Пример #1
0
 public RequestMetadataProvider(EntryFactory entryFactory)
 {
     mEntryFactory = entryFactory;
 }
Пример #2
0
        /// <summary>
        /// Returns debug information that will be sent to the Glimpse client.
        /// </summary>
        /// <param name="context">The tab context.</param>
        /// <returns>An object with debug information that the Glimpse client can display.</returns>
        public override object GetData(ITabContext context)
        {
            var connectionStringRegistry = new ConnectionStringRegistry();
            var entryFactory             = new EntryFactory(connectionStringRegistry);
            var requestMetadataProvider  = new RequestMetadataProvider(entryFactory);
            var requestMetadata          = requestMetadataProvider.GetRequestMetadata(SqlDebug.CurrentRequestLog);

            var items = new List <object[]>
            {
                new object[] { "Ordinal", "Information", "Text", "Result", "Received", "Sent", "Duration", "Stack trace" }
            };

            var nextOrdinal = 1;

            foreach (var entry in requestMetadata.Entries)
            {
                CommandEntry commandEntry = entry as CommandEntry;
                if (commandEntry != null)
                {
                    items.Add(new object[] {
                        String.Format(CultureInfo.InvariantCulture, "{0:N0}", nextOrdinal++),
                        GetInformation(commandEntry),
                        GetText(commandEntry),
                        GetResult(commandEntry),
                        String.Format(CultureInfo.InvariantCulture, "!{0:N0} B {1}!", commandEntry.BytesReceived, GetBytesReceivedChart(requestMetadata, commandEntry)),
                        String.Format(CultureInfo.InvariantCulture, "!{0:N0} B {1}!", commandEntry.BytesSent, GetBytesSentChart(requestMetadata, commandEntry)),
                        String.Format(CultureInfo.InvariantCulture, "!{0:N0} ms {1}!", commandEntry.Duration.TotalMilliseconds, GetDurationChart(requestMetadata, commandEntry)),
                        commandEntry.StackTrace,
                        commandEntry.IsDuplicate ? "warn" : String.Empty
                    });
                    continue;
                }

                ConnectionEntry connectionEntry = entry as ConnectionEntry;
                if (connectionEntry != null)
                {
                    items.Add(new object[] {
                        String.Empty,
                        GetInformation(connectionEntry),
                        String.Empty,
                        null,
                        null,
                        null,
                        null,
                        connectionEntry.StackTrace,
                        "quiet"
                    });
                    continue;
                }

                InformationEntry informationEntry = entry as InformationEntry;
                if (informationEntry != null)
                {
                    items.Add(new object[] {
                        String.Empty,
                        GetInformation(informationEntry),
                        null,
                        null,
                        null,
                        null,
                        null,
                        null,
                        "info"
                    });
                    continue;
                }
            }

            var statictics = new object[] {
                new object[] { "Name", "Value" },
                new object[] { "Queries", String.Format(CultureInfo.InvariantCulture, "{0:N0}", requestMetadata.Statistics.TotalCommands) },
                new object[] { "Duplicate queries", String.Format(CultureInfo.InvariantCulture, "{0:N0}", requestMetadata.Statistics.TotalDuplicateCommands) },
                new object[] { "Duration", String.Format(CultureInfo.InvariantCulture, "{0:N0} ms", requestMetadata.Statistics.TotalDuration.TotalMilliseconds) },
                new object[] { "Received", String.Format(CultureInfo.InvariantCulture, "{0:N0} B", requestMetadata.Statistics.TotalBytesReceived) },
                new object[] { "Sent", String.Format(CultureInfo.InvariantCulture, "{0:N0} B", requestMetadata.Statistics.TotalBytesSent) }
            };

            return(new Dictionary <string, object>
            {
                { SECTION_KEY_STATISTICS, statictics },
                { SECTION_KEY_QUERIES, items }
            });
        }
Пример #3
0
        /// <summary>
        /// Returns debug information that will be sent to the Glimpse client.
        /// </summary>
        /// <param name="context">The tab context.</param>
        /// <returns>An object with debug information that the Glimpse client can display.</returns>
        public override object GetData(ITabContext context)
        {
            var connectionStringRegistry = new ConnectionStringRegistry();
            var entryFactory = new EntryFactory(connectionStringRegistry);
            var requestMetadataProvider = new RequestMetadataProvider(entryFactory);
            var requestMetadata = requestMetadataProvider.GetRequestMetadata(SqlDebug.CurrentRequestLog);

            var items = new List<object[]>
            {
                new object[] {"Ordinal", "Information", "Text", "Result", "Received", "Sent", "Duration", "Stack trace"}
            };

            var nextOrdinal = 1;
            foreach (var entry in requestMetadata.Entries)
            {
                CommandEntry commandEntry = entry as CommandEntry;
                if (commandEntry != null)
                {
                    items.Add(new object[] {
                        String.Format(CultureInfo.InvariantCulture, "{0:N0}", nextOrdinal++),
                        GetInformation(commandEntry),
                        GetText(commandEntry),
                        GetResult(commandEntry),
                        String.Format(CultureInfo.InvariantCulture, "!{0:N0} B {1}!", commandEntry.BytesReceived, GetBytesReceivedChart(requestMetadata, commandEntry)),
                        String.Format(CultureInfo.InvariantCulture, "!{0:N0} B {1}!", commandEntry.BytesSent, GetBytesSentChart(requestMetadata, commandEntry)),
                        String.Format(CultureInfo.InvariantCulture, "!{0:N0} ms {1}!", commandEntry.Duration.TotalMilliseconds, GetDurationChart(requestMetadata, commandEntry)),
                        commandEntry.StackTrace,
                        commandEntry.IsDuplicate ? "warn" : String.Empty
                    });
                    continue;
                }

                ConnectionEntry connectionEntry = entry as ConnectionEntry;
                if (connectionEntry != null)
                {
                    items.Add(new object[] {
                        String.Empty,
                        GetInformation(connectionEntry),
                        String.Empty,
                        null,
                        null,
                        null,
                        null,
                        connectionEntry.StackTrace,
                        "quiet"
                    });
                    continue;
                }

                InformationEntry informationEntry = entry as InformationEntry;
                if (informationEntry != null)
                {
                    items.Add(new object[] {
                        String.Empty,
                        GetInformation(informationEntry),
                        null,
                        null,
                        null,
                        null,
                        null,
                        null,
                        "info"
                    });
                    continue;
                }
            }

            var statictics = new object[] {
                new object[] { "Name", "Value" },
                new object[] { "Queries", String.Format(CultureInfo.InvariantCulture, "{0:N0}", requestMetadata.Statistics.TotalCommands) },
                new object[] { "Duplicate queries", String.Format(CultureInfo.InvariantCulture, "{0:N0}", requestMetadata.Statistics.TotalDuplicateCommands) },
                new object[] { "Duration", String.Format(CultureInfo.InvariantCulture, "{0:N0} ms", requestMetadata.Statistics.TotalDuration.TotalMilliseconds) },
                new object[] { "Received", String.Format(CultureInfo.InvariantCulture, "{0:N0} B", requestMetadata.Statistics.TotalBytesReceived) },
                new object[] { "Sent", String.Format(CultureInfo.InvariantCulture, "{0:N0} B", requestMetadata.Statistics.TotalBytesSent) }
            };

            return new Dictionary<string, object>
            {
                { SECTION_KEY_STATISTICS, statictics },
                { SECTION_KEY_QUERIES, items }
            };
        }
 public RequestMetadataProvider(EntryFactory entryFactory)
 {
     mEntryFactory = entryFactory;
 }