Skip to content

Commit

Permalink
spiked out more of the new instrumentation recording
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremydmiller committed Aug 25, 2015
1 parent dbf87d8 commit 3bf5b31
Showing 1 changed file with 35 additions and 18 deletions.
53 changes: 35 additions & 18 deletions src/FubuMVC.Core/Diagnostics/Instrumentation/IExecutionRecorder.cs
Original file line number Diff line number Diff line change
@@ -1,50 +1,62 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Threading.Tasks;
using FubuMVC.Core.Diagnostics.Packaging;

namespace FubuMVC.Core.Diagnostics.Instrumentation
{
public interface IExecutionRecorder
{
void Record(ChainExecutionLog log);
void Record(ChainExecutionLog log, IDictionary<string, object> http);
}


// This will need to be registered.
public class InMemoryExecutionRecorder : IExecutionRecorder
public class NulloExecutionRecorder : IExecutionRecorder
{
private readonly PerformanceHistoryQueue _queue;
public void Record(ChainExecutionLog log, IDictionary<string, object> http)
{
// no-op
}
}

public InMemoryExecutionRecorder(PerformanceHistoryQueue queue)
public class VerboseExecutionRecorder : IExecutionRecorder
{
private readonly IExecutionLogStorage _storage;

public VerboseExecutionRecorder(IExecutionLogStorage storage)
{
_queue = queue;
_storage = storage;
}

public void Record(ChainExecutionLog log)
public void Record(ChainExecutionLog log, IDictionary<string, object> http)
{
_queue.Enqueue(log);
throw new NotImplementedException();
}
}

// TODO -- this will need to be registered
public class PerformanceHistoryRecording : IActivator
public class ProductionExecutionRecorder : IExecutionRecorder
{
private readonly PerformanceHistoryQueue _queue;
private readonly IExecutionLogStorage _storage;

public PerformanceHistoryRecording(PerformanceHistoryQueue queue)
public ProductionExecutionRecorder(IExecutionLogStorage storage)
{
_queue = queue;
_storage = storage;
}

public void Activate(IActivationLog log, IPerfTimer timer)
public void Record(ChainExecutionLog log, IDictionary<string, object> http)
{
log.Trace("Starting the in memory performance tracking");
_queue.Start();
throw new NotImplementedException();
}
}

public class PerformanceHistoryQueue : IDisposable
public interface IExecutionLogStorage
{
void Store(ChainExecutionLog log);
void Start();
}


public class PerformanceHistoryQueue : IExecutionLogStorage, IDisposable
{
private readonly BlockingCollection<ChainExecutionLog> _collection =
new BlockingCollection<ChainExecutionLog>(new ConcurrentBag<ChainExecutionLog>());
Expand Down Expand Up @@ -75,5 +87,10 @@ public void Start()
{
_readingTask = Task.Factory.StartNew(record);
}

void IExecutionLogStorage.Store(ChainExecutionLog log)
{
Enqueue(log);
}
}
}

0 comments on commit 3bf5b31

Please sign in to comment.