Skip to content

Commit

Permalink
Merge branch 'fix-857-bte'
Browse files Browse the repository at this point in the history
refactor and add resource name to jaeger url parsing
  • Loading branch information
NeuralFlux committed Oct 3, 2024
2 parents 9b6f11f + 4d5181b commit 0c2e3bb
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 0c2e3bb

Please sign in to comment.