Skip to content

Commit

Permalink
refactor(exporter-jaeger): migrate away from getEnv() (#5464)
Browse files Browse the repository at this point in the history
  • Loading branch information
pichlermarc authored Feb 13, 2025
1 parent 4b8ae0c commit b526ec9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ For semantic convention package changes, see the [semconv CHANGELOG](packages/se
* `WebTracerProvider` constructor now does not throw anymore when `contextManager` or `propagator` are passed as extra options to the constructor
* feat(sdk-trace-base): add stack trace warning to debug instrumentation [#5363](https://github.com/open-telemetry/opentelemetry-js/pull/5363) @neilfordyce
* feat(core): add more scalable replacements for getEnv(), getEnvWithoutDefaults() [#5443](https://github.com/open-telemetry/opentelemetry-js/pull/5443) @pichlermarc
* refactor(exporter-jaeger): migrate away from getEnv() [#5464](https://github.com/open-telemetry/opentelemetry-js/pull/5464) @pichlermarc

### :bug: (Bug Fix)

Expand Down
21 changes: 14 additions & 7 deletions packages/opentelemetry-exporter-jaeger/src/jaeger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ import {
BindOnceFuture,
ExportResult,
ExportResultCode,
getEnv,
getNumberFromEnv,
getStringFromEnv,
} from '@opentelemetry/core';
import { ReadableSpan, SpanExporter } from '@opentelemetry/sdk-trace-base';
import { Socket } from 'dgram';
Expand Down Expand Up @@ -60,15 +61,21 @@ export class JaegerExporter implements SpanExporter {
// to the endpoint via HTTP, making the OTEL_EXPORTER_JAEGER_AGENT_HOST and JAEGER_AGENT_PORT unused. If OTEL_EXPORTER_JAEGER_ENDPOINT is secured,
// HTTP basic authentication can be performed by setting the OTEL_EXPORTER_JAEGER_USER and OTEL_EXPORTER_JAEGER_PASSWORD environment variables.

const env = getEnv();
localConfig.endpoint =
localConfig.endpoint || env.OTEL_EXPORTER_JAEGER_ENDPOINT;
localConfig.endpoint ||
(getStringFromEnv('OTEL_EXPORTER_JAEGER_ENDPOINT') ?? '');
localConfig.username =
localConfig.username || env.OTEL_EXPORTER_JAEGER_USER;
localConfig.username ||
(getStringFromEnv('OTEL_EXPORTER_JAEGER_USER') ?? '');
localConfig.password =
localConfig.password || env.OTEL_EXPORTER_JAEGER_PASSWORD;
localConfig.host = localConfig.host || env.OTEL_EXPORTER_JAEGER_AGENT_HOST;
localConfig.port = localConfig.port || env.OTEL_EXPORTER_JAEGER_AGENT_PORT;
localConfig.password ||
(getStringFromEnv('OTEL_EXPORTER_JAEGER_PASSWORD') ?? '');
localConfig.host =
localConfig.host ||
(getStringFromEnv('OTEL_EXPORTER_JAEGER_AGENT_HOST') ?? '');
localConfig.port =
localConfig.port ||
(getNumberFromEnv('OTEL_EXPORTER_JAEGER_AGENT_PORT') ?? 6832);

this._localConfig = localConfig;

Expand Down

0 comments on commit b526ec9

Please sign in to comment.