Skip to content

fix: record db.client.operation.duration in seconds#72

Open
slavovojacek wants to merge 1 commit intoexaring:mainfrom
slavovojacek:fix/duration-unit-seconds
Open

fix: record db.client.operation.duration in seconds#72
slavovojacek wants to merge 1 commit intoexaring:mainfrom
slavovojacek:fix/duration-unit-seconds

Conversation

@slavovojacek
Copy link

Summary

Fixes #70.

The db.client.operation.duration instrument declares unit "s" per the OpenTelemetry semantic conventions (semconv.DBClientOperationDurationUnit = "s"), but recordOperationDuration was recording integer milliseconds via time.Duration.Milliseconds(). This causes the Prometheus exporter to emit a db_client_operation_duration_seconds metric whose values and bucket boundaries are actually in milliseconds — making the metric name actively misleading and any histogram quantile queries return incorrect results.

Change

  • operationDuration: metric.Int64Histogrammetric.Float64Histogram
  • createMetrics: meter.Int64Histogrammeter.Float64Histogram
  • recordOperationDuration: time.Since(startTime).Milliseconds()time.Since(startTime).Seconds()

Notes

This is a breaking change for existing Prometheus users: bucket le labels and all recorded values will shift from millisecond-range integers (e.g. le="5" for 5ms) to second-range floats (e.g. le="0.005"). Users with custom histogram views or dashboards querying bucket boundaries by value will need to update them.

The instrument declares unit "s" per the OTel semantic conventions
(semconv.DBClientOperationDurationUnit), but was recording integer
milliseconds via time.Duration.Milliseconds(). This caused the
Prometheus exporter to emit a misleadingly named
db_client_operation_duration_seconds metric whose bucket boundaries
and values were in milliseconds.

Change operationDuration from Int64Histogram to Float64Histogram and
record time.Duration.Seconds() to match the declared unit.

Fixes exaring#70
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

db_client_operation_duration_seconds_bucket -misleading metric name

1 participant