Skip to content
Browse files

#Update #283 - Add ITimelineMessage to Connection/Command ADO messages

  • Loading branch information...
1 parent 39de566 commit 31aa6af3c96595bc3fe7ac2e94267433c92330d7 @avanderhoorn avanderhoorn committed
View
28 source/Glimpse.Ado/AlternateType/GlimpseDbCommand.cs
@@ -183,11 +183,11 @@ protected override DbDataReader ExecuteDbDataReader(CommandBehavior behavior)
}
catch (Exception exception)
{
- LogCommandError(commandId, timer, exception);
+ LogCommandError(commandId, timer, exception, "ExecuteDbDataReader");
throw;
}
- LogCommandEnd(commandId, timer, reader.RecordsAffected);
+ LogCommandEnd(commandId, timer, reader.RecordsAffected, "ExecuteDbDataReader");
return new GlimpseDbDataReader(reader, InnerCommand, InnerConnection.ConnectionId, commandId);
}
@@ -204,11 +204,11 @@ public override int ExecuteNonQuery()
num = InnerCommand.ExecuteNonQuery();
}
catch (Exception exception)
- {
- LogCommandError(commandId, timer, exception);
+ {
+ LogCommandError(commandId, timer, exception, "ExecuteNonQuery");
throw;
- }
- LogCommandEnd(commandId, timer, num);
+ }
+ LogCommandEnd(commandId, timer, num, "ExecuteNonQuery");
return num;
}
@@ -225,11 +225,11 @@ public override object ExecuteScalar()
result = InnerCommand.ExecuteScalar();
}
catch (Exception exception)
- {
- LogCommandError(commandId, timer, exception);
+ {
+ LogCommandError(commandId, timer, exception, "ExecuteScalar");
throw;
}
- LogCommandEnd(commandId, timer, null);
+ LogCommandEnd(commandId, timer, null, "ExecuteScalar");
return result;
}
@@ -312,23 +312,25 @@ private void LogCommandStart(Guid commandId, TimeSpan timerTimeSpan)
}
}
- private void LogCommandEnd(Guid commandId, TimeSpan timer, int? recordsAffected)
+ private void LogCommandEnd(Guid commandId, TimeSpan timer, int? recordsAffected, string type)
{
if (MessageBroker != null)
{
MessageBroker.Publish(
new CommandDurationAndRowCountMessage(InnerConnection.ConnectionId, commandId, recordsAffected)
- .AsTimedMessage(TimerStop(timer)));
+ .AsTimedMessage(TimerStop(timer))
+ .AsTimelineMessage("Command Executed", AdoTimelineCategory.Command, type));
}
}
- private void LogCommandError(Guid commandId, TimeSpan timer, Exception exception)
+ private void LogCommandError(Guid commandId, TimeSpan timer, Exception exception, string type)
{
if (MessageBroker != null)
{
MessageBroker.Publish(
new CommandErrorMessage(InnerConnection.ConnectionId, commandId, exception)
- .AsTimedMessage(TimerStop(timer)));
+ .AsTimedMessage(TimerStop(timer))
+ .AsTimelineMessage("Command Error", AdoTimelineCategory.Command, type));
}
}
View
3 source/Glimpse.Ado/AlternateType/GlimpseDbConnection.cs
@@ -229,7 +229,8 @@ private void ClosedConnection()
{
MessageBroker.Publish(
new ConnectionClosedMessage(ConnectionId)
- .AsTimedMessage(TimerStop(timerTimeSpan)));
+ .AsTimedMessage(TimerStop(timerTimeSpan))
+ .AsTimelineMessage("Connection Opened", AdoTimelineCategory.Connection));
}
private TimeSpan TimerTrigger()
View
1 source/Glimpse.Ado/Glimpse.Ado.csproj
@@ -59,6 +59,7 @@
<Compile Include="Message\ConnectionStartedMessage.cs" />
<Compile Include="Message\DtcTransactionCompletedMessage.cs" />
<Compile Include="Message\DtcTransactionEnlistedMessage.cs" />
+ <Compile Include="Message\MvcTimelineCategory.cs" />
<Compile Include="Message\TransactionBeganMessage.cs" />
<Compile Include="Message\TransactionCommitMessage.cs" />
<Compile Include="Message\TransactionRollbackMessage.cs" />
View
9 source/Glimpse.Ado/Message/CommandDurationAndRowCountMessage.cs
@@ -1,8 +1,9 @@
using System;
+using Glimpse.Core.Message;
namespace Glimpse.Ado.Message
{
- public class CommandDurationAndRowCountMessage : AdoCommandMessage
+ public class CommandDurationAndRowCountMessage : AdoCommandMessage, ITimelineMessage
{
public CommandDurationAndRowCountMessage(Guid connectionId, Guid commandId, long? recordsAffected)
: base(connectionId, commandId)
@@ -12,5 +13,11 @@ public CommandDurationAndRowCountMessage(Guid connectionId, Guid commandId, long
}
public long? RecordsAffected { get; protected set; }
+
+ public string EventName { get; set; }
+
+ public TimelineCategoryItem EventCategory { get; set; }
+
+ public string EventSubText { get; set; }
}
}
View
11 source/Glimpse.Ado/Message/CommandErrorMessage.cs
@@ -1,8 +1,9 @@
using System;
+using Glimpse.Core.Message;
namespace Glimpse.Ado.Message
{
- public class CommandErrorMessage : AdoCommandMessage
+ public class CommandErrorMessage : AdoCommandMessage, ITimelineMessage
{
public CommandErrorMessage(Guid connectionId, Guid commandId, Exception exception)
: base(connectionId, commandId)
@@ -10,6 +11,12 @@ public CommandErrorMessage(Guid connectionId, Guid commandId, Exception exceptio
Exception = exception;
}
- public Exception Exception { get; protected set; }
+ public Exception Exception { get; protected set; }
+
+ public string EventName { get; set; }
+
+ public TimelineCategoryItem EventCategory { get; set; }
+
+ public string EventSubText { get; set; }
}
}
View
12 source/Glimpse.Ado/Message/ConnectionClosedMessage.cs
@@ -1,11 +1,19 @@
using System;
+using Glimpse.Core.Message;
namespace Glimpse.Ado.Message
{
- public class ConnectionClosedMessage : AdoMessage
+ public class ConnectionClosedMessage : AdoMessage, ITimelineMessage
{
- public ConnectionClosedMessage(Guid connectionId) : base(connectionId)
+ public ConnectionClosedMessage(Guid connectionId)
+ : base(connectionId)
{
}
+
+ public string EventName { get; set; }
+
+ public TimelineCategoryItem EventCategory { get; set; }
+
+ public string EventSubText { get; set; }
}
}
View
29 source/Glimpse.Ado/Message/MvcTimelineCategory.cs
@@ -0,0 +1,29 @@
+using TimelineCategoryItem = Glimpse.Core.Message.TimelineCategoryItem;
+
+namespace Glimpse.Ado.Message
+{
+ /// <summary>
+ /// Options that can used for timeline events.
+ /// </summary>
+ public class AdoTimelineCategory : Glimpse.Core.Message.TimelineCategory
+ {
+ private static TimelineCategoryItem connection = new TimelineCategoryItem("Connection", "#F0ED5D", "#DEE81A");
+ private static TimelineCategoryItem command = new TimelineCategoryItem("Command", "#FD45F7", "#DD31DA");
+
+ /// <summary>
+ /// Gets the timeline category for a connection.
+ /// </summary>
+ public static TimelineCategoryItem Connection
+ {
+ get { return connection; }
+ }
+
+ /// <summary>
+ /// Gets the timeline category for a command.
+ /// </summary>
+ public static TimelineCategoryItem Command
+ {
+ get { return command; }
+ }
+ }
+}

0 comments on commit 31aa6af

Please sign in to comment.
Something went wrong with that request. Please try again.