-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
end to end tracing with the new instrumentation using OWIN requests
- Loading branch information
1 parent
d2df0ab
commit 3763b2a
Showing
11 changed files
with
197 additions
and
47 deletions.
There are no files selected for viewing
63 changes: 63 additions & 0 deletions
63
src/FubuMVC.Core/Diagnostics/Instrumentation/ChainExecutionListener.cs
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,63 @@ | ||
using System; | ||
using FubuCore.Logging; | ||
using ExceptionReport = FubuCore.Logging.ExceptionReport; | ||
|
||
namespace FubuMVC.Core.Diagnostics.Instrumentation | ||
{ | ||
public class ChainExecutionListener : ILogListener | ||
{ | ||
private readonly IChainExecutionLog _trace; | ||
|
||
public ChainExecutionListener(IChainExecutionLog trace) | ||
{ | ||
_trace = trace; | ||
} | ||
|
||
public bool ListensFor(Type type) | ||
{ | ||
return true; | ||
} | ||
|
||
public void DebugMessage(object message) | ||
{ | ||
_trace.Log(message); | ||
} | ||
|
||
public void InfoMessage(object message) | ||
{ | ||
_trace.Log(message); | ||
} | ||
|
||
public void Debug(string message) | ||
{ | ||
_trace.Log(new StringMessage(message)); | ||
} | ||
|
||
public void Info(string message) | ||
{ | ||
_trace.Log(new StringMessage(message)); | ||
} | ||
|
||
public void Error(string message, Exception ex) | ||
{ | ||
_trace.Log(new ExceptionReport(message, ex)); | ||
} | ||
|
||
public void Error(object correlationId, string message, Exception ex) | ||
{ | ||
_trace.Log(new ExceptionReport(message, ex){ | ||
CorrelationId = correlationId | ||
}); | ||
} | ||
|
||
public bool IsDebugEnabled | ||
{ | ||
get { return true; } | ||
} | ||
|
||
public bool IsInfoEnabled | ||
{ | ||
get { return true; } | ||
} | ||
} | ||
} |
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
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
44 changes: 44 additions & 0 deletions
44
src/FubuMVC.Tests/Diagnostics/Instrumentation/ChainExecutionHistoryTester.cs
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,44 @@ | ||
using System.Linq; | ||
using FubuMVC.Core; | ||
using FubuMVC.Core.Diagnostics.Instrumentation; | ||
using FubuMVC.Core.Diagnostics.Runtime; | ||
using NUnit.Framework; | ||
using Shouldly; | ||
|
||
namespace FubuMVC.Tests.Diagnostics.Instrumentation | ||
{ | ||
[TestFixture] | ||
public class ChainExecutionHistoryTester | ||
{ | ||
[Test] | ||
public void only_cache_up_to_the_setting_limit() | ||
{ | ||
var settings = new DiagnosticsSettings | ||
{ | ||
MaxRequests = 10 | ||
}; | ||
|
||
var cache = new ChainExecutionHistory(settings); | ||
|
||
cache.Store(new ChainExecutionLog()); | ||
cache.Store(new ChainExecutionLog()); | ||
cache.Store(new ChainExecutionLog()); | ||
cache.Store(new ChainExecutionLog()); | ||
cache.Store(new ChainExecutionLog()); | ||
cache.Store(new ChainExecutionLog()); | ||
cache.Store(new ChainExecutionLog()); | ||
cache.Store(new ChainExecutionLog()); | ||
cache.Store(new ChainExecutionLog()); | ||
|
||
cache.RecentReports().Count().ShouldBe(9); | ||
|
||
cache.Store(new ChainExecutionLog()); | ||
cache.Store(new ChainExecutionLog()); | ||
cache.Store(new ChainExecutionLog()); | ||
cache.Store(new ChainExecutionLog()); | ||
cache.Store(new ChainExecutionLog()); | ||
|
||
cache.RecentReports().Count().ShouldBe(settings.MaxRequests); | ||
} | ||
} | ||
} |
69 changes: 69 additions & 0 deletions
69
src/FubuMVC.Tests/Diagnostics/Instrumentation/ChainExecutionListenerTester.cs
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,69 @@ | ||
using FubuCore.Logging; | ||
using FubuMVC.Core.Diagnostics.Instrumentation; | ||
using FubuMVC.Core.Diagnostics.Runtime.Tracing; | ||
using FubuMVC.Tests.TestSupport; | ||
using NUnit.Framework; | ||
using Rhino.Mocks; | ||
using Shouldly; | ||
|
||
namespace FubuMVC.Tests.Diagnostics.Instrumentation | ||
{ | ||
[TestFixture] | ||
public class ChainExecutionListenerTester : InteractionContext<ChainExecutionListener> | ||
{ | ||
private void assertMessageWasLogged(object message) | ||
{ | ||
MockFor<IChainExecutionLog>().AssertWasCalled(x => x.Log(message)); | ||
} | ||
|
||
[Test] | ||
public void debugging_is_enabled() | ||
{ | ||
ClassUnderTest.IsDebugEnabled.ShouldBeTrue(); | ||
} | ||
|
||
[Test] | ||
public void info_is_enabled() | ||
{ | ||
ClassUnderTest.IsInfoEnabled.ShouldBeTrue(); | ||
} | ||
|
||
[Test] | ||
public void debug_message_delegates() | ||
{ | ||
var message = new object(); | ||
|
||
ClassUnderTest.DebugMessage(message); | ||
|
||
assertMessageWasLogged(message); | ||
} | ||
|
||
[Test] | ||
public void debug_string_delegates() | ||
{ | ||
ClassUnderTest.Debug("some stuff"); | ||
|
||
assertMessageWasLogged(new StringMessage("some stuff")); | ||
} | ||
|
||
[Test] | ||
public void info_message_delegates() | ||
{ | ||
var message = new object(); | ||
|
||
ClassUnderTest.InfoMessage(message); | ||
|
||
assertMessageWasLogged(message); | ||
} | ||
|
||
[Test] | ||
public void info_string_delegates() | ||
{ | ||
ClassUnderTest.Info("some stuff"); | ||
|
||
assertMessageWasLogged(new StringMessage("some stuff")); | ||
} | ||
|
||
|
||
} | ||
} |
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