MCPcopy Create free account
hub / github.com/hashintel/hash / init

Method init

libs/@local/telemetry/src/lib.rs:195–220  ·  view source on GitHub ↗

Initialize the telemetry setup in the current scope. # Errors - [`InitTracingError`], if initializing the [`tracing_subscriber::Registry`] fails.

(self)

Source from the content-addressed store, hash-verified

193 ///
194 /// - [`InitTracingError`], if initializing the [`tracing_subscriber::Registry`] fails.
195 pub fn init(self) -> Result<impl Drop, Report<InitTracingError>> {
196 #[expect(unused)]
197 struct DropGuard<T>(T, DefaultGuard);
198
199 #[expect(clippy::empty_drop)]
200 impl<T> Drop for DropGuard<T> {
201 fn drop(&mut self) {}
202 }
203
204 let (registry, telemetry_guard) = self.build()?;
205 let default_guard = tracing::dispatcher::set_default(&registry.into());
206
207 // We have to wait until logging is initialized before we can print the warning.
208 if std::env::var("RUST_LOG").is_ok() {
209 if std::env::var("HASH_GRAPH_LOG_LEVEL").is_ok() {
210 warn!(
211 "`HASH_GRAPH_LOG_LEVEL` and `RUST_LOG` are set, `HASH_GRAPH_LOG_LEVEL` has \
212 been used to determine the logging level."
213 );
214 } else {
215 warn!("`RUST_LOG` is set, please use `HASH_GRAPH_LOG_LEVEL` instead");
216 }
217 }
218
219 Ok(DropGuard(telemetry_guard, default_guard))
220 }
221
222 /// Initialize the telemetry setup.
223 ///

Callers 12

initializeSentryFunction · 0.45
instrument.tsFile · 0.45
main.tsFile · 0.45
instrument.mjsFile · 0.45
main.tsFile · 0.45
indexPdfFileFunction · 0.45
setup_subscriberFunction · 0.45
init_tracingFunction · 0.45
EChartFunction · 0.45

Calls 4

OkInterface · 0.85
is_okMethod · 0.80
DropGuardClass · 0.70
buildMethod · 0.45

Tested by

no test coverage detected