diff --git a/packages/opentelemetry-exporter-jaeger/src/jaeger.ts b/packages/opentelemetry-exporter-jaeger/src/jaeger.ts index 83f6658492..5cc5178289 100644 --- a/packages/opentelemetry-exporter-jaeger/src/jaeger.ts +++ b/packages/opentelemetry-exporter-jaeger/src/jaeger.ts @@ -38,7 +38,17 @@ export class JaegerExporter implements SpanExporter { typeof config.flushTimeout === 'number' ? config.flushTimeout : 2000; config.host = config.host || process.env.JAEGER_AGENT_HOST; - + config.endpoint = config.endpoint || process.env.JAEGER_ENDPOINT; + config.username = config.username || process.env.JAEGER_USER; + config.password = config.password || process.env.JAEGER_PASSWORD; + // 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. + this._sender = config.endpoint + ? new jaegerTypes.HTTPSender(config) + : new jaegerTypes.UDPSender(config); this._sender = new jaegerTypes.UDPSender(config); if (this._sender._client instanceof Socket) { // unref socket to prevent it from keeping the process running diff --git a/packages/opentelemetry-exporter-jaeger/src/types.ts b/packages/opentelemetry-exporter-jaeger/src/types.ts index c902cfd309..72282212d2 100644 --- a/packages/opentelemetry-exporter-jaeger/src/types.ts +++ b/packages/opentelemetry-exporter-jaeger/src/types.ts @@ -28,6 +28,13 @@ export interface ExporterConfig { maxPacketSize?: number; // default: 65000 /** Time to wait for an onShutdown flush to finish before closing the sender */ flushTimeout?: number; // default: 2000 + //The HTTP endpoint for sending spans directly to a collector, i.e. http://jaeger-collector:14268/api/traces + //If setten will override host and port + endpoint?: string; + //Username to send as part of "Basic" authentication to the collector endpoint + username?: string; + //Password to send as part of "Basic" authentication to the collector endpoint + password?: string; } // Below require is needed as jaeger-client types does not expose the thrift, @@ -41,6 +48,8 @@ export const Utils = require('jaeger-client/dist/src/util').default; // tslint:disable-next-line:variable-name export const ThriftUtils = require('jaeger-client/dist/src/thrift').default; +export const HTTPSender = require('jaeger-client/dist/src/reporters/http_sender').default; + export type TagValue = string | number | boolean; export interface Tag {