dd-trace-js icon indicating copy to clipboard operation
dd-trace-js copied to clipboard

Standalone ASM priority sampler and tag propagation

Open iunanua opened this issue 8 months ago • 3 comments

What does this PR do?

Continuation of https://github.com/DataDog/dd-trace-js/pull/4291

Defines two new channels in opentracing/propagation/text_map.js in order to alter trace propagation:

  • dd-trace:span:inject which publishes the trace span context and the carrier that is going to be injected in a downstream req
  • dd-trace:span:extract which publishes the trace span context and the carrier when a span is going to be extracted from an upstream req.

When standalone ASM is enabled it:

  • replaces default PrioritySampler with StandaloneAsmPrioritySampler via DatadogTracer constructor.
    • StandaloneAsmPrioritySampler searches for _dd.p.appsec in the tags in order to keep a trace, sets a 1 req/min rate limiter and disables user rules.
  • when injecting a trace and if the trace doesn't contain _dd.p.appsec tag, removes x-datadog- and datadog info from tracestate
  • when extracting a trace if the trace doesn't contain _dd.p.appsec tag, resets the sampling priority.
  • disables span stats and includes 'Datadog-Client-Computed-Stats': 'yes' header when exporting traces to the agent to pretend stats computation is made by the tracer

ST PR to enable Standalone ASM tests

Motivation

Support Standalone ASM billing

Plugin Checklist

Additional Notes

iunanua avatar Jun 19 '24 13:06 iunanua