Skip to content

Improve Doc to Make the Tracing Context Example #575 #583

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
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

artsiomkaltovich
Copy link

Improve Doc to Make the Tracing Context Example ready to use out of the Box.

Please refer to issue #575

@artsiomkaltovich artsiomkaltovich force-pushed the improve_tracing_context_doc_issue_575 branch from 99380f8 to 71f9bf2 Compare May 23, 2025 18:18
Copy link
Member

@tobz tobz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, these changes don't actually compile when trying to run the doctests.

You'll need to add some of these dependencies to [dev-dependencies] and potentially update the enabled feature flags for some of the existing dev dependencies.

You can run cargo test -p metrics-tracing-context --doc locally to execute the tests while fixing the dependencies to ensure they're passing before requesting another review.

Comment on lines 13 to 14
//! use metrics_tracing_context::MetricsLayer;
//! use metrics_tracing_context::TracingContextLayer;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//! use metrics_tracing_context::MetricsLayer;
//! use metrics_tracing_context::TracingContextLayer;
//! use metrics_tracing_context::{MetricsLayer, TracingContextLayer};

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @tobz.

I will fix the ci, if other changes are ok.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added dependencies, but I still got the following error:

---- metrics-tracing-context/src/lib.rs - (line 11) stdout ----
error[E0277]: the trait bound `PrometheusRecorder: Recorder` is not satisfied
   --> metrics-tracing-context/src/lib.rs:32:30
    |
24  | metrics::set_global_recorder(recorder).unwrap();
    | ---------------------------- ^^^^^^^^ the trait `Recorder` is not implemented for `PrometheusRecorder`
  

I've failed to understand why as Recorder as implemented for PrometheusRecorder and all dependencies seems up to date.

tracing-subscriber = { workspace = true, features = ["registry"] }
tracing-subscriber = { workspace = true, features = ["registry", "fmt"] }
tokio = { workspace = true }
metrics-exporter-prometheus = { version = "0.17.0", features = ["http-listener", "hyper", "hyper-util"] }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This probably needs to be a path dependency (see metrics-util above).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is. I can't get why :)

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants