Skip to content
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

the trait bound PrometheusRecorder: Recorder is not satisfied #557

Open
berwani opened this issue Feb 7, 2025 · 1 comment
Open

the trait bound PrometheusRecorder: Recorder is not satisfied #557

berwani opened this issue Feb 7, 2025 · 1 comment
Labels
C-core Component: core functionality such as traits, etc. C-exporter Component: exporters such as Prometheus, TCP, etc. S-needs-repro Status: awaiting a reproduction to continue investgation. T-ergonomics Type: ergonomics.

Comments

@berwani
Copy link

berwani commented Feb 7, 2025

Somehow, the set_global_recorder call inside the PrometheusBuilder.install() is not working for me, so I am trying to get the recorder via the PrometheusBuilder.build() and trying to set the global recorder myself. But I get the error stating that the PrometheusRecorder doesn't implement Recorder trait. Code I use and the error below:

    let (recorder, exporter): (PrometheusRecorder, ExporterFuture) = PrometheusBuilder::new()
        .build()
        .unwrap();
    metrics::set_global_recorder(recorder).unwrap();
error[E0277]: the trait bound `PrometheusRecorder: Recorder` is not satisfied
   --> enforcer/main.rs:131:34
    |
131 |     metrics::set_global_recorder(recorder).unwrap();
    |     ---------------------------- ^^^^^^^^ the trait `Recorder` is not implemented for `PrometheusRecorder`
    |     |
    |     required by a bound introduced by this call
  

May be the Recorder impl for PrometheusRecorder should be pub or part of a module that users can import?

I also have the following imports:

use metrics_exporter_prometheus::{ExporterFuture, PrometheusBuilder, PrometheusRecorder};
use metrics::Recorder;
@tobz
Copy link
Member

tobz commented Feb 19, 2025

Apologies, I had thought I had responded to this but clearly not... 😭

I'm not sure if you're still having an issue, but this looks like the classic metrics version mismatch problem. If you run cargo tree -i -p metrics, is there only one version or does it complain about there being multiple and that you need to specify which one?

If there are multiple, that's likely your issue: you need to use the same version of metrics as the version specified by metrics-exporter-prometheus.

@tobz tobz added C-exporter Component: exporters such as Prometheus, TCP, etc. C-core Component: core functionality such as traits, etc. S-needs-repro Status: awaiting a reproduction to continue investgation. T-ergonomics Type: ergonomics. labels Feb 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-core Component: core functionality such as traits, etc. C-exporter Component: exporters such as Prometheus, TCP, etc. S-needs-repro Status: awaiting a reproduction to continue investgation. T-ergonomics Type: ergonomics.
Projects
None yet
Development

No branches or pull requests

2 participants