How to use the dd-trace.extract function in dd-trace

To help you get started, we’ve selected a few dd-trace examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DataDog / datadog-lambda-layer-js / src / trace / listener.ts View on Github external
public onWrap<T = (...args: any[]) => any>(func: T): T {
    const rootTraceContext = this.contextService.currentTraceHeaders;
    const spanContext: SpanContext | null = Tracer.extract("http_headers", rootTraceContext);
    const options: SpanOptions & TraceOptions = {};
    if (this.context) {
      options.tags = {
        cold_start: this.coldstart,
        event_source: this.eventSource,
        function_arn: this.context.invokedFunctionArn,
        request_id: this.context.awsRequestId,
        resource_names: this.context.functionName,

    if (spanContext !== null) {
      options.childOf = spanContext;

    return Tracer.wrap(this.handlerName, options, func);