Skip to content

refactor(rc): drop in-tracer RC tags normalization shim [stacked on #227]#242

Closed
bm1549 wants to merge 1 commit into
worktree-brian.marks+adaptive-sampling-fixesfrom
brian.marks/drop-rc-tags-normalization
Closed

refactor(rc): drop in-tracer RC tags normalization shim [stacked on #227]#242
bm1549 wants to merge 1 commit into
worktree-brian.marks+adaptive-sampling-fixesfrom
brian.marks/drop-rc-tags-normalization

Conversation

@bm1549
Copy link
Copy Markdown
Contributor

@bm1549 bm1549 commented May 29, 2026

🚧 DO NOT MERGE YET — intentionally premature, stacked on #227.
CI is expected RED until the workspace libdd-sampling dependency is bumped to a release that parses RC list-shape tags natively. See "Merge gate" below.

What does this PR do?

Deletes normalize_rc_tags from datadog-opentelemetry/src/core/configuration/remote_config.rs — the temporary shim added in #227 that converts Remote Config's list-shape sampling-rule tags ([{"key": "...", "value_glob": "..."}]) into the map shape ({"key": "value"}) that libdd-sampling's SamplingRuleConfig deserializer currently requires.

Also removes the shim's 3 direct unit tests (test_normalize_rc_tags_*) and its single call site. Net: -106 / +10 in one file.

Motivation

The shim only exists because libdd-sampling (currently pinned at 1.0.0) deserializes rule tags as a {key: value} map and rejects the RC wire shape. Once a libdd-sampling release lands that parses the list shape [{key, value_glob}] natively, the in-tracer normalization is dead weight — the RC JSON can flow straight through. This PR stages that cleanup so it's ready to land the moment the dependency supports it.

Merge gate — read before merging

This change is only safe once libdd-sampling is bumped to the release with native list-shape tag parsing. Merging the shim removal alone regresses production: the tracer would advertise RC sampling support but reject any rule carrying tags (invalid type: sequence, expected a map).

The interlock is the kept test test_handler_rc_rules_with_list_tags_applied:

  • It is RED today on libdd-sampling 1.0.0 (verified locally: invalid type: sequence, expected a map at line 1 column 43).
  • It flips green once the workspace libdd-sampling is bumped to the release that accepts list-shape tags.
  • Left red on purpose (not #[ignore]d) so CI cannot go green — and the PR cannot be cleanly merged — until the parser actually supports the wire shape.

To land this PR: in this branch (or a precursor), bump libdd-sampling (workspace Cargo.toml + Cargo.lock) to the release with native list-shape support, confirm the gate test goes green, then merge.

Additional Notes

  • Stacked on fix(rc): accept RC list-shape tags and honor tracing_sampling_rate #227 (base = worktree-brian.marks+adaptive-sampling-fixes). Rebase onto main once fix(rc): accept RC list-shape tags and honor tracing_sampling_rate #227 merges.
  • Kept, with a post-bump caveat: test_handler_malformed_tags_rejects_update still asserts that a rule with a malformed list-shape tag entry (missing value_glob) is rejected wholesale. Today that holds because libdd-sampling rejects all list-shape tags. Post-bump, the fail-closed invariant (don't silently drop a bad entry and broaden a tag-constrained rule) must be re-validated against the new parser, and that test's comment (which still attributes rejection to the removed shim) should be refreshed by the bump PR.
  • No CHANGELOG entry: the changelog is release-sectioned with no "Unreleased" heading, and the net user-visible behavior at correct merge time (with the bump) is unchanged — list-tag rules still apply, just parsed by libdd-sampling instead of the shim. If the bump PR warrants a changelog line, add it there.

🤖 Generated with Claude Code

Removes `normalize_rc_tags` (and its 3 unit tests + call site), the
temporary shim that converted RC's list-shape sampling-rule tags
(`[{key, value_glob}]`) into the map shape (`{key: value}`) that
libdd-sampling's deserializer currently requires.

This shim exists only because libdd-sampling does not yet parse the RC
wire shape natively. Once a libdd-sampling release lands that accepts
list-shape tags directly, this normalization is dead weight.

Stacked on #227. **Intentionally premature — DO NOT MERGE yet.** This
deletion is only safe once the workspace libdd-sampling dependency is
bumped to the release that parses list-shape tags natively. Merging the
shim removal alone regresses RC tag-qualified sampling in production
(the tracer would advertise RC sampling support but reject any rule with
tags). CI is RED until that bump.

The gate is `test_handler_rc_rules_with_list_tags_applied`: it fails
today with `invalid type: sequence, expected a map` and flips green once
the bump lands. Left red (not #[ignore]) deliberately, as a merge
interlock that prevents shipping the regression.

Kept (post-bump contract, behavior-level, no ref to the removed fn):
- test_handler_rc_rules_with_list_tags_applied  (the green-light gate)
- test_handler_malformed_tags_rejects_update    (re-validate post-bump:
  libdd-sampling must still reject malformed list entries, not silently
  drop them — the fail-closed invariant the shim used to guarantee; its
  comment attributing rejection to the shim is now stale and should be
  updated by the bump PR)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@datadog-prod-us1-3
Copy link
Copy Markdown

datadog-prod-us1-3 Bot commented May 29, 2026

Pipelines  Tests

Fix all issues with BitsAI

⚠️ Warnings

🚦 6 Pipeline jobs failed

Test | build and test using cross - on centos7   View in Datadog   GitHub Actions

🔧 Fix in code (Fix with Cursor). Panic: called `Result::unwrap()` on an `Err` value: Failed to update sampling rules from remote: Failed to parse sampling rules JSON: invalid type: sequence, expected a map at line 1 column 43 in remote_config.rs:2425.

Test | cargo test --workspace #macos-14   View in Datadog   GitHub Actions

🔧 Fix in code (Fix with Cursor). 1 test failed: panic at datadog-opentelemetry/src/core/configuration/remote_config.rs:2425:60 due to invalid type in parsed JSON.

Check Pull Request CI Status | ensure-ci-success   View in Datadog   GitHub Actions

🛟 This job is unlikely to succeed on retry. Please review your pipeline configuration. Check run failed due to deprecated Node.js 20 actions. Update actions for Node.js 24 support.

View all 6 failed jobs.

🧪 1 Test failed in 1 job

Test | test   GitHub Actions

core::configuration::remote_config::tests::test_handler_rc_rules_with_list_tags_applied from datadog-opentelemetry   View in Datadog (Fix with Cursor)
Test has failed

ℹ️ Info

No other issues found (see more)

❄️ No new flaky tests detected

Useful? React with 👍 / 👎

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

@bm1549
Copy link
Copy Markdown
Contributor Author

bm1549 commented Jun 1, 2026

Folding this into the base PR #227 instead of keeping it stacked.

libdd-sampling 2.1.0 shipped with native RC list-shape tag parsing, so the shim removal is no longer "premature" — #227 now bumps libdd-sampling 1.0.0 → 2.1.0 and drops the normalize_rc_tags shim in a single commit (chore: bump libdd-sampling 1.0.0 -> 2.1.0, drop RC tags shim). The gate test test_handler_rc_rules_with_list_tags_applied is green there, and the fail-closed invariant (test_handler_malformed_tags_rejects_update) still holds on 2.1.0.

Closing as superseded — no separate cleanup PR needed.

@bm1549 bm1549 closed this Jun 1, 2026
@bm1549 bm1549 deleted the brian.marks/drop-rc-tags-normalization branch June 1, 2026 12:23
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.

1 participant