Skip to content

Commit

Permalink
refactor(opentelemetry-exporter-jaeger): removes config parameter change
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardodalcin committed Jun 3, 2020
1 parent 0d8b202 commit 2c75792
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions packages/opentelemetry-exporter-jaeger/src/jaeger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,25 +32,26 @@ export class JaegerExporter implements SpanExporter {
private readonly _onShutdownFlushTimeout: number;

constructor(config: jaegerTypes.ExporterConfig) {
this._logger = config.logger || new NoopLogger();
const tags: jaegerTypes.Tag[] = config.tags || [];
const localConfig = Object.assign({}, config)
this._logger = localConfig.logger || new NoopLogger();
const tags: jaegerTypes.Tag[] = localConfig.tags || [];
this._onShutdownFlushTimeout =
typeof config.flushTimeout === 'number' ? config.flushTimeout : 2000;
typeof localConfig.flushTimeout === 'number' ? localConfig.flushTimeout : 2000;

// https://github.com/jaegertracing/jaeger-client-node#environment-variables
// By default, the client sends traces via UDP to the agent at localhost:6832. Use JAEGER_AGENT_HOST and
// JAEGER_AGENT_PORT to send UDP traces to a different host:port. If JAEGER_ENDPOINT is set, the client sends traces
// to the endpoint via HTTP, making the JAEGER_AGENT_HOST and JAEGER_AGENT_PORT unused. If JAEGER_ENDPOINT is secured,
// HTTP basic authentication can be performed by setting the JAEGER_USER and JAEGER_PASSWORD environment variables.
if (config.endpoint) {
config.endpoint = config.endpoint || process.env.JAEGER_ENDPOINT;
config.username = config.username || process.env.JAEGER_USER;
config.password = config.password || process.env.JAEGER_PASSWORD;
this._sender = new jaegerTypes.HTTPSender(config);
if (localConfig.endpoint) {
localConfig.endpoint = localConfig.endpoint || process.env.JAEGER_ENDPOINT;
localConfig.username = localConfig.username || process.env.JAEGER_USER;
localConfig.password = localConfig.password || process.env.JAEGER_PASSWORD;
this._sender = new jaegerTypes.HTTPSender(localConfig);
this._sender._httpOptions.headers[OT_REQUEST_HEADER] = 1;
} else {
config.host = config.host || process.env.JAEGER_AGENT_HOST;
this._sender = config.endpoint = new jaegerTypes.UDPSender(config);
localConfig.host = localConfig.host || process.env.JAEGER_AGENT_HOST;
this._sender = localConfig.endpoint = new jaegerTypes.UDPSender(localConfig);
}

if (this._sender._client instanceof Socket) {
Expand All @@ -59,7 +60,7 @@ export class JaegerExporter implements SpanExporter {
}

this._process = {
serviceName: config.serviceName,
serviceName: localConfig.serviceName,
tags: jaegerTypes.ThriftUtils.getThriftTags(tags),
};
this._sender.setProcess(this._process);
Expand Down

0 comments on commit 2c75792

Please sign in to comment.