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

Method build

libs/@local/telemetry/src/lib.rs:119–188  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

117 }
118
119 fn build(self) -> Result<(impl Into<Dispatch>, impl Drop), Report<InitTracingError>> {
120 let error_layer = self.error_layer.then(ErrorLayer::default);
121 let console_layer = self
122 .console_logging
123 .as_ref()
124 .map(self::logging::console_layer);
125
126 let (file_layer, file_guard) = self.file_logging.map(self::logging::file_layer).unzip();
127
128 let sentry_layer = self.sentry.as_ref().map(self::traces::sentry::layer);
129
130 let (otlp_logs_layer, otlp_logs_provider) = self
131 .otlp
132 .as_ref()
133 .map(|(otlp, service_name)| {
134 self::logging::otlp::provider(otlp, service_name)
135 .change_context(InitTracingError)
136 .map(|provider| (self::logging::otlp::layer(&provider), provider))
137 })
138 .transpose()?
139 .unzip();
140
141 let (otlp_traces_layer, otlp_traces_provider) = self
142 .otlp
143 .as_ref()
144 .map(|(otlp, service_name)| {
145 self::traces::otlp::provider(otlp, service_name)
146 .change_context(InitTracingError)
147 .map(|provider| (self::traces::otlp::layer(&provider), provider))
148 })
149 .transpose()?
150 .unzip();
151
152 let otlp_metrics_provider = self
153 .otlp
154 .as_ref()
155 .map(|(otlp, service_name)| {
156 self::metrics::otlp::provider(otlp, service_name).change_context(InitTracingError)
157 })
158 .transpose()?;
159
160 let (flame_layer, flamegraph_guard) = self
161 .flamegraph_path
162 .map(|path| {
163 fs::create_dir_all(&path).change_context(InitTracingError)?;
164 FlameLayer::with_file(path.join("tracing.folded")).change_context(InitTracingError)
165 })
166 .transpose()?
167 .unzip();
168
169 let guard = TelemetryGuard {
170 otlp_traces_provider,
171 otlp_logs_provider,
172 otlp_metrics_provider,
173 _file_guard: file_guard,
174 _flamegraph: flamegraph_guard,
175 };
176

Callers 7

initMethod · 0.45
init_globalMethod · 0.45
providerFunction · 0.45
providerFunction · 0.45
appenderMethod · 0.45
providerFunction · 0.45
newMethod · 0.45

Calls 9

OkInterface · 0.85
thenMethod · 0.80
providerFunction · 0.50
layerFunction · 0.50
mapMethod · 0.45
as_refMethod · 0.45
change_contextMethod · 0.45
joinMethod · 0.45
withMethod · 0.45

Tested by

no test coverage detected