Skip to content

Commit cf73548

Browse files
authored
dotnet-counters JSON Exporter improvements (#666)
* make timestamp non culture-sensitive, change 'counter type' to 'counterType' * Remove more spaces from the JSON
1 parent 42f505e commit cf73548

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/Tools/dotnet-counters/Exporters/JSONExporter.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ public void Initialize()
3636
}
3737

3838
builder = new StringBuilder();
39-
builder.Append($"{{ \"Target Process\": \"{_processName}\", ");
40-
builder.Append($"\"Start Time\": \"{DateTime.Now.ToString()}\", ");
39+
builder.Append($"{{ \"TargetProcess\": \"{_processName}\", ");
40+
builder.Append($"\"StartTime\": \"{DateTime.Now.ToString()}\", ");
4141
builder.Append($"\"Events\": [");
4242
}
4343

@@ -57,10 +57,10 @@ public void CounterPayloadReceived(string providerName, ICounterPayload payload,
5757
File.AppendAllText(_output, builder.ToString());
5858
builder.Clear();
5959
}
60-
builder.Append($"{{ \"timestamp\": \"{DateTime.Now.ToString()}\", ");
60+
builder.Append($"{{ \"timestamp\": \"{DateTime.Now.ToString("u")}\", ");
6161
builder.Append($" \"provider\": \"{providerName}\", ");
6262
builder.Append($" \"name\": \"{payload.GetDisplay()}\", ");
63-
builder.Append($" \"counter type\": \"{payload.GetCounterType()}\", ");
63+
builder.Append($" \"counterType\": \"{payload.GetCounterType()}\", ");
6464
builder.Append($" \"value\": {payload.GetValue()} }},");
6565
}
6666

src/tests/dotnet-counters/JSONExporterTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ class JSONCounterPayload
149149
[JsonProperty("name")]
150150
public string name { get; set; }
151151

152-
[JsonProperty("counter type")]
152+
[JsonProperty("counterType")]
153153
public string counterType { get; set; }
154154

155155
[JsonProperty("value")]
@@ -158,10 +158,10 @@ class JSONCounterPayload
158158

159159
class JSONCounterTrace
160160
{
161-
[JsonProperty("Target Process")]
161+
[JsonProperty("TargetProcess")]
162162
public string targetProcess { get; set; }
163163

164-
[JsonProperty("Start Time")]
164+
[JsonProperty("StartTime")]
165165
public string startTime { get; set; }
166166

167167
[JsonProperty("Events")]

0 commit comments

Comments
 (0)