Prometheus exporter does not convert time units to seconds #18903
Open
Description
Component(s)
exporter/prometheus
What happened?
Description
Prometheus uses seconds as time unit by default. If I send an OTLP histogram with a different time unit, the value will not be converted to seconds (as it should be) but will be used as-is.
Steps to Reproduce
Send a histogram with unit: "milliseconds" to the OTel collector where the receiver is otlp/http/protobuf
(but I think any otlp receiver should produce the same result) and the exporter is prometheus. Then check the Prometheus /metrics
endpoint.
E.g.:
metrics {
name: "test.timer"
unit: "milliseconds"
histogram {
data_points {
start_time_unix_nano: 1677210838494000000
time_unix_nano: 1677210839021000000
count: 1
sum: 123.0
}
aggregation_temporality: AGGREGATION_TEMPORALITY_CUMULATIVE
}
}
Expected Result
test_timer_sum{...} 0.123
Actual Result
test_timer_sum{...} 123
Collector version
otel/opentelemetry-collector-contrib:cdf47846a7ff
Environment information
Environment
OS: MacOS 13.2.1
OpenTelemetry Collector configuration
receivers:
otlp:
protocols:
grpc:
http:
exporters:
prometheus:
endpoint: '0.0.0.0:9090'
metric_expiration: 1m
enable_open_metrics: true
resource_to_telemetry_conversion:
enabled: true
service:
pipelines:
metrics:
receivers: [otlp]
exporters: [prometheus]
Log output
No response
Additional context
No response