Add Prometheus Exporter for Exemplars#4178
Add Prometheus Exporter for Exemplars#4178czhang771 wants to merge 57 commits intoopen-telemetry:mainfrom
Conversation
|
@czhang771 would you mind turning this pull request as ready and update the description with: # Description
Fixes #2407
Follow-up of https://github.com/open-telemetry/opentelemetry-python/pull/4094
- Add exemplars to histogram in Prometheus exporter
- Fix typing of `span_id` and `trace_id` in exemplar related code (they were set as `str` when they actually are `int`)
> [!NOTE]
> The Prometheus exporter seems to be implemented differently in Python compared to Java and Dotnet and uses Metric Families and a custom collector rather than directing converting the OTEL types to Prometheus types.
> My current attempt focuses on the Histogram and adds the exemplars to each bucket for the histogram although I am not sure if this is the best way to go about it.
Relevant Resources:
- Prometheus Metric Protofiles: https://github.com/prometheus/client_model/blob/master/io/prometheus/client/metrics.proto
- Java Prometheus Exporter: https://github.com/open-telemetry/opentelemetry-java/tree/main/exporters/prometheus/src/main/java/io/opentelemetry/exporter/prometheus
- Metric Family Class Types: https://github.com/prometheus/client_python/blob/bed7432fad70a16acff5e7b03a65eb9ec350d3e6/prometheus_client/metrics_core.py#L178
- Custom Collectors in Prometheus: https://prometheus.github.io/client_python/collector/custom/
## Type of change
New feature (non-breaking change which adds functionality)
# How Has This Been Tested?
Add a test to check histogram exemplar are exported with the openmetrics format: `exporter/opentelemetry-exporter-prometheus/tests/test_prometheus_exporter.py::TestPrometheusMetricReader::test_histogram_with_exemplar_to_prometheus`
# Does This PR Require a Contrib Repo Change?
- [ ] Yes. - Link to PR:
- [x] No.
# Checklist:
- [x] Followed the style guidelines of this project
- [x] Changelogs have been updated
- [x] Unit tests have been added
- [x] Documentation has been updated |
xrmx
left a comment
There was a problem hiding this comment.
The sdk part LGTM but I think we are missing a test to assert that sometimes these fields are not serialized
We need two tests because AFAICS we don't have any tests serializing exemplars in oltp |
|
👋 Is this PR out of date or does it just need rebasing? |
@francesco-ferretti-ki it likely just needs rebasing |
|
I think we should close this PR. It needs rebasing and has conflicts. The author hasn't interacted in 18+ months. If someone else would like to add, they can open another PR. cc @open-telemetry/python-approvers |
|
This PR has been automatically marked as stale because it has not had any activity for 14 days. It will be closed if no further activity occurs within 14 days of this comment. |
|
This PR has been closed due to inactivity. Please reopen if you would like to continue working on it. |
Description
Fixes #2407
Follow-up of #4094
span_idandtrace_idin exemplar related code (they were set asstrwhen they actually areint)Note
The Prometheus exporter seems to be implemented differently in Python compared to Java and Dotnet and uses Metric Families and a custom collector rather than directing converting the OTEL types to Prometheus types.
My current attempt focuses on the Histogram and adds the exemplars to each bucket for the histogram although I am not sure if this is the best way to go about it.
Relevant Resources:
Type of change
New feature (non-breaking change which adds functionality)
How Has This Been Tested?
Add a test to check histogram exemplar are exported with the openmetrics format:
exporter/opentelemetry-exporter-prometheus/tests/test_prometheus_exporter.py::TestPrometheusMetricReader::test_histogram_with_exemplar_to_prometheusDoes This PR Require a Contrib Repo Change?
Checklist: