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

Metric exported to prometheus recorded for 5 minutes in 15 seconds interval

Open
#1,794 2 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 
Testing below code in local, once the execution is complete and data is exported to prometheus, I could see in grafana the metric is plotted every 15 seconds for a 5 min duration, even though the execution was triggered only once.

Things that we have tried:

  • Set the exportIntervalMillis and exportTimeoutMillis in the PeriodicExportingMetricReader to one sec 
  • We also added the shutdown_on_exit=True in the MeterProvider
    both of the above did not change the behavior

Steps to reproduce
exporter = PrometheusRemoteWriteMetricsExporter(
    endpoint="https://endpoint.com",
)
testing_labels = {"environment": "test"}
reader = PeriodicExportingMetricReader(exporter,30000)
provider = MeterProvider(metric_readers=[reader])
metrics.set_meter_provider(provider)
meter = metrics.get_meter(name)

 
def export_to_prometheus():
    metric_one = meter.create_counter(name="metric_one",description="metric one")
    metric_one.add(5,testing_labels)
    metric_two = meter.create_histogram(name="metric_two")
    metric_three = meter.create_up_down_counter(
        name="metric_three",
        description="metric three"
  )  
    metric_two.record(17)
    metric_three.add(56,testing_labels)

if name == "main":
export_to_prometheus(")

What is the expected behavior?

  • If we run the execution once, the metric exported should be recorded only once

What is the actual behavior?

  • If we run the execution once, the metric exported is being recorded for 5 mins in every 15 sec

Additional context
NA

Can you please help me understand why is the data recorded for 5 mins in every 15 sec intervals, while it should plot the data only once for a specific timestamp?

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 by reproducing the behavior with the provided Python example, focusing on PeriodicExportingMetricReader and PrometheusRemoteWriteMetricsExporter. Trace how the reader schedules exports after the one-time execution and compare the resulting timestamps with the expected single export; done means the cause is identified and covered by a regression test or documented behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
prometheus, python
Domain
observability
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.