Skip to content

feat(apm): add sampling-rules CRUD commands#552

Draft
rachelyangdog wants to merge 1 commit into
DataDog:mainfrom
rachelyangdog:rachel/apm-sampling-rules-commands
Draft

feat(apm): add sampling-rules CRUD commands#552
rachelyangdog wants to merge 1 commit into
DataDog:mainfrom
rachelyangdog:rachel/apm-sampling-rules-commands

Conversation

@rachelyangdog
Copy link
Copy Markdown
Contributor

Adds pup apm sampling-rules {list,get,create,update,delete} for managing customer per-(service,env,resource) head-based sampling rules. Backed by Remote Config product APM_TRACING with provenance=customer. Rules surface on traces with _dd.p.dm:-11 and
ingestion_reason:remote_rule.

Commands

pup apm sampling-rules list [--service S --env E]
pup apm sampling-rules get
pup apm sampling-rules create --service S --env E --resource R --sample-rate F
pup apm sampling-rules update --service S --env E --resource R --sample-rate F
pup apm sampling-rules delete

When --service and --env are both given, list narrows via the backend's /configs/by_target endpoint.

Scopes

  • apm_remote_configuration_read (added to default + read_only)
  • apm_remote_configuration_write (added to default)

Both scopes are on pup's OUISvc registrable client allowlist as of the recent OAuth rollout. Backend support is in place:

  • dd-source PR rachel.yang/apm-trace-configurations-oauth-auth (Rapid service-default OAuth on trace-configurations)
  • dd-go PR rachel.yang/rc-api-proxy-apm-tracing-oauth (rc-api-proxy authn_methods on apm_tracing routes)

Tests

8 tests added in commands::apm::tests, matching the service_remapping_* pattern:

test_sampling_rules_list
test_sampling_rules_list_by_target
test_sampling_rules_get
test_sampling_rules_get_not_found
test_sampling_rules_create
test_sampling_rules_create_api_error
test_sampling_rules_update
test_sampling_rules_delete

All pass locally. The 5 unrelated test failures in cases, dbm, logs, metrics, traces are pre-existing DNS-resolution flakes against unused.local and not touched by this change.

Follow-ups

  • pup apm adaptive-sampling commands (allotment + onboarding) — separate PR. Requires the apm_service_ingest_{read,write} scopes which are also already on the OUISvc allowlist.
  • Flip the agent-skills dd-apm/sampling skill PR from draft to ready once these commands ship in a release.

What does this PR do?

Motivation

Additional Notes

Checklist

  • The code change follows the project conventions (see CONTRIBUTING.md)
  • Tests have been added/updated (if applicable)
  • Documentation has been updated (if applicable)
  • All CI checks pass
  • Code coverage is maintained or improved

Related Issues

Adds `pup apm sampling-rules {list,get,create,update,delete}` for
managing customer per-(service,env,resource) head-based sampling rules.
Backed by Remote Config product APM_TRACING with provenance=customer.
Rules surface on traces with `_dd.p.dm:-11` and
`ingestion_reason:remote_rule`.

## Commands

  pup apm sampling-rules list [--service S --env E]
  pup apm sampling-rules get   <id>
  pup apm sampling-rules create --service S --env E --resource R --sample-rate F
  pup apm sampling-rules update <id> --service S --env E --resource R --sample-rate F
  pup apm sampling-rules delete <id>

When `--service` and `--env` are both given, list narrows via the
backend's `/configs/by_target` endpoint.

## Scopes

  - apm_remote_configuration_read   (added to default + read_only)
  - apm_remote_configuration_write  (added to default)

Both scopes are on pup's OUISvc registrable client allowlist as of the
recent OAuth rollout. Backend support is in place:

  - dd-source PR `rachel.yang/apm-trace-configurations-oauth-auth`
    (Rapid service-default OAuth on trace-configurations)
  - dd-go PR `rachel.yang/rc-api-proxy-apm-tracing-oauth`
    (rc-api-proxy authn_methods on apm_tracing routes)

## Tests

8 tests added in `commands::apm::tests`, matching the
service_remapping_* pattern:

  test_sampling_rules_list
  test_sampling_rules_list_by_target
  test_sampling_rules_get
  test_sampling_rules_get_not_found
  test_sampling_rules_create
  test_sampling_rules_create_api_error
  test_sampling_rules_update
  test_sampling_rules_delete

All pass locally. The 5 unrelated test failures in `cases`, `dbm`,
`logs`, `metrics`, `traces` are pre-existing DNS-resolution flakes
against `unused.local` and not touched by this change.

## Follow-ups

  - `pup apm adaptive-sampling` commands (allotment + onboarding) —
    separate PR. Requires the `apm_service_ingest_{read,write}` scopes
    which are also already on the OUISvc allowlist.
  - Flip the agent-skills `dd-apm/sampling` skill PR from draft to
    ready once these commands ship in a release.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@rachelyangdog rachelyangdog requested a review from a team as a code owner June 2, 2026 18:07
@rachelyangdog rachelyangdog marked this pull request as draft June 2, 2026 18:07
@datadog-datadog-prod-us1-2
Copy link
Copy Markdown

datadog-datadog-prod-us1-2 Bot commented Jun 2, 2026

Pipelines

Fix all issues with BitsAI

⚠️ Warnings

🚦 1 Pipeline job failed

CI | Check, Test &amp; Coverage   View in Datadog   GitHub Actions

🔧 Fix in code (Fix with Cursor). Compilation error due to mismatched parentheses in super::sampling_rules_create calls at /home/runner/work/pup/pup/src/commands/apm.rs:949 and /home/runner/work/pup/pup/src/commands/apm.rs:983.

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 3a9a234 | Docs | Datadog PR Page | Give us feedback!

@platinummonkey platinummonkey added enhancement New feature or request product:apm labels Jun 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request product:apm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants