I am currently using Asp.Net MVC 4 and I would like to include the time of some routines used by my controllers in the glimpse's timeline tab.
I know that I have to create an ITimeLineMessage Implementation and send the timing information with a message broker. But how to create the ITimeLineMessage ?
Here is a way but its not very nice and not supported:
- Retrieve the MessageBroker for the following static method:
Glimpse.Core.Framework.GlimpseConfiguration.GetConfiguredMessageBroker()
- Then publish an ITimelineMessage to the MessageBroker:
messageBroker.Publish(timelineMessage)
- Note, you could create a generic message type that you use over again that implements
ITimelineMessage
- To populate the properties of your ITimelineMessage implementation you might also need
IExecutionTimer
. You can get this via the following static method:
Glimpse.Core.Framework.GlimpseConfiguration.GetConfiguredTimerStrategy()
- The above will have the knowledge of when the request started for offsets etc.
As @nikmd23 said, we know this is about as bad as what you could ever want to do but v2 will see a much much more simple way of doing this.
Here is an implementation using anthonyv's suggestion:
https://gist.github.com/droyad/8292852
You can create any custom class you want, that class just has to implement ITimelineMessage
.
As a general heads up, we are currently working through a way to make this WAY easier. If the approach described there interests you, please do provide your feedback.