open-telemetry / open-telemetry/opentelemetry-ruby
Refactor: determine metrics data kind from data_points class instead of instrument_kind
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 606
- Forks
- 301
- Avg merge
- 3d 19h
- Merged PRs (30d)
- 42
Description
A key challenge in implementing exponential histograms is that the data_points class used to represent them differs from the instrument_kind. Since there is no dedicated API like create_exponential_histogram, exponential histograms are instead created using the generic create_histogram function, followed by applying a view with exponential_histogram aggregation. As a result, both explicit_histogram and exponential_histogram instruments share the same instrument_kind value: histogram.
This creates ambiguity in the current as_otlp_metrics implementation, which must distinguish between explicit and exponential histograms to correctly map to the appropriate protobuf types: HistogramDataPoint or ExponentialHistogramDataPoint.
This issue could become more prominent when users heavily rely on views to modify aggregations.
Additionally, the way otel-python uses the data_points class to encode trace data (as seen in the _encode_metric function) might be better addressed as part of a broader refactoring effort.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the current as_otlp_metrics implementation and compare its handling with the _encode_metric function in the referenced otel-python metrics encoder. Trace how data_points and instrument_kind identify explicit versus exponential histograms, then verify that each maps to the correct protobuf data-point type. Done means the ambiguity is removed and the relevant metrics behavior is covered by existing or updated tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- observability
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100