-
Notifications
You must be signed in to change notification settings - Fork 603
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for hooking in additional instrumentation around Timings (#…
…650) Most of the code of _a project that I'm working on_ is instrumented via MiniProfiler's extension methods. In order to get the MiniProfiler instrumented sections/traces into 3rd party APM tools, we'd either need to hijack all the MiniProfiler extension method combinations, or add yet another `using` around everything we instrument via MiniProfiler. The latter is particularly impractical for the `.Inline(() => ....)` extension methods etc.
- Loading branch information
Showing
4 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using System; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
namespace StackExchange.Profiling.Tests | ||
{ | ||
public class TimingInstrumentationTest : BaseTest | ||
{ | ||
public TimingInstrumentationTest(ITestOutputHelper output) : base(output) { } | ||
|
||
private class TimingInstrumentation : IDisposable | ||
{ | ||
public Timing Timing { get; set; } | ||
public bool Disposed { get; set; } | ||
public void Dispose() => Disposed = true; | ||
} | ||
|
||
[Fact] | ||
public void IsInstrumented() | ||
{ | ||
TimingInstrumentation instrumentation = null; | ||
Timing timing = null; | ||
Options.TimingInstrumentationProvider = t => instrumentation = new TimingInstrumentation { Timing = t }; | ||
var mp = Options.StartProfiler(); | ||
|
||
using (timing = mp.Step("Test timing")) | ||
{ | ||
Assert.NotNull(instrumentation); | ||
Assert.False(instrumentation.Disposed); | ||
mp.Increment(); | ||
} | ||
|
||
Assert.NotNull(instrumentation); | ||
Assert.Equal(timing, instrumentation.Timing); | ||
Assert.True(instrumentation.Disposed); | ||
} | ||
} | ||
} |