Skip to content

dotnet-counters: default IncrementingEventCounter values crashes the ConsoleMonitor #427

@dorki

Description

@dorki

When creating IncrementingEventCounter (https://github.com/dotnet/corefx/blob/61a6264018989e06d314b68d57bd91b4b72e4360/src/Common/src/CoreLib/System/Diagnostics/Tracing/IncrementingEventCounter.cs) without setting the DisplayRateTimeScale property, the property value will remain the default TimeSpan.Zero.

While dumping the value to the EventSource using the DiagnosticCounter.WritePayload method, this will be converted into string.Emtpy:
payload.DisplayRateTimeScale = (DisplayRateTimeScale == TimeSpan.Zero) ? "" : DisplayRateTimeScale.ToString("c")
(https://github.com/dotnet/corefx/blob/61a6264018989e06d314b68d57bd91b4b72e4360/src/Common/src/CoreLib/System/Diagnostics/Tracing/IncrementingEventCounter.cs#L66)

But in the dotnet-counters the IncrementingCounterPayload constructor doesn't handle this case of empty string:

m_DisplayRateTimeScale = TimeSpan.Parse(payloadFields["DisplayRateTimeScale"].ToString()).ToString("%s' sec'");

which will cause a System.FormatException to be thrown
image

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions