dd-trace-js
dd-trace-js copied to clipboard
Standalone ASM priority sampler and tag propagation
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
withStandaloneAsmPrioritySampler
viaDatadogTracer
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, removesx-datadog-
and datadog info fromtracestate
- 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
- [ ] Unit tests.
- [ ] TypeScript definitions.
- [ ] TypeScript tests.
- [ ] API documentation.
- [ ] CircleCI jobs/workflows.
- [ ] Plugin is exported.