Skip to content

[Bug]: PeriodicReader with with_interval not respected #2888

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

Open
joseph-henry opened this issue Apr 1, 2025 · 4 comments
Open

[Bug]: PeriodicReader with with_interval not respected #2888

joseph-henry opened this issue Apr 1, 2025 · 4 comments
Labels
A-metrics Area: issues related to metrics question Further information is requested

Comments

@joseph-henry
Copy link

joseph-henry commented Apr 1, 2025

Hello.

I'm trying to change the interval of metrics collection but cannot seem to get the desired effect. I'm doing:

fn init_metrics() -> SdkMeterProvider {
    let exporter = MetricExporter::builder()
        .with_http()
        .with_protocol(Protocol::HttpBinary) //can be changed to `Protocol::HttpJson` to export in JSON format
        .build()
        .expect("Failed to create metric exporter");

    let reader = PeriodicReader::builder(exporter)
        .with_interval(Duration::from_secs(5))
        .build();

    SdkMeterProvider::builder()
        .with_reader(reader)
        .with_resource(get_resource())
        .build()
}

But it's still exporting at 60 seconds.

I can see the following log entry so it appears to be correctly set:

OpenTelemetry.Metrics.PeriodicReader opentelemetry_sdk:  name="PeriodReaderThreadStarted" interval_in_millisecs=5000

Also, I'd like to be able to configure not only the collection frequency but also the export frequency separately. For instance I may want to collect data once a second but only export every 60 seconds, is that possible?

Thanks.

OpenTelemetry API Version (i.e version of opentelemetry crate)

0.28.0

OpenTelemetry SDK Version (i.e version of opentelemetry_sdk crate)

0.28.0

What Exporter(s) are you seeing the problem on?

MetricExporter

Relevant log output

OpenTelemetry.Metrics.PeriodicReader opentelemetry_sdk:  name="PeriodReaderThreadStarted" interval_in_millisecs=5000
@joseph-henry joseph-henry added bug Something isn't working triage:todo Needs to be traiged. labels Apr 1, 2025
@cijothomas
Copy link
Member

but cannot seem to get the desired effect

Can you share details on how you are testing and validating? The shared logs just has a the initial log only - if you can share subsequent logs, that should tell how frequently export is triggered.

@cijothomas
Copy link
Member

Also, I'd like to be able to configure not only the collection frequency but also the export frequency separately. For instance I may want to collect data once a second but only export every 60 seconds, is that possible?

Not possible today. This is an open issue in the specification also.

@cijothomas cijothomas added question Further information is requested and removed bug Something isn't working triage:todo Needs to be traiged. labels Apr 1, 2025
@otiv-emiel-vanseveren
Copy link

otiv-emiel-vanseveren commented Apr 7, 2025

Also having the same issue. Setting a different interval (e.g. 15s), still just pulls every 60s

@cijothomas
Copy link
Member

@otiv-emiel-vanseveren Can you share more details ? I was not able to reproduce this....

@cijothomas cijothomas added the A-metrics Area: issues related to metrics label Apr 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-metrics Area: issues related to metrics question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants