Initialize the telemetry setup. # Errors - [`InitTracingError`], if initializing the [`tracing_subscriber::Registry`] fails.
(self)
| 225 | /// |
| 226 | /// - [`InitTracingError`], if initializing the [`tracing_subscriber::Registry`] fails. |
| 227 | pub fn init_global(self) -> Result<impl Drop, Report<InitTracingError>> { |
| 228 | let (registry, guard) = self.build()?; |
| 229 | |
| 230 | registry.try_init().change_context(InitTracingError)?; |
| 231 | |
| 232 | // We have to wait until logging is initialized before we can print the warning. |
| 233 | if std::env::var("RUST_LOG").is_ok() { |
| 234 | if std::env::var("HASH_GRAPH_LOG_LEVEL").is_ok() { |
| 235 | warn!( |
| 236 | "`HASH_GRAPH_LOG_LEVEL` and `RUST_LOG` are set, `HASH_GRAPH_LOG_LEVEL` has \ |
| 237 | been used to determine the logging level." |
| 238 | ); |
| 239 | } else { |
| 240 | warn!("`RUST_LOG` is set, please use `HASH_GRAPH_LOG_LEVEL` instead"); |
| 241 | } |
| 242 | } |
| 243 | |
| 244 | Ok(guard) |
| 245 | } |
| 246 | } |
| 247 | |
| 248 | struct TelemetryGuard<F> { |
no test coverage detected