-
Notifications
You must be signed in to change notification settings - Fork 5.4k
feat: introduce fuel-telemetry macros #7295
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
base: master
Are you sure you want to change the base?
Conversation
@@ -0,0 +1,59 @@ | |||
//! Telemetry utilities for logging to InfluxDB | |||
|
|||
pub use fuel_telemetry::*; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unconditionally re-exporting fuel_telemetry::*
forces all consumers to compile the dependency even when the telemetry feature is off;
pub use fuel_telemetry::*; | |
#[cfg(feature = "telemetry")] | |
pub use fuel_telemetry::*; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh 🤦 nice catch thanks!
forc-tracing/src/telemetry.rs
Outdated
/// Logs an error message to telemetry | ||
#[macro_export] | ||
macro_rules! error_telemetry { | ||
($($arg:tt)*) => {{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe *
implies 0+
args; I believe we don't want scenario's where there are no args?
($($arg:tt)*) => {{ | |
($($arg:tt)+) => {{ |
If so; may also apply to the macros below aswell
Description
Add telemetry opt-out support to forc-tracing
This adds
fuel-telemetry
toforc-tracing
(not quite - dependency is currently pointing to Github) with opt-out functionality for upstream tools like fuelup.Usage
First, add it to the
forc-tracing
dependency:Then use the
telemetry::*
glob, followed by the usualtracing
macros, but with a_telemetry
postfix:This will output the following (note
DEBUG
andTRACE
messages are filtered out because ofRUST_LOG=info
):> RUST_LOG=info ./target/debug/example Stop Slow down Go
We can then peek into telemetry files like the following:
New: Telemetry Opt-Out Support
This PR also adds opt-out functionality for telemetry, allowing upstream tools like fuelup to disable telemetry collection:
Changes:
--disable-telemetry
CLI flag to main forc binaryFORC_DISABLE_TELEMETRY
environment variable supportinit_telemetry()
function for proper initializationOpt-out Usage:
Code example with opt-out:
The implementation ensures telemetry is opt-out by default but can be easily disabled through either CLI flags or environment variables, making it suitable for upstream tool integration.