-
Notifications
You must be signed in to change notification settings - Fork 661
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
Histogram.record() producing inaccurate start_time_unix_nano
value
#4123
Labels
bug
Something isn't working
Comments
tested with this small snippet against the main branch to reproduce the behavior; pip install opentelemetry-api opentelemetry-sdk import time
from opentelemetry.metrics import (
get_meter_provider,
set_meter_provider,
)
from opentelemetry.sdk.metrics import MeterProvider, Histogram
from opentelemetry.sdk.metrics.export import (
ConsoleMetricExporter,
PeriodicExportingMetricReader,
AggregationTemporality
)
temporality = {
Histogram: AggregationTemporality.DELTA,
}
reader = PeriodicExportingMetricReader(exporter=ConsoleMetricExporter(preferred_temporality=temporality), export_interval_millis=1_000)
provider = MeterProvider(metric_readers=[reader,])
set_meter_provider(provider)
meter = get_meter_provider().get_meter(__name__)
hist = meter.create_histogram("my_histogram", description="duration", unit="s")
if __name__ == "__main__":
i = 0
while True:
time.sleep(1)
hist.record(1, {"foo": f"bar{i}"}) # constant start_time_unix_nano
# hist.record(1, {"foo": f"bar"}) # incremental start_time_unix_nano
i += 1 example return
|
Thanks for providing a more concise example. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe your environment
OS: CentOS 7
Python version: Python3.11
SDK version: 1.26.0
API version: 1.26.0
What happened?
When using Python OpenTelemetry (OTel) to record histogram metrics with unique integer attributes, all recorded histograms are showing a static
start_time_unix_nano
value in the OpenTelemetry logs. Despite different timestamps being recorded for each metric point, thestart_time_unix_nano
remains constant across all data points, which is not expected behavior. This issue does not occur when static attribute values are used.Steps to Reproduce
There is an easy to follow MRE here:
https://github.com/williamdoddsb365/otel_histogram_issue
Expected Result
The
start_time_unix_nano
value should increment for each recorded histogram data point, regardless of whether the attributes are static or dynamic.Actual Result
The
start_time_unix_nano
remains constant across all data points when dynamic attributes are sent.Additional context
No response
Would you like to implement a fix?
None
The text was updated successfully, but these errors were encountered: