Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standalone ASM priority sampler and tag propagation #4416

Merged
merged 110 commits into from
Jul 5, 2024

Conversation

iunanua
Copy link
Contributor

@iunanua iunanua commented Jun 19, 2024

What does this PR do?

Continuation of #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 and others added 30 commits May 9, 2024 11:53
@iunanua iunanua marked this pull request as ready for review June 27, 2024 15:04
@iunanua iunanua requested review from a team as code owners June 27, 2024 15:04
@iunanua iunanua merged commit 7997564 into master Jul 5, 2024
157 checks passed
@iunanua iunanua deleted the igor/standalone-asm-priority-sampler-channel branch July 5, 2024 08:47
juan-fernandez pushed a commit that referenced this pull request Jul 10, 2024
* DD_APM_TRACING_ENABLED and span _dd.apm.enabled tag

* clean up

* Use MANUAL_KEEP const

* Add _dd.p.appsec tag on standalone ASM events

* Include apmTracingEnabled checks

* Appsec Reporter tests

* Appsec sdk track_event test

* Use numeric value for _dd.p.appsec

* Include appsec standalone config in .ts files

* Clean up null and undefined values

* Remove not needed config properties

* standalone module

* Clean up

* standalone proxy test

* Update packages/dd-trace/test/appsec/iast/vulnerability-reporter.spec.js

Co-authored-by: Ugaitz Urien <[email protected]>

* appsec reporter test

* Use standalone singletone in vulnerability-reporter

* continue applying ratelimiter on appsec standalone events

* Update packages/dd-trace/src/appsec/reporter.js

Co-authored-by: simon-id <[email protected]>

* Add _dd.apm.enabled:0 in root spans with remote parent

* Use a method to add the tag

* Remove apmTracingEnabled config property

* Add _dd.p.appsec tag in trace tags

* Some tests

* Set _dd.apm.enabled in root span

* configure standalone if _tracingInitialized

* Use dd-trace:span:start channel

* PrioritySampler and propagation

* Clean up

* Clean up

* use a meta tag

* Use dc to modify what is injected and extracted

* set USER_KEEP priority

* integration tests

* hasSubscribers check

* test description

* hasSubscribers check

* standalone tests

* Check span context has tags before using them and check if config has changed

* clean up

* Pass prioritySampler as argument to DatadogTracer

* clean up

* clean up

* protect span context sampling access

* Disable span stats if standalone enabled

* clean up

* clean up

* Clean up

* Clean up

* clean up

* Remove all headers from carrier

* inject integration tests

* remove only

* Update packages/dd-trace/test/appsec/sdk/track_event.spec.js

Co-authored-by: Ugaitz Urien <[email protected]>

* Update packages/dd-trace/test/appsec/standalone.spec.js

Co-authored-by: Ugaitz Urien <[email protected]>

* protect sample method

* Use assert instead expect

* reset sampling prio

* unsubscribe after test

* clear dd context from tracestate

* propagation with and without ASM events

* suggestions

* test inject and extrach channels

* use two services to test propagation

* integration tests cleanup

* clean up

* clean up

* Update packages/dd-trace/src/priority_sampler.js

Co-authored-by: Ugaitz Urien <[email protected]>

* Update packages/dd-trace/src/appsec/standalone.js

Co-authored-by: Ugaitz Urien <[email protected]>

* Move hasOwn, remove not used argument and fix test

* simplify iast integration-test using weak_hash

* Update packages/dd-trace/src/appsec/standalone.js

Co-authored-by: Ugaitz Urien <[email protected]>

* suggestions

* Fix integration tests

* Update packages/dd-trace/test/span_stats.spec.js

Co-authored-by: Ugaitz Urien <[email protected]>

* Update packages/dd-trace/test/exporters/agent/exporter.spec.js

Co-authored-by: Ugaitz Urien <[email protected]>

* Remove redundant check

* Remove standalone option

* protect onSpanInject and onSpanExtract

* do not set _dd.p.dm

* remove _dd.p.dm check from integration tests

* increase coverage

* increase coverage

* more coverage

* remove not needed async

* set default mechanism

* sugestions

* Remove throw tests

* Remove throw tests

* Update packages/dd-trace/test/appsec/standalone.spec.js

Co-authored-by: simon-id <[email protected]>

---------

Co-authored-by: Ugaitz Urien <[email protected]>
Co-authored-by: simon-id <[email protected]>
juan-fernandez pushed a commit that referenced this pull request Jul 10, 2024
* DD_APM_TRACING_ENABLED and span _dd.apm.enabled tag

* clean up

* Use MANUAL_KEEP const

* Add _dd.p.appsec tag on standalone ASM events

* Include apmTracingEnabled checks

* Appsec Reporter tests

* Appsec sdk track_event test

* Use numeric value for _dd.p.appsec

* Include appsec standalone config in .ts files

* Clean up null and undefined values

* Remove not needed config properties

* standalone module

* Clean up

* standalone proxy test

* Update packages/dd-trace/test/appsec/iast/vulnerability-reporter.spec.js

Co-authored-by: Ugaitz Urien <[email protected]>

* appsec reporter test

* Use standalone singletone in vulnerability-reporter

* continue applying ratelimiter on appsec standalone events

* Update packages/dd-trace/src/appsec/reporter.js

Co-authored-by: simon-id <[email protected]>

* Add _dd.apm.enabled:0 in root spans with remote parent

* Use a method to add the tag

* Remove apmTracingEnabled config property

* Add _dd.p.appsec tag in trace tags

* Some tests

* Set _dd.apm.enabled in root span

* configure standalone if _tracingInitialized

* Use dd-trace:span:start channel

* PrioritySampler and propagation

* Clean up

* Clean up

* use a meta tag

* Use dc to modify what is injected and extracted

* set USER_KEEP priority

* integration tests

* hasSubscribers check

* test description

* hasSubscribers check

* standalone tests

* Check span context has tags before using them and check if config has changed

* clean up

* Pass prioritySampler as argument to DatadogTracer

* clean up

* clean up

* protect span context sampling access

* Disable span stats if standalone enabled

* clean up

* clean up

* Clean up

* Clean up

* clean up

* Remove all headers from carrier

* inject integration tests

* remove only

* Update packages/dd-trace/test/appsec/sdk/track_event.spec.js

Co-authored-by: Ugaitz Urien <[email protected]>

* Update packages/dd-trace/test/appsec/standalone.spec.js

Co-authored-by: Ugaitz Urien <[email protected]>

* protect sample method

* Use assert instead expect

* reset sampling prio

* unsubscribe after test

* clear dd context from tracestate

* propagation with and without ASM events

* suggestions

* test inject and extrach channels

* use two services to test propagation

* integration tests cleanup

* clean up

* clean up

* Update packages/dd-trace/src/priority_sampler.js

Co-authored-by: Ugaitz Urien <[email protected]>

* Update packages/dd-trace/src/appsec/standalone.js

Co-authored-by: Ugaitz Urien <[email protected]>

* Move hasOwn, remove not used argument and fix test

* simplify iast integration-test using weak_hash

* Update packages/dd-trace/src/appsec/standalone.js

Co-authored-by: Ugaitz Urien <[email protected]>

* suggestions

* Fix integration tests

* Update packages/dd-trace/test/span_stats.spec.js

Co-authored-by: Ugaitz Urien <[email protected]>

* Update packages/dd-trace/test/exporters/agent/exporter.spec.js

Co-authored-by: Ugaitz Urien <[email protected]>

* Remove redundant check

* Remove standalone option

* protect onSpanInject and onSpanExtract

* do not set _dd.p.dm

* remove _dd.p.dm check from integration tests

* increase coverage

* increase coverage

* more coverage

* remove not needed async

* set default mechanism

* sugestions

* Remove throw tests

* Remove throw tests

* Update packages/dd-trace/test/appsec/standalone.spec.js

Co-authored-by: simon-id <[email protected]>

---------

Co-authored-by: Ugaitz Urien <[email protected]>
Co-authored-by: simon-id <[email protected]>
This was referenced Jul 10, 2024
juan-fernandez pushed a commit that referenced this pull request Jul 11, 2024
* DD_APM_TRACING_ENABLED and span _dd.apm.enabled tag

* clean up

* Use MANUAL_KEEP const

* Add _dd.p.appsec tag on standalone ASM events

* Include apmTracingEnabled checks

* Appsec Reporter tests

* Appsec sdk track_event test

* Use numeric value for _dd.p.appsec

* Include appsec standalone config in .ts files

* Clean up null and undefined values

* Remove not needed config properties

* standalone module

* Clean up

* standalone proxy test

* Update packages/dd-trace/test/appsec/iast/vulnerability-reporter.spec.js

Co-authored-by: Ugaitz Urien <[email protected]>

* appsec reporter test

* Use standalone singletone in vulnerability-reporter

* continue applying ratelimiter on appsec standalone events

* Update packages/dd-trace/src/appsec/reporter.js

Co-authored-by: simon-id <[email protected]>

* Add _dd.apm.enabled:0 in root spans with remote parent

* Use a method to add the tag

* Remove apmTracingEnabled config property

* Add _dd.p.appsec tag in trace tags

* Some tests

* Set _dd.apm.enabled in root span

* configure standalone if _tracingInitialized

* Use dd-trace:span:start channel

* PrioritySampler and propagation

* Clean up

* Clean up

* use a meta tag

* Use dc to modify what is injected and extracted

* set USER_KEEP priority

* integration tests

* hasSubscribers check

* test description

* hasSubscribers check

* standalone tests

* Check span context has tags before using them and check if config has changed

* clean up

* Pass prioritySampler as argument to DatadogTracer

* clean up

* clean up

* protect span context sampling access

* Disable span stats if standalone enabled

* clean up

* clean up

* Clean up

* Clean up

* clean up

* Remove all headers from carrier

* inject integration tests

* remove only

* Update packages/dd-trace/test/appsec/sdk/track_event.spec.js

Co-authored-by: Ugaitz Urien <[email protected]>

* Update packages/dd-trace/test/appsec/standalone.spec.js

Co-authored-by: Ugaitz Urien <[email protected]>

* protect sample method

* Use assert instead expect

* reset sampling prio

* unsubscribe after test

* clear dd context from tracestate

* propagation with and without ASM events

* suggestions

* test inject and extrach channels

* use two services to test propagation

* integration tests cleanup

* clean up

* clean up

* Update packages/dd-trace/src/priority_sampler.js

Co-authored-by: Ugaitz Urien <[email protected]>

* Update packages/dd-trace/src/appsec/standalone.js

Co-authored-by: Ugaitz Urien <[email protected]>

* Move hasOwn, remove not used argument and fix test

* simplify iast integration-test using weak_hash

* Update packages/dd-trace/src/appsec/standalone.js

Co-authored-by: Ugaitz Urien <[email protected]>

* suggestions

* Fix integration tests

* Update packages/dd-trace/test/span_stats.spec.js

Co-authored-by: Ugaitz Urien <[email protected]>

* Update packages/dd-trace/test/exporters/agent/exporter.spec.js

Co-authored-by: Ugaitz Urien <[email protected]>

* Remove redundant check

* Remove standalone option

* protect onSpanInject and onSpanExtract

* do not set _dd.p.dm

* remove _dd.p.dm check from integration tests

* increase coverage

* increase coverage

* more coverage

* remove not needed async

* set default mechanism

* sugestions

* Remove throw tests

* Remove throw tests

* Update packages/dd-trace/test/appsec/standalone.spec.js

Co-authored-by: simon-id <[email protected]>

---------

Co-authored-by: Ugaitz Urien <[email protected]>
Co-authored-by: simon-id <[email protected]>
juan-fernandez pushed a commit that referenced this pull request Jul 11, 2024
* DD_APM_TRACING_ENABLED and span _dd.apm.enabled tag

* clean up

* Use MANUAL_KEEP const

* Add _dd.p.appsec tag on standalone ASM events

* Include apmTracingEnabled checks

* Appsec Reporter tests

* Appsec sdk track_event test

* Use numeric value for _dd.p.appsec

* Include appsec standalone config in .ts files

* Clean up null and undefined values

* Remove not needed config properties

* standalone module

* Clean up

* standalone proxy test

* Update packages/dd-trace/test/appsec/iast/vulnerability-reporter.spec.js

Co-authored-by: Ugaitz Urien <[email protected]>

* appsec reporter test

* Use standalone singletone in vulnerability-reporter

* continue applying ratelimiter on appsec standalone events

* Update packages/dd-trace/src/appsec/reporter.js

Co-authored-by: simon-id <[email protected]>

* Add _dd.apm.enabled:0 in root spans with remote parent

* Use a method to add the tag

* Remove apmTracingEnabled config property

* Add _dd.p.appsec tag in trace tags

* Some tests

* Set _dd.apm.enabled in root span

* configure standalone if _tracingInitialized

* Use dd-trace:span:start channel

* PrioritySampler and propagation

* Clean up

* Clean up

* use a meta tag

* Use dc to modify what is injected and extracted

* set USER_KEEP priority

* integration tests

* hasSubscribers check

* test description

* hasSubscribers check

* standalone tests

* Check span context has tags before using them and check if config has changed

* clean up

* Pass prioritySampler as argument to DatadogTracer

* clean up

* clean up

* protect span context sampling access

* Disable span stats if standalone enabled

* clean up

* clean up

* Clean up

* Clean up

* clean up

* Remove all headers from carrier

* inject integration tests

* remove only

* Update packages/dd-trace/test/appsec/sdk/track_event.spec.js

Co-authored-by: Ugaitz Urien <[email protected]>

* Update packages/dd-trace/test/appsec/standalone.spec.js

Co-authored-by: Ugaitz Urien <[email protected]>

* protect sample method

* Use assert instead expect

* reset sampling prio

* unsubscribe after test

* clear dd context from tracestate

* propagation with and without ASM events

* suggestions

* test inject and extrach channels

* use two services to test propagation

* integration tests cleanup

* clean up

* clean up

* Update packages/dd-trace/src/priority_sampler.js

Co-authored-by: Ugaitz Urien <[email protected]>

* Update packages/dd-trace/src/appsec/standalone.js

Co-authored-by: Ugaitz Urien <[email protected]>

* Move hasOwn, remove not used argument and fix test

* simplify iast integration-test using weak_hash

* Update packages/dd-trace/src/appsec/standalone.js

Co-authored-by: Ugaitz Urien <[email protected]>

* suggestions

* Fix integration tests

* Update packages/dd-trace/test/span_stats.spec.js

Co-authored-by: Ugaitz Urien <[email protected]>

* Update packages/dd-trace/test/exporters/agent/exporter.spec.js

Co-authored-by: Ugaitz Urien <[email protected]>

* Remove redundant check

* Remove standalone option

* protect onSpanInject and onSpanExtract

* do not set _dd.p.dm

* remove _dd.p.dm check from integration tests

* increase coverage

* increase coverage

* more coverage

* remove not needed async

* set default mechanism

* sugestions

* Remove throw tests

* Remove throw tests

* Update packages/dd-trace/test/appsec/standalone.spec.js

Co-authored-by: simon-id <[email protected]>

---------

Co-authored-by: Ugaitz Urien <[email protected]>
Co-authored-by: simon-id <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants