open-telemetry / open-telemetry/opentelemetry-python-contrib

Remove aggreagator suffix when exporting to Prometheus Remote Write

Open
#701 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
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".

Seems this is added https://github.com/open-telemetry/opentelemetry-python-contrib/blob/metrics/exporter/opentelemetry-exporter-prometheus-remote-write/src/opentelemetry/exporter/prometheus_remote_write/__init__.py#L244

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.