Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import * as jaegerClient from "jaeger-client";
import * as promClient from "prom-client";
import * as opentracing from "opentracing";
const tracingConfig: jaegerClient.TracingConfig = {};
const tracingOptions: jaegerClient.TracingOptions = {};
const tracer = jaegerClient.initTracer(tracingConfig, tracingOptions);
jaegerClient.initTracerFromEnv(tracingConfig, tracingOptions);
const metrics = new jaegerClient.PrometheusMetricsFactory(promClient, "foo");
const textCodec = new jaegerClient.TextMapCodec({
contextKey: 'trace-id',
baggagePrefix: 'baggage-',
urlEncoding: false,
});
tracer.registerInjector(opentracing.FORMAT_TEXT_MAP, textCodec);
tracer.registerExtractor(opentracing.FORMAT_TEXT_MAP, textCodec);
const zipkinB3TextMapCodec = new jaegerClient.ZipkinB3TextMapCodec({
baggagePrefix: 'baggage-',
urlEncoding: false,
});
tracer.registerInjector(opentracing.FORMAT_HTTP_HEADERS, zipkinB3TextMapCodec);
/** Whether or not to enable Jaeger. */
useJaeger: boolean
/** The access token for lightstep tracing. */
lightstepAccessToken: string
}
): Tracer | undefined {
if (useJaeger) {
const config = {
serviceName,
sampler: {
type: 'const',
param: 1,
},
}
return initTracerFromEnv(config, {})
}
if (lightstepAccessToken !== '') {
return new lightstep.Tracer({
access_token: lightstepAccessToken,
component_name: serviceName,
})
}
return undefined
}