You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Histogram buckets aren't well configured in OpenTelemetry. The minimum bucket is 5. That's fine if you're measuring in milliseconds, not so good when you're measuring in seconds. There is special hardcoding for known .NET histograms, but 3rd party histograms aren't helped.
This isn't an Aspire specific issue. Why isn't this being handled in OpenTelemetry? The instrument declares that it's units are seconds. This should just work without every instrument consumer needing to make a custom view.
OTEL recommends seconds for durations. They changed from ms to s this year to align for Prometheus, who uses seconds everywhere.
However, OTEL didn't change their histogram bucket bounds, which are still optimized for milliseconds. They won't change them because it's a breaking change. It's very dumb and means that the smallest bucket is 5 seconds.
A fix is hard coded for known .NET built-in counters in OTEL. Automatically changing all histograms with a unit of seconds might not be what someone wants.
The temporary solution for 3rd parties in .NET 8 is to add custom views.
Activity
eerhardt commentedon Nov 2, 2023
This isn't an Aspire specific issue. Why isn't this being handled in OpenTelemetry? The instrument declares that it's units are seconds. This should just work without every instrument consumer needing to make a custom view.
eerhardt commentedon Nov 2, 2023
Here's the instrument creation: https://github.com/npgsql/npgsql/blob/5c106023a1a192a2fab0726fc7df9ca51e39cb22/src/Npgsql/MetricsReporter.cs#L62-L66
JamesNK commentedon Nov 2, 2023
Three decisions have put us in this situation:
A fix is hard coded for known .NET built-in counters in OTEL. Automatically changing all histograms with a unit of seconds might not be what someone wants.
The temporary solution for 3rd parties in .NET 8 is to add custom views.
JamesNK commentedon Nov 2, 2023
Duration metric reporting 5 seconds:
The graph is unlikely to report any other value because everything will fall into the 5-second bucket.
eerhardt commentedon Nov 2, 2023
https://github.com/open-telemetry/semantic-conventions/blob/1eb70c4d74aa904a8c81c5ed10302af8bb3c1b70/docs/database/database-metrics.md?plain=1#L138-L146
says
db.client.connections.create_timemsSo maybe Npgsql should be updated to
ms?JamesNK commentedon Nov 2, 2023
I think DB conventions just hasn't been updated yet for seconds. They're focusing on stabilizing HTTP.
Add view to Npgsql's histograms because they are in seconds and not ms.
Fix Npgsql Metrics (#658)
Fix Npgsql Metrics (#658)
eerhardt commentedon Nov 2, 2023
Reopening to backport to preview1.
roji commentedon Nov 2, 2023
FWIW I implemented seconds for command duration because of the explicit OTel conventions around this, as James Newton-King (@JamesNK) wrote above:
Fix Npgsql Metrics (#658) (#660)
eerhardt commentedon Nov 2, 2023
Fixed with #660.