MCPcopy Create free account
hub / github.com/boringstack-xyz/boringstack / initializeOpenTelemetry

Function initializeOpenTelemetry

apps/api/src/config/otel/otel.ts:37–65  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

35let sdk: NodeSDK | null = null;
36
37export const initializeOpenTelemetry = (): void => {
38 if (env.OTEL_EXPORTER_OTLP_ENDPOINT === "") {
39 return;
40 }
41
42 sdk = new NodeSDK({
43 resource: resourceFromAttributes({
44 [ATTR_SERVICE_NAME]: env.OTEL_SERVICE_NAME,
45 [ATTR_SERVICE_VERSION]: env.APP_NAME,
46 "deployment.environment": env.NODE_ENV,
47 }),
48 traceExporter: new OTLPTraceExporter({
49 url: `${env.OTEL_EXPORTER_OTLP_ENDPOINT}/v1/traces`,
50 }),
51 instrumentations: [
52 getNodeAutoInstrumentations({
53 /*
54 * Disable file-system instrumentation: it generates an enormous
55 * volume of spans for normal Node operations and drowns out the
56 * application signal. Disable dns for the same reason.
57 */
58 "@opentelemetry/instrumentation-fs": { enabled: false },
59 "@opentelemetry/instrumentation-dns": { enabled: false },
60 }),
61 ],
62 });
63
64 sdk.start();
65};
66
67/*
68 * Best-effort shutdown, called from the process exit handlers so

Callers 1

instrument.tsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected