Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Internal ITrace: Adds back Line Numbers #2242

Merged
merged 11 commits into from
Feb 26, 2021
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.WriteObjectStart();

writer.WriteFieldName("member name");
bchong95 marked this conversation as resolved.
Show resolved Hide resolved
writer.WriteStringValue(trace.CallerInfo.MemberName);

writer.WriteFieldName("file path");
writer.WriteStringValue(trace.CallerInfo.FilePath);
writer.WriteFieldName("file name");
bchong95 marked this conversation as resolved.
Show resolved Hide resolved
writer.WriteStringValue(GetFileNameFromPath(trace.CallerInfo.FilePath));
bchong95 marked this conversation as resolved.
Show resolved Hide resolved

writer.WriteFieldName("line number");
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))
bchong95 marked this conversation as resolved.
Show resolved Hide resolved
{
fileName = filePath.Split('\\').Last();
bchong95 marked this conversation as resolved.
Show resolved Hide resolved
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 information": {
"member name": "MemberName",
"file name": "FilePath",
"line number": 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 information": {
"member name": "MemberName",
"file name": "FilePath",
"line number": 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 information": {
"member name": "MemberName",
"file name": "FilePath",
"line number": 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 information": {
"member name": "MemberName",
"file name": "FilePath",
"line number": 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 information": {
"member name": "MemberName",
"file name": "FilePath",
"line number": 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 information": {
"member name": "MemberName",
"file name": "FilePath",
"line number": 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 information": {
"member name": "MemberName",
"file name": "FilePath",
"line number": 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 information": {
"member name": "MemberName",
"file name": "FilePath",
"line number": 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 information": {
"member name": "MemberName",
"file name": "FilePath",
"line number": 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 information": {
"member name": "MemberName",
"file name": "FilePath",
"line number": 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 information": {
"member name": "MemberName",
"file name": "FilePath",
"line number": 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 information": {
"member name": "MemberName",
"file name": "FilePath",
"line number": 42
},
"start time": "12:00:00:000",
"duration in milliseconds": 0,
"data": {},
Expand Down
Loading