← Back to Pull requests

feat(metricprovider): support per-metric accountId override for New Relic #5031

Closed
unknown closed this pull request without merging on Sep 11, 2026 14:04 UTC
View on GitHub
unknown unknown commented on Sep 09, 2026 20:07 UTC
Author

Summary

Adds an optional accountId field to the New Relic metric provider spec. When set, it overrides the account-id from the profile secret, allowing a single credential/profile to query different New Relic accounts across rollouts. When omitted, the account-id from the profile secret is used — so the change is fully backward compatible.

Motivation

Today the New Relic provider is hard-bound to the account id stored in a single profile secret (Nrdb.Query(n.AccountID, ...)), and there is no way to target a different account per query. In multi-tenant setups where each team's telemetry lives in its own New Relic account, this forces either one profile secret per account (secret sprawl) or relocating APM data into a central account.

The Datadog provider already gained multi-account support in #3787 via a secretRef. This PR provides the equivalent capability for New Relic, but decouples only the non-secret account id rather than distributing credentials: one shared profile secret continues to hold the API key (a New Relic user key can query multiple accounts), and the account to query is selected per-metric.

Changes

  • Add NewRelicMetric.AccountID (optional, proto field 4).

  • Provider uses metric.Provider.NewRelic.AccountID when set; otherwise falls back to the profile secret's account-id (unchanged behavior).

  • Regenerated CRDs, OpenAPI, protobuf, and the kustomize schema.

  • Docs + unit tests covering the override behavior.
  • Backward compatibility

  • The field is optional (omitempty, new proto tag 4) — existing manifests and controllers are unaffected.

  • The profile secret's account-id remains the default and is still required when no override is set; the runtime requirement (apiKey != "" && accountID != "") is unchanged.
  • Example

    provider:
      newRelic:
        profile: my-newrelic-secret   # holds the API key + default account-id
        accountId: "1234567"          # optional; overrides the secret's account-id
        query: FROM Transaction SELECT percentage(count(*), WHERE error IS false) AS successRate
    

    Testing

  • Added unit tests in metricproviders/newrelic/newrelic_test.go for: override takes precedence over the secret, override works when the secret has no account-id, and a non-integer override errors.

  • go build and go test ./metricproviders/newrelic/... pass.
  • Diff: 296 lines (+222 / -74) across 3 files Reviewer: kostis-codefresh Review duration: 2516m
    All Vouch review confidence checks passed
    Residual risk 0.16 = Change Risk (0.40) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.40 · 296 lines diff across 3 files
    0.40
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    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.341
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #5031"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% 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: 40.0% (MEDIUM) · Higher = larger blast radius
    40.0%
    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: 60.5% · Lower = rushed or shallow review
    60.5%
    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: 15.8% · Safe to merge
    15.8%