Skip to content

Commit

Permalink
added envelope logging to the IExecutionLogger implementations
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremydmiller committed Sep 1, 2015
1 parent 0aedcbe commit d2b349c
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using FubuMVC.Core.Registration.Nodes;
using FubuMVC.Core.ServiceBus.Runtime;

namespace FubuMVC.Core.Diagnostics.Instrumentation
{
Expand All @@ -14,6 +15,9 @@ public interface IChainExecutionLog
void RecordHeaders(IDictionary<string, object> env);
void RecordBody(IDictionary<string, object> env);

void RecordHeaders(Envelope envelope);
void RecordBody(Envelope envelope);

Guid Id { get; }
BehaviorChain RootChain { get; set; }
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using System.Collections.Generic;
using FubuMVC.Core.ServiceBus.Runtime;

namespace FubuMVC.Core.Diagnostics.Instrumentation
{
public interface IExecutionLogger
{
void Record(IChainExecutionLog log, IDictionary<string, object> http);
void Record(IChainExecutionLog log, Envelope envelope);
}
}
4 changes: 2 additions & 2 deletions src/FubuMVC.Core/Diagnostics/Instrumentation/IRequestLog.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using FubuMVC.Core.ServiceBus.Runtime;

namespace FubuMVC.Core.Diagnostics.Instrumentation
{
public interface IRequestLog
{
double ExecutionTime { get; }
bool HadException { get; }


}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using FubuMVC.Core.ServiceBus.Runtime;

namespace FubuMVC.Core.Diagnostics.Instrumentation
{
Expand All @@ -8,5 +9,10 @@ public void Record(IChainExecutionLog log, IDictionary<string, object> http)
{
// no-op
}

public void Record(IChainExecutionLog log, Envelope envelope)
{
// no-op
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using FubuMVC.Core.ServiceBus.Runtime;

namespace FubuMVC.Core.Diagnostics.Instrumentation
{
Expand All @@ -16,5 +17,12 @@ public void Record(IChainExecutionLog log, IDictionary<string, object> http)
log.RecordHeaders(http);
_storage.Store(log);
}

public void Record(IChainExecutionLog log, Envelope envelope)
{
log.RecordHeaders(envelope);

_storage.Store(log);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using FubuMVC.Core.ServiceBus.Runtime;

namespace FubuMVC.Core.Diagnostics.Instrumentation
{
Expand All @@ -18,5 +19,13 @@ public void Record(IChainExecutionLog log, IDictionary<string, object> http)

_storage.Store(log);
}

public void Record(IChainExecutionLog log, Envelope envelope)
{
log.RecordHeaders(envelope);
log.RecordBody(envelope);

_storage.Store(log);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -147,16 +147,6 @@ public void has_exception()
log.HadException.ShouldBeTrue();
}

[Test]
public void mark_finished()
{
var log = new ChainExecutionLog();
Thread.Sleep(5);
log.MarkFinished();

log.ExecutionTime.ShouldBeGreaterThan(0);
}

[Test]
public void record_headers_from_http_request()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using FubuMVC.Core.Diagnostics.Instrumentation;
using FubuMVC.Core.ServiceBus.Runtime;
using FubuMVC.Tests.TestSupport;
using NUnit.Framework;
using Rhino.Mocks;
Expand All @@ -22,5 +23,19 @@ public void record()

MockFor<IExecutionLogStorage>().AssertWasCalled(x => x.Store(log));
}

[Test]
public void record_for_envelope()
{
var log = MockFor<IChainExecutionLog>();
var envelope = new Envelope();

ClassUnderTest.Record(log, envelope);

log.AssertWasCalled(x => x.RecordHeaders(envelope));
log.AssertWasNotCalled(x => x.RecordBody(envelope));

MockFor<IExecutionLogStorage>().AssertWasCalled(x => x.Store(log));
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using FubuMVC.Core.Diagnostics.Instrumentation;
using FubuMVC.Core.ServiceBus.Runtime;
using FubuMVC.Tests.TestSupport;
using NUnit.Framework;
using Rhino.Mocks;
Expand All @@ -22,5 +23,19 @@ public void record()

MockFor<IExecutionLogStorage>().AssertWasCalled(x => x.Store(log));
}

[Test]
public void record_for_envelope()
{
var log = MockFor<IChainExecutionLog>();
var envelope = new Envelope();

ClassUnderTest.Record(log, envelope);

log.AssertWasCalled(x => x.RecordHeaders(envelope));
log.AssertWasCalled(x => x.RecordBody(envelope));

MockFor<IExecutionLogStorage>().AssertWasCalled(x => x.Store(log));
}
}
}

0 comments on commit d2b349c

Please sign in to comment.