open-telemetry / open-telemetry/opentelemetry-python-contrib
Remove aggreagator suffix when exporting to Prometheus Remote Write
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.1k
- Forks
- 1.1k
- Avg merge
- 4d 15h
- Merged PRs (30d)
- 16
Description
Describe your environment
I am using Python 3.8.10 with the requirements listed in the Prometheus Remote Write exporter
Steps to reproduce
Create a updownobserver metric and export it to Prometheus Remote Write like:
metrics.set_meter_provider(MeterProvider())
meter = metrics.get_meter(__name__, True)
exporter = PrometheusRemoteWriteMetricsExporter(
......
)
...
host_cpu_percent = meter.register_updownsumobserver(
name="cpu_used_percent",
callback=host_cpu_percent_callback,
description="CPU percent usage",
unit="1",
value_type=float,
)
What is the expected behavior?
To have the metric pushed to my system with the exact name. In this case, "cpu_used_percent".
What is the actual behavior?
Seems the exporter (or other component) is adding a "_last" suffix. So the metric is received like "cpu_used_percent_last".
As a gauge metric, I don't see the reason on adding the suffix. I understand for other aggregators the metric name is "changed" adding the "min", "max"... suffixes but for the "last",
Is there a way of removing that suffix? I want the metric name to be same I have defined. Thanks a lot
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 in metrics/exporter/opentelemetry-exporter-prometheus-remote-write/src/opentelemetry/exporter/prometheus_remote_write/init.py around line 244, where the issue reports the suffix is added. Trace the naming of the updownobserver output and verify the reproduction; done means the exported metric is named cpu_used_percent rather than cpu_used_percent_last.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- prometheus, python
- Domain
- observability
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100