-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Counter generated from System.Diagnostic.Metrics resets to zero. #103670
Comments
This is not how the metrics work in .NET. It is the listener/aggregator job to accumulate the published counter values. I encourage you to read the doc https://learn.microsoft.com/en-us/dotnet/core/diagnostics/metrics-collection#create-a-custom-collection-tool-using-the-net-meterlistener-api for more info and explanation. |
@tarekgh do you mind if I ask a related question to this? I've never found proper documentation about it. In a setup with an OTEL collector and an observability tool (e.g. Datadog), who exactly is performing this aggregation? Is it the application itself before emitting the values to the collector? Is it the collector? Or does the collector also sends raw values and they are aggregated by Datadog? This has always confused me because it is not clear to me when a counter is supposed to reset, and how one even signals an intended reset (if that is even possible). Does a reset happen when I restart my application? Is there some sort of signal that is sent from the application side to indicate a counter is "a new instance" or "a new stream of deltas separate from previous ones", or is that defined by the collector or the observability tool? Since counters are delta based, one would need to accumulate their values forever to have an accurate view: basically going back to the very first measurement. For example, imagine I wanted to track "hats sold throughout history", and my application has been running for 10 years. Do telemetry counters (or any other instruments really) work at that scale, or are they not meant to capture "persistent" telemetry like this? I probably just missed it, but I couldn't find the answer for this "delta instrument aggregation lifetime" question in either the Microsoft docs, OTEL docs or even Datadog docs. |
You are welcome to ask any question anytime. There is a good doc https://github.com/open-telemetry/opentelemetry-dotnet/tree/4af3df9b81dbf78f3abbbd5d764573db8d54d373/docs/metrics#meterprovider-management describing how metrics work in OpenTelelmetry. Please have a look and let's know if you still have any questions not answered. |
Description
The counters in .NET 8 (or .NET 4.8) reset to zero whilst running, losing the current measurement.
Reproduction Steps
Run the following code sample in Rider (or on the command line) ..
Expected behavior
The counters to increment until the application is stopped.
Actual behavior
Regression?
No response
Known Workarounds
No response
Configuration
.NET 8 (8.0.5) and .NET 4.8.1
Windows 11 (latest)
x64
Other information
No response
The text was updated successfully, but these errors were encountered: