Skip to content

Commit f877ba1

Browse files
pichlermarctrentm
authored andcommitted
refactor(exporter-jaeger): migrate away from getEnv() (open-telemetry#5464)
1 parent 8e08ff4 commit f877ba1

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ For semantic convention package changes, see the [semconv CHANGELOG](packages/se
105105
* `WebTracerProvider` constructor now does not throw anymore when `contextManager` or `propagator` are passed as extra options to the constructor
106106
* feat(sdk-trace-base): add stack trace warning to debug instrumentation [#5363](https://github.com/open-telemetry/opentelemetry-js/pull/5363) @neilfordyce
107107
* feat(core): add more scalable replacements for getEnv(), getEnvWithoutDefaults() [#5443](https://github.com/open-telemetry/opentelemetry-js/pull/5443) @pichlermarc
108+
* refactor(exporter-jaeger): migrate away from getEnv() [#5464](https://github.com/open-telemetry/opentelemetry-js/pull/5464) @pichlermarc
108109

109110
### :bug: (Bug Fix)
110111

packages/opentelemetry-exporter-jaeger/src/jaeger.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ import {
1919
BindOnceFuture,
2020
ExportResult,
2121
ExportResultCode,
22-
getEnv,
22+
getNumberFromEnv,
23+
getStringFromEnv,
2324
} from '@opentelemetry/core';
2425
import { ReadableSpan, SpanExporter } from '@opentelemetry/sdk-trace-base';
2526
import { Socket } from 'dgram';
@@ -60,15 +61,21 @@ export class JaegerExporter implements SpanExporter {
6061
// to the endpoint via HTTP, making the OTEL_EXPORTER_JAEGER_AGENT_HOST and JAEGER_AGENT_PORT unused. If OTEL_EXPORTER_JAEGER_ENDPOINT is secured,
6162
// HTTP basic authentication can be performed by setting the OTEL_EXPORTER_JAEGER_USER and OTEL_EXPORTER_JAEGER_PASSWORD environment variables.
6263

63-
const env = getEnv();
6464
localConfig.endpoint =
65-
localConfig.endpoint || env.OTEL_EXPORTER_JAEGER_ENDPOINT;
65+
localConfig.endpoint ||
66+
(getStringFromEnv('OTEL_EXPORTER_JAEGER_ENDPOINT') ?? '');
6667
localConfig.username =
67-
localConfig.username || env.OTEL_EXPORTER_JAEGER_USER;
68+
localConfig.username ||
69+
(getStringFromEnv('OTEL_EXPORTER_JAEGER_USER') ?? '');
6870
localConfig.password =
69-
localConfig.password || env.OTEL_EXPORTER_JAEGER_PASSWORD;
70-
localConfig.host = localConfig.host || env.OTEL_EXPORTER_JAEGER_AGENT_HOST;
71-
localConfig.port = localConfig.port || env.OTEL_EXPORTER_JAEGER_AGENT_PORT;
71+
localConfig.password ||
72+
(getStringFromEnv('OTEL_EXPORTER_JAEGER_PASSWORD') ?? '');
73+
localConfig.host =
74+
localConfig.host ||
75+
(getStringFromEnv('OTEL_EXPORTER_JAEGER_AGENT_HOST') ?? '');
76+
localConfig.port =
77+
localConfig.port ||
78+
(getNumberFromEnv('OTEL_EXPORTER_JAEGER_AGENT_PORT') ?? 6832);
7279

7380
this._localConfig = localConfig;
7481

0 commit comments

Comments
 (0)