fix(appsec): manage listener activation lifecycle - #19478
Draft
florentinl wants to merge 1 commit into
Draft
Conversation
Codeowners resolved as |
Circular import analysis
|
Contributor
🎉 All green!🧪 All tests passed 🔗 Commit SHA: 5986b57 | Docs | Datadog PR Page | Give us feedback! |
florentinl
force-pushed
the
agent/appsec-listener-lifecycle
branch
from
August 4, 2026 12:19
18cfc44 to
8a216b7
Compare
florentinl
force-pushed
the
agent/appsec-listener-lifecycle
branch
from
August 4, 2026 12:38
8a216b7 to
5986b57
Compare
BenchmarksBenchmark execution time: 2026-08-04 13:05:16 Comparing candidate commit 5986b57 in PR branch Found 0 performance improvements and 7 performance regressions! Performance is the same for 601 metrics, 10 unstable metrics. scenario:httppropagationinject-ids_only
scenario:iast_aspects-re_expand_aspect
scenario:iastaspects-index_aspect
scenario:iastaspectsospath-ospathbasename_aspect
scenario:span-start
scenario:telemetryaddmetric-1-count-metric-1-times
scenario:tracer-small
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Replace the process-global
_APPSEC_TO_BE_LOADEDsentinel with explicit, symmetric listener registration and deregistration.AppSec activation now registers every activation-sensitive listener it owns, including the typed HTTPX subscribers and listeners that were previously installed as import side effects. Deactivation unregisters those listeners and clears the request-scoped Flask blocking callback. Registration remains idempotent, so load/load and disable/disable sequences are safe.
The AppSec telemetry listener intentionally remains registered after deactivation so it can report the disabled state.
Testing
rt run 248da41@12d4546 -- --no-cov tests/appsec/appsec/test_listeners.py tests/appsec/appsec/test_remoteconfiguration.py tests/appsec/appsec/test_processor.py(131 passed, 1 xfailed)rt run 248da41@12d4546 -- --no-cov tests/appsec/appsec/test_telemetry.py::test_appsec_enabled_metric tests/appsec/appsec/test_listeners.py(13 passed)rt run 1cdebe0@1625618 -- --no-cov tests/internal/test_subscribers.py(14 passed)scripts/lint checksRisks
Listener ownership is spread across several AppSec integration modules. The lifecycle test covers each registration group, repeated activation/deactivation, HTTPX typed subscribers, and the dynamically registered Flask block callback. The telemetry test covers reporting both enabled and disabled AppSec states.
Additional Notes
This PR is intentionally limited to AppSec listener activation lifecycle. The common-module/subprocess signal redesign remains separate.