Skip to content

Commit

Permalink
chore: refactor Jaeger URL init
Browse files Browse the repository at this point in the history
  • Loading branch information
NeuralFlux committed Oct 3, 2024
1 parent aa83d8c commit 4d5181b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/controllers/opentelemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.");

0 comments on commit 4d5181b

Please sign in to comment.