Skip to content
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 Explicit Bucket Boundaries issue #4428

Closed
atibdialpad opened this issue Feb 13, 2025 · 3 comments · Fixed by #4434
Closed

Histogram Explicit Bucket Boundaries issue #4428

atibdialpad opened this issue Feb 13, 2025 · 3 comments · Fixed by #4434
Assignees

Comments

@atibdialpad
Copy link

I am trying to use this #4361 feature and not being able to get the desired output.

a = meter.create_histogram('a_latency', explicit_bucket_boundaries_advisory=[0.0, 1.0, 2.0])
a.record(99.9)

I am having these metrics exported to an otel-collector (running the latest "Version": "0.119.0") and using the debug exporter to print the histogram where I see the default bucket boundaries are being used.

2025-02-13T17:35:14.529+0530	info	ResourceMetrics #0
Resource SchemaURL: 
Resource attributes:
     -> service.name: Str(log_to_metric)
ScopeMetrics #0
ScopeMetrics SchemaURL: 
InstrumentationScope otel_log_processor 
Metric #0
Descriptor:
     -> Name: a_latency
     -> Description: 
     -> Unit: 
     -> DataType: Histogram
     -> AggregationTemporality: Cumulative
HistogramDataPoints #0
StartTimestamp: 2025-02-13 12:04:45.590067 +0000 UTC
Timestamp: 2025-02-13 12:05:14.466452 +0000 UTC
Count: 1
Sum: 99.900000
Min: 99.900000
Max: 99.900000
ExplicitBounds #0: 0.000000
ExplicitBounds #1: 5.000000
ExplicitBounds #2: 10.000000
ExplicitBounds #3: 25.000000
ExplicitBounds #4: 50.000000
ExplicitBounds #5: 75.000000
ExplicitBounds #6: 100.000000
ExplicitBounds #7: 250.000000
ExplicitBounds #8: 500.000000
ExplicitBounds #9: 750.000000
ExplicitBounds #10: 1000.000000
ExplicitBounds #11: 2500.000000
ExplicitBounds #12: 5000.000000
ExplicitBounds #13: 7500.000000
ExplicitBounds #14: 10000.000000
Buckets #0, Count: 0
Buckets #1, Count: 0
Buckets #2, Count: 0
Buckets #3, Count: 0
Buckets #4, Count: 0
Buckets #5, Count: 0
Buckets #6, Count: 1
Buckets #7, Count: 0
Buckets #8, Count: 0
Buckets #9, Count: 0
Buckets #10, Count: 0
Buckets #11, Count: 0
Buckets #12, Count: 0
Buckets #13, Count: 0
Buckets #14, Count: 0
Buckets #15, Count: 0
	{"kind": "exporter", "data_type": "metrics", "name": "debug"}

client version

opentelemetry-api                        1.30.0
opentelemetry-exporter-otlp              1.30.0
opentelemetry-exporter-otlp-proto-common 1.30.0
opentelemetry-exporter-otlp-proto-grpc   1.30.0
opentelemetry-exporter-otlp-proto-http   1.30.0
opentelemetry-proto                      1.30.0
opentelemetry-sdk                        1.30.0
@atibdialpad
Copy link
Author

++ @xrmx

@xrmx
Copy link
Contributor

xrmx commented Feb 14, 2025

With repro.py as:

from opentelemetry.metrics import get_meter


meter = get_meter("foo")
a = meter.create_histogram('a_latency', explicit_bucket_boundaries_advisory=[0.0, 1.0, 2.0])
a.record(99.9)

calling it with:

opentelemetry-instrument --logs_exporter=none --traces_exporter=none --metrics_exporter=console python3 repro.py 

I get this:

            "scope_metrics": [
                {
                    "scope": {
                        "name": "foo",
                        "version": "",
                        "schema_url": "",
                        "attributes": null
                    },
                    "metrics": [
                        {
                            "name": "a_latency",
                            "description": "",
                            "unit": "",
                            "data": {
                                "data_points": [
                                    {
                                        "attributes": {},
                                        "start_time_unix_nano": 1739550887411977730,
                                        "time_unix_nano": 1739550887412526364,
                                        "count": 1,
                                        "sum": 99.9,
                                        "bucket_counts": [
                                            0,
                                            0,
                                            0,
                                            1
                                        ],
                                        "explicit_bounds": [
                                            0.0,
                                            1.0,
                                            2.0
                                        ],
                                        "min": 99.9,
                                        "max": 99.9,
                                        "exemplars": []
                                    }
                                ],
                                "aggregation_temporality": 2
                            }
                        }
                    ],
                    "schema_url": ""
                },

I'm testing with OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE set to DELTA

@emdneto
Copy link
Member

emdneto commented Feb 14, 2025

It works well when using ConsoleExporter + InMemoryReader because they use DefaultAggregation() as preferred_aggregation method

But OTLPExporter is using ExplicitBucketHistogramAggregation directly.

Checking the code we are not looking for _advisory there. Probably we need to look for _advisory parameters there as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants