1fanwang opened a new pull request, #66805:
URL: https://github.com/apache/airflow/pull/66805
### Problem
Follow-up to #64207, which set `ExponentialBucketHistogramAggregation` as the
default for every OTel `Histogram` instrument. That covers timer/timing.
Non-timer histograms (`*_count`, `*_duration` on direct `Stats.histogram()`,
custom `*_delay` metrics) still pick bucket boundaries at each call site,
so the same family of metrics can end up with different bucket shapes
depending on which module created the instrument.
### Fix
New `shared/observability/.../metrics/histogram_buckets.py` module that:
- Defines three named bucket aggregations — `LATENCY_BUCKETS` (exponential),
`COUNT_BUCKETS` (small linear), `DELAY_BUCKETS` (large-range).
- Exposes `DEFAULT_PATTERN_BUCKETS` mapping `*_duration` / `*_delay` /
`*_count` to those aggregations.
- Provides `build_views_for_patterns()` returning OTel `View` objects keyed
by instrument-name glob. Deployments can pass an override dict.
`otel_logger.get_otel_logger()` layers the pattern views on top of the
existing instrument-type baseline view — the per-instrument-type
exponential default still applies, the pattern views only refine it for
matching names.
### Tests
`test_histogram_buckets.py` covers the default pattern map, the per-pattern
aggregation resolution, custom-mapping override, and that
`build_views_for_patterns()` returns one `View` per entry with the right
`instrument_name`.
`test_otel_logger.py::test_get_otel_logger_uses_exponential_histogram_view`
updated to assert the layered shape (baseline view + pattern views).
### Design note
Flagging this as a design discussion. A reasonable counter-proposal is
"let each call site pass its bucket boundaries" rather than centralising
the map. Happy to take that direction if maintainers prefer.
Closes #66801
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]