From 4798767037a7aa7f91f3e99113cf2051d062c164 Mon Sep 17 00:00:00 2001 From: Sergey Gleip <3on.gleip@gmail.com> Date: Wed, 20 Dec 2023 14:14:09 +0300 Subject: [PATCH] fix: Change opentracing protocol (#94) --- src/Service.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/Service.ts b/src/Service.ts index 2c062e2..5cd68b3 100644 --- a/src/Service.ts +++ b/src/Service.ts @@ -85,9 +85,19 @@ export class Service extends Root { [SemanticResourceAttributes.SERVICE_NAME]: this.options.name, }), }); - const exporter = new JaegerExporter({ - endpoint: this.getSettingFromEnv('OTEL_AGENT', false), - }); + + let host: string | undefined; + let port: number | undefined; + + const agentUrl = this.getSettingFromEnv('OTEL_AGENT', false); + + if (agentUrl) { + const agent = agentUrl.split(':'); + host = agent[0]; + port = parseInt(agent[1]) || undefined; + } + + const exporter = new JaegerExporter({ host, port }); provider.addSpanProcessor(new SimpleSpanProcessor(exporter)); provider.register(); }