Skip to content

Commit

Permalink
Internal ITrace: Adds back Line Numbers (#2242)
Browse files Browse the repository at this point in the history
* added line number

* shortened the caller info

* updated baselines
  • Loading branch information
bchong95 authored Feb 26, 2021
1 parent 661f72c commit 5420653
Show file tree
Hide file tree
Showing 15 changed files with 14,242 additions and 2,380 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,19 @@ public static void WriteTrace(
writer.WriteFieldName("component");
writer.WriteStringValue(trace.Component.ToString());

#if INTERNAL
writer.WriteFieldName("caller information");
writer.WriteFieldName("caller info");
writer.WriteObjectStart();

writer.WriteFieldName("member name");
writer.WriteFieldName("member");
writer.WriteStringValue(trace.CallerInfo.MemberName);

writer.WriteFieldName("file path");
writer.WriteStringValue(trace.CallerInfo.FilePath);
writer.WriteFieldName("file");
writer.WriteStringValue(GetFileNameFromPath(trace.CallerInfo.FilePath));

writer.WriteFieldName("line number");
writer.WriteFieldName("line");
writer.WriteNumber64Value(trace.CallerInfo.LineNumber);

writer.WriteObjectEnd();
#endif

writer.WriteFieldName("start time");
writer.WriteStringValue(trace.StartTime.ToString("hh:mm:ss:fff"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,14 +176,13 @@ private static void WriteTraceRecursive(
writer.Write("Component");
writer.Write(space);

#if INTERNAL
writer.Write(trace.CallerInfo.MemberName);

writer.Write('@');
writer.Write(trace.CallerInfo.FilePath.Split('\\').Last());
writer.Write(GetFileNameFromPath(trace.CallerInfo.FilePath));
writer.Write(':');
writer.Write(trace.CallerInfo.LineNumber);
writer.Write(space);
#endif

writer.Write(trace.StartTime.ToString("hh:mm:ss:fff", CultureInfo.InvariantCulture));
writer.Write(space);
Expand Down
15 changes: 15 additions & 0 deletions Microsoft.Azure.Cosmos/src/Tracing/TraceWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@

namespace Microsoft.Azure.Cosmos.Tracing
{
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using Microsoft.Azure.Cosmos.Json;

internal static partial class TraceWriter
{
private static readonly Dictionary<string, string> FilePathToName = new Dictionary<string, string>();

public static void WriteTrace(
TextWriter writer,
ITrace trace,
Expand Down Expand Up @@ -56,5 +60,16 @@ public enum AsciiType
ClassicRounded,
ExclamationMarks,
}

public static string GetFileNameFromPath(string filePath)
{
if (!FilePathToName.TryGetValue(filePath, out string fileName))
{
fileName = filePath.Split('\\').Last();
FilePathToName[filePath] = fileName;
}

return fileName;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,29 +34,34 @@
</Input>
<Output>
<Text><![CDATA[.
└── ExecuteAsync(00000000-0000-0000-0000-000000000000) Transport-Component 12:00:00:000 0.00 milliseconds
└── Execute Next Batch(00000000-0000-0000-0000-000000000000) Batch-Component 12:00:00:000 0.00 milliseconds
├── Create Batch Request(00000000-0000-0000-0000-000000000000) Batch-Component 12:00:00:000 0.00 milliseconds
└── Execute Batch Request(00000000-0000-0000-0000-000000000000) Batch-Component 12:00:00:000 0.00 milliseconds
├── Microsoft.Azure.Cosmos.Handlers.RequestInvokerHandler(00000000-0000-0000-0000-000000000000) RequestHandler-Component 12:00:00:000 0.00 milliseconds
│ └── Microsoft.Azure.Cosmos.Handlers.RequestInvokerHandler(00000000-0000-0000-0000-000000000000) RequestHandler-Component 12:00:00:000 0.00 milliseconds
│ └── Send Async(00000000-0000-0000-0000-000000000000) RequestHandler-Component 12:00:00:000 0.00 milliseconds
│ └── Send Async(00000000-0000-0000-0000-000000000000) RequestHandler-Component 12:00:00:000 0.00 milliseconds
│ └── Send Async(00000000-0000-0000-0000-000000000000) RequestHandler-Component 12:00:00:000 0.00 milliseconds
│ └── Send Async(00000000-0000-0000-0000-000000000000) RequestHandler-Component 12:00:00:000 0.00 milliseconds
│ └── Microsoft.Azure.Documents.ServerStoreModel Transport Request(00000000-0000-0000-0000-000000000000) Transport-Component 12:00:00:000 0.00 milliseconds
└── ExecuteAsync(00000000-0000-0000-0000-000000000000) Transport-Component MemberName@FilePath:42 12:00:00:000 0.00 milliseconds
└── Execute Next Batch(00000000-0000-0000-0000-000000000000) Batch-Component MemberName@FilePath:42 12:00:00:000 0.00 milliseconds
├── Create Batch Request(00000000-0000-0000-0000-000000000000) Batch-Component MemberName@FilePath:42 12:00:00:000 0.00 milliseconds
└── Execute Batch Request(00000000-0000-0000-0000-000000000000) Batch-Component MemberName@FilePath:42 12:00:00:000 0.00 milliseconds
├── Microsoft.Azure.Cosmos.Handlers.RequestInvokerHandler(00000000-0000-0000-0000-000000000000) RequestHandler-Component MemberName@FilePath:42 12:00:00:000 0.00 milliseconds
│ └── Microsoft.Azure.Cosmos.Handlers.RequestInvokerHandler(00000000-0000-0000-0000-000000000000) RequestHandler-Component MemberName@FilePath:42 12:00:00:000 0.00 milliseconds
│ └── Send Async(00000000-0000-0000-0000-000000000000) RequestHandler-Component MemberName@FilePath:42 12:00:00:000 0.00 milliseconds
│ └── Send Async(00000000-0000-0000-0000-000000000000) RequestHandler-Component MemberName@FilePath:42 12:00:00:000 0.00 milliseconds
│ └── Send Async(00000000-0000-0000-0000-000000000000) RequestHandler-Component MemberName@FilePath:42 12:00:00:000 0.00 milliseconds
│ └── Send Async(00000000-0000-0000-0000-000000000000) RequestHandler-Component MemberName@FilePath:42 12:00:00:000 0.00 milliseconds
│ └── Microsoft.Azure.Documents.ServerStoreModel Transport Request(00000000-0000-0000-0000-000000000000) Transport-Component MemberName@FilePath:42 12:00:00:000 0.00 milliseconds
│ (
│ [User Agent]
│ Redacted To Not Change The Baselines From Run To Run
│ [Client Side Request Stats]
│ Redacted To Not Change The Baselines From Run To Run
│ )
└── Create Trace(00000000-0000-0000-0000-000000000000) Batch-Component 12:00:00:000 0.00 milliseconds
└── Create Trace(00000000-0000-0000-0000-000000000000) Batch-Component MemberName@FilePath:42 12:00:00:000 0.00 milliseconds
]]></Text>
<Json><![CDATA[{
"name": "ExecuteAsync",
"id": "00000000-0000-0000-0000-000000000000",
"component": "Transport",
"caller info": {
"member": "MemberName",
"file": "FilePath",
"line": 42
},
"start time": "12:00:00:000",
"duration in milliseconds": 0,
"data": {},
Expand All @@ -65,6 +70,11 @@
"name": "Execute Next Batch",
"id": "00000000-0000-0000-0000-000000000000",
"component": "Batch",
"caller info": {
"member": "MemberName",
"file": "FilePath",
"line": 42
},
"start time": "12:00:00:000",
"duration in milliseconds": 0,
"data": {},
Expand All @@ -73,6 +83,11 @@
"name": "Create Batch Request",
"id": "00000000-0000-0000-0000-000000000000",
"component": "Batch",
"caller info": {
"member": "MemberName",
"file": "FilePath",
"line": 42
},
"start time": "12:00:00:000",
"duration in milliseconds": 0,
"data": {},
Expand All @@ -82,6 +97,11 @@
"name": "Execute Batch Request",
"id": "00000000-0000-0000-0000-000000000000",
"component": "Batch",
"caller info": {
"member": "MemberName",
"file": "FilePath",
"line": 42
},
"start time": "12:00:00:000",
"duration in milliseconds": 0,
"data": {},
Expand All @@ -90,6 +110,11 @@
"name": "Microsoft.Azure.Cosmos.Handlers.RequestInvokerHandler",
"id": "00000000-0000-0000-0000-000000000000",
"component": "RequestHandler",
"caller info": {
"member": "MemberName",
"file": "FilePath",
"line": 42
},
"start time": "12:00:00:000",
"duration in milliseconds": 0,
"data": {},
Expand All @@ -98,6 +123,11 @@
"name": "Microsoft.Azure.Cosmos.Handlers.RequestInvokerHandler",
"id": "00000000-0000-0000-0000-000000000000",
"component": "RequestHandler",
"caller info": {
"member": "MemberName",
"file": "FilePath",
"line": 42
},
"start time": "12:00:00:000",
"duration in milliseconds": 0,
"data": {},
Expand All @@ -106,6 +136,11 @@
"name": "Send Async",
"id": "00000000-0000-0000-0000-000000000000",
"component": "RequestHandler",
"caller info": {
"member": "MemberName",
"file": "FilePath",
"line": 42
},
"start time": "12:00:00:000",
"duration in milliseconds": 0,
"data": {},
Expand All @@ -114,6 +149,11 @@
"name": "Send Async",
"id": "00000000-0000-0000-0000-000000000000",
"component": "RequestHandler",
"caller info": {
"member": "MemberName",
"file": "FilePath",
"line": 42
},
"start time": "12:00:00:000",
"duration in milliseconds": 0,
"data": {},
Expand All @@ -122,6 +162,11 @@
"name": "Send Async",
"id": "00000000-0000-0000-0000-000000000000",
"component": "RequestHandler",
"caller info": {
"member": "MemberName",
"file": "FilePath",
"line": 42
},
"start time": "12:00:00:000",
"duration in milliseconds": 0,
"data": {},
Expand All @@ -130,6 +175,11 @@
"name": "Send Async",
"id": "00000000-0000-0000-0000-000000000000",
"component": "RequestHandler",
"caller info": {
"member": "MemberName",
"file": "FilePath",
"line": 42
},
"start time": "12:00:00:000",
"duration in milliseconds": 0,
"data": {},
Expand All @@ -138,6 +188,11 @@
"name": "Microsoft.Azure.Documents.ServerStoreModel Transport Request",
"id": "00000000-0000-0000-0000-000000000000",
"component": "Transport",
"caller info": {
"member": "MemberName",
"file": "FilePath",
"line": 42
},
"start time": "12:00:00:000",
"duration in milliseconds": 0,
"data": {
Expand All @@ -162,6 +217,11 @@
"name": "Create Trace",
"id": "00000000-0000-0000-0000-000000000000",
"component": "Batch",
"caller info": {
"member": "MemberName",
"file": "FilePath",
"line": 42
},
"start time": "12:00:00:000",
"duration in milliseconds": 0,
"data": {},
Expand Down
Loading

0 comments on commit 5420653

Please sign in to comment.