-
Notifications
You must be signed in to change notification settings - Fork 624
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
Add Prometheus Exporter for Exemplars #4178
Open
czhang771
wants to merge
54
commits into
open-telemetry:main
Choose a base branch
from
fcollonval:prometheus_exporter
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Fixes #2407
Follow-up of #4094
span_id
andtrace_id
in exemplar related code (they were set asstr
when 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_prometheus
Does This PR Require a Contrib Repo Change?
Checklist: