Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.get()
.initialize()
.catch(err => {
this.logger.error(
'StackdriverTracer#start: Disabling the Trace Agent for the',
`following reason: ${err.message}`
);
this.disable();
});
cls.get().enable();
const tracePolicy =
this.config.overrides.tracePolicy ||
new BuiltinTracePolicy(this.config.tracePolicyConfig);
const propagation =
this.config.overrides.propagation || new StackdriverFormat();
const tracerComponents = {logger: this.logger, tracePolicy, propagation};
this.traceAgent.enable(
this.config.pluginLoaderConfig.tracerConfig,
tracerComponents
);
pluginLoader
.create(this.config.pluginLoaderConfig, tracerComponents)
.activate();
// Require http and https again, now that the plugin loader is activated.
// This forces them to be patched.
require('http');
require('https');
export function getOrInjectContext(
headerWrapper: HeaderWrapper
): context.SpanContext {
let spanContext = context.extract(headerWrapper);
if (spanContext) {
return spanContext;
}
// We were the first actor to detect lack of context. Establish context.
spanContext = context.generate();
context.inject(headerWrapper, spanContext);
return spanContext;
}
export function getOrInjectContext(
headerWrapper: HeaderWrapper
): context.SpanContext {
let spanContext = context.extract(headerWrapper);
if (spanContext) {
return spanContext;
}
// We were the first actor to detect lack of context. Establish context.
spanContext = context.generate();
context.inject(headerWrapper, spanContext);
return spanContext;
}
export function getOrInjectContext(
headerWrapper: HeaderWrapper
): context.SpanContext {
let spanContext = context.extract(headerWrapper);
if (spanContext) {
return spanContext;
}
// We were the first actor to detect lack of context. Establish context.
spanContext = context.generate();
context.inject(headerWrapper, spanContext);
return spanContext;
}