From 4d5181b89df353234a3c0ec5932a2b1e4d0cdfe0 Mon Sep 17 00:00:00 2001 From: NeuralFlux <40491005+NeuralFlux@users.noreply.github.com> Date: Thu, 3 Oct 2024 14:03:26 -0400 Subject: [PATCH] chore: refactor Jaeger URL init --- src/controllers/opentelemetry.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/controllers/opentelemetry.ts b/src/controllers/opentelemetry.ts index 1c2a60b..e7c46ba 100644 --- a/src/controllers/opentelemetry.ts +++ b/src/controllers/opentelemetry.ts @@ -6,18 +6,21 @@ import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-proto'; const debug = Debug("bte:biothings-explorer:otel-init"); import { ATTR_SERVICE_NAME } from '@opentelemetry/semantic-conventions'; +const jaegerHost = process.env.JAEGER_HOST ?? 'jaeger-otel-collector'; +const jaegerPort = process.env.JAEGER_PORT ?? 4318; +const jaegerResName = process.env.JAEGER_RES_NAME ?? ''; debug("Initializing Opentelemetry instrumentation..."); const sdk = new NodeSDK({ // metrics, if needed, shall be exported on a different endpoint traceExporter: new OTLPTraceExporter({ - url: `${process.env.JAEGER_HOST ?? 'jaeger-otel-collector'}:${process.env.JAEGER_PORT ?? 4318}/v1/traces` + url: `${jaegerHost}:${jaegerPort}${jaegerResName}` }), instrumentations: [getNodeAutoInstrumentations()], resource: new Resource({ [ATTR_SERVICE_NAME]: "biothings-explorer", }), }); -debug(`OTel URL ${process.env.JAEGER_HOST ?? 'jaeger-otel-collector'}:${process.env.JAEGER_PORT ?? 4318}/v1/traces`); +debug(`OTel URL ${jaegerHost}:${jaegerPort}${jaegerResName}`); sdk.start(); debug("Opentelemetry instrumentation initialized.");