← Back to Pull requests

feat(clusteragent/appsec): add appsec_injector.enabled telemetry gauge #60996

Open
unknown opened this pull request with 330 lines diff across 4 files
View on GitHub
unknown unknown commented on Nov 20, 2026 12:49 UTC
Author

What does this PR do?

Adds an appsec_injector.enabled gauge, tagged with proxy_type and mode, and adds it to the cluster-agent agent telemetry profile. It is set to 1 when the injector starts running for a proxy type (after IsInjectionPossible succeeds, before the leader wait), and removed when it stops. Every cluster-agent replica reports it, leader or not.

Sidecar-mode proxy types mutate pods only through the admission webhook, which does not run when admission_controller.enabled is false. They are reported only when the admission controller is enabled.

Motivation

The only AppSec injector telemetry today is two counters, appsec_injector.watched_changes and appsec_injector.sidecar_mutations. They show activity, not whether the injector is enabled: a cluster with the injector on but no gateway changes or pod admissions reports nothing. Counting clusters by their presence only worked because counters that had moved once were sent with a value of 0 in every later payload, and #60331 stops that for zero_metric profiles. A gauge is not delta-converted, so it keeps reporting while the injector runs.

Describe how you validated your changes

  • TestRun_reportsEnabledGaugeWhileRunning runs the injector as a non-leader in external mode, sidecar mode with the admission controller, and sidecar mode without it. Once run first checks leadership, it checks the gauge is 1 for the first two and absent for the third, then cancels and checks the series is removed.

  • TestRun_logsNotApplicableSkipAtInfo checks, from inside IsInjectionPossible and after run returns, that a proxy type skipped as not applicable is never reported.

  • TestDefaultProfilesExportAppsecInjectorEnabledGauge runs the shipped default profiles through the collection path and checks the sent payload has appsec_injector.enabled = 1 with proxy_type and mode.

  • Each of these fails when the gating is removed, the Set moves before IsInjectionPossible, or the profile drops preserve_tags.

  • dda inv test --targets=./pkg/clusteragent/appsec,./comp/core/agenttelemetry/impl passes, dda inv linter.go reports no issues on both packages, and gazelle is clean.
  • Additional Notes

    COAT payloads carry @org_id and the replica's @metrics.agent_metadata.hostid, but no cluster identifier, so replicas of one cluster cannot be deduplicated. Count orgs, for example cardinality(@org_id) over service:trace-events-writer-agent-telemetry @metrics.appsec_injector.enabled.value:*. Counting hostid counts cluster-agent replicas, not clusters.

    The gauge only appears from the release that ships this change.

    Diff: 330 lines (+247 / -83) across 4 files Reviewer: adel121 Review duration: 15372m
    All Vouch review confidence checks passed
    Residual risk 0.22 = Change Risk (0.42) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.42 · 330 lines diff across 4 files
    0.42
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.347
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #60996"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 42.1% (MEDIUM) · Higher = larger blast radius
    42.1%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 22.4% · Safe to merge
    22.4%