This repository has been archived by the owner on Jan 15, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
337 additions
and
258 deletions.
There are no files selected for viewing
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,65 @@ | ||
using System; | ||
using System.Linq; | ||
using Glimpse.Ado.Message; | ||
using Glimpse.Ado.Model; | ||
using Glimpse.Core.Extensibility; | ||
using Glimpse.Core.Extensions; | ||
|
||
namespace Glimpse.Ado.Display | ||
{ | ||
[Obsolete] | ||
public class SqlDisplay : IDisplay, ITabSetup, IKey | ||
{ | ||
private const string InternalName = "sql"; | ||
|
||
public string Name | ||
{ | ||
get { return InternalName; } | ||
} | ||
|
||
public string Key | ||
{ | ||
get { return InternalName; } | ||
} | ||
|
||
public object GetData(ITabContext context) | ||
{ | ||
var messages = context.GetMessages<AdoMessage>().ToList(); | ||
var aggregator = new MessageAggregator(messages); | ||
var queryData = aggregator.Aggregate(); | ||
|
||
var queryCount = queryData.Commands.Count; | ||
var connectionCount = queryData.Connections.Count; | ||
var transactionCount = queryData.Transactions.Count; | ||
|
||
var queryExecutionTime = new TimeSpan(); | ||
var connectionOpenTime = new TimeSpan(); | ||
|
||
foreach (var command in queryData.Commands) | ||
{ | ||
var commandMetadata = command.Value; | ||
queryExecutionTime += commandMetadata.Duration; | ||
} | ||
|
||
foreach (var connection in queryData.Connections) | ||
{ | ||
var connectionMetadata = connection.Value; | ||
connectionOpenTime += connectionMetadata.Duration.GetValueOrDefault(TimeSpan.Zero); | ||
} | ||
|
||
return new | ||
{ | ||
queryCount, | ||
connectionCount, | ||
transactionCount, | ||
queryExecutionTime, | ||
connectionOpenTime | ||
}; | ||
} | ||
|
||
public void Setup(ITabSetupContext context) | ||
{ | ||
context.PersistMessages<AdoMessage>(); | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using System; | ||
using System.Threading; | ||
using Glimpse.Core.Extensibility; | ||
|
||
namespace Glimpse.AspNet.Display | ||
{ | ||
[Obsolete] | ||
public class EnvironmentDisplay : IDisplay, IKey | ||
{ | ||
private const string InternalName = "environment"; | ||
|
||
public string Name | ||
{ | ||
get { return InternalName; } | ||
} | ||
|
||
public string Key | ||
{ | ||
get { return InternalName; } | ||
} | ||
|
||
public object GetData(ITabContext context) | ||
{ | ||
return new | ||
{ | ||
serverName = Environment.MachineName, | ||
user = Thread.CurrentPrincipal.Identity.Name | ||
}; | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using System; | ||
using System.Linq; | ||
using Glimpse.Core.Extensibility; | ||
using Glimpse.Core.Extensions; | ||
using Glimpse.Core.Message; | ||
|
||
namespace Glimpse.Core.Display | ||
{ | ||
[Obsolete] | ||
public class TimingsDisplay : IDisplay, ITabSetup, IKey | ||
{ | ||
private const string InternalName = "Timings"; | ||
|
||
public string Name | ||
{ | ||
get { return InternalName; } | ||
} | ||
|
||
public string Key | ||
{ | ||
get { return InternalName; } | ||
} | ||
|
||
public object GetData(ITabContext context) | ||
{ | ||
return context.GetMessages<ITimelineMessage>() | ||
.Where(m => | ||
m.EventCategory.Name.Equals("Command") || | ||
m.EventCategory.Name.Equals("Controller") || | ||
m.EventCategory.Name.Equals("Render")); | ||
} | ||
|
||
public void Setup(ITabSetupContext context) | ||
{ | ||
context.PersistMessages<ITimelineMessage>(); | ||
} | ||
} | ||
} |
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
22 changes: 22 additions & 0 deletions
22
source/Glimpse.Core/SerializationConverter/EnumerableOfITimelineMessageConverter.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,22 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Glimpse.Core.Extensibility; | ||
using Glimpse.Core.Message; | ||
|
||
namespace Glimpse.Core.SerializationConverter | ||
{ | ||
public class EnumerableOfITimelineMessageConverter : SerializationConverter<IEnumerable<ITimelineMessage>> | ||
{ | ||
public override object Convert(IEnumerable<ITimelineMessage> obj) | ||
{ | ||
return obj.Select(message => new | ||
{ | ||
title = message.EventName, | ||
startTime = message.StartTime, | ||
duration = message.Duration, | ||
startPoint = message.Offset, | ||
category = message.EventCategory.Name | ||
}); | ||
} | ||
} | ||
} |
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,104 @@ | ||
using System; | ||
using Glimpse.AspNet.AlternateType; | ||
using Glimpse.Core.Extensibility; | ||
using Glimpse.Core.Extensions; | ||
using Glimpse.Mvc.AlternateType; | ||
using Glimpse.Mvc.Model; | ||
|
||
namespace Glimpse.Mvc.Display | ||
{ | ||
public class MvcDisplay : IDisplay, ITabSetup, IKey | ||
{ | ||
private const string InternalName = "mvc"; | ||
|
||
public string Name | ||
{ | ||
get { return InternalName; } | ||
} | ||
|
||
public string Key | ||
{ | ||
get { return InternalName; } | ||
} | ||
|
||
public object GetData(ITabContext context) | ||
{ | ||
var result = context.TabStore.Get<MvcDisplayModel>(); | ||
|
||
return result; | ||
} | ||
|
||
public void Setup(ITabSetupContext context) | ||
{ | ||
var mb = context.MessageBroker; | ||
|
||
mb.Subscribe<ActionInvoker.InvokeActionMethod.Message>(m => UpdateAction(m, context)); | ||
mb.Subscribe<ViewEngine.FindViews.Message>(m => UpdateView(m, context)); | ||
mb.Subscribe<View.Render.Message>(m => UpdateRender(m, context)); | ||
mb.Subscribe<RouteBase.GetRouteData.Message>(m => UpdateRoute(m, context)); | ||
} | ||
|
||
private void UpdateRoute(RouteBase.GetRouteData.Message message, ITabSetupContext context) | ||
{ | ||
var model = GetModel(context.GetTabStore()); | ||
|
||
// string.Empty is a valid routeName | ||
if (message.IsMatch && model.MatchedRouteName == null) | ||
{ | ||
// only update the first matched route | ||
model.MatchedRouteName = message.RouteName; | ||
} | ||
} | ||
|
||
private void UpdateRender(View.Render.Message message, ITabSetupContext context) | ||
{ | ||
var model = GetModel(context.GetTabStore()); | ||
|
||
// Last message in is the first/primary view | ||
model.ViewRenderTime = Math.Round(message.Duration.TotalMilliseconds, 2); | ||
} | ||
|
||
private void UpdateAction(ActionInvoker.InvokeActionMethod.Message message, ITabSetupContext context) | ||
{ | ||
var model = GetModel(context.GetTabStore()); | ||
|
||
if (message.IsChildAction) | ||
{ | ||
model.ChildActionCount++; | ||
} | ||
else | ||
{ | ||
model.ActionName = message.ActionName; | ||
model.ActionExecutionTime = Math.Round(message.Duration.TotalMilliseconds, 2); | ||
model.ControllerName = message.ControllerName; | ||
} | ||
} | ||
|
||
private void UpdateView(ViewEngine.FindViews.Message message, ITabSetupContext context) | ||
{ | ||
if (message.IsFound) | ||
{ | ||
var model = GetModel(context.GetTabStore()); | ||
|
||
model.ChildViewCount++; | ||
|
||
if (model.ViewName == null) | ||
{ | ||
model.ViewName = message.ViewName; | ||
} | ||
} | ||
} | ||
|
||
private MvcDisplayModel GetModel(IDataStore tabStore) | ||
{ | ||
if (tabStore.Contains<MvcDisplayModel>()) | ||
{ | ||
return tabStore.Get<MvcDisplayModel>(); | ||
} | ||
|
||
var model = new MvcDisplayModel(); | ||
tabStore.Set(model); | ||
return model; | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
namespace Glimpse.Mvc.Model | ||
{ | ||
public class MvcDisplayModel | ||
{ | ||
public MvcDisplayModel() | ||
{ | ||
ChildViewCount = -1; | ||
} | ||
|
||
public string ActionName { get; set; } | ||
|
||
public double? ActionExecutionTime { get; set; } | ||
|
||
public int ChildActionCount { get; set; } | ||
|
||
public string ViewName { get; set; } | ||
|
||
public double? ViewRenderTime { get; set; } | ||
|
||
public int ChildViewCount { get; set; } | ||
|
||
public string ControllerName { get; set; } | ||
|
||
public string MatchedRouteName { get; set; } | ||
} | ||
} |
Oops, something went wrong.