refactor(config): peer service revamp#4653
Conversation
Move peerServiceDefaultsEnabled and peerServiceMappings from the tracer's local config struct to internal/config.Config. These fields already existed in the global config singleton but lacked getter/setter methods. The tracer now reads/writes peer service configuration through the global config accessors instead of maintaining local copies.
…e defaults - Fix gofmt: remove extra blank line left from field removal - Keep schema-dependent peerServiceDefaultsEnabled logic in the tracer since spanAttributeSchemaVersion uses namingschema (understands "v1") while loadConfig uses getInt (can't parse "v1"). Add TODO to move once spanAttributeSchemaVersion is fully migrated.
SetPeerServiceMappings and SetPeerServiceMapping have non-standard signatures (map param / three value params) that the reflective test helper cannot auto-generate values for. Register them as special cases.
Address PR review comments: move the peer service defaults enabled logic (schema-dependent calculation) from tracer's newConfig() to internal config's loadConfig(). Add parseSpanAttributeSchema parser that handles "v0"/"v1" string values (matching namingschema behavior), replacing the previous getInt call that couldn't parse these formats.
…okup - Add getIntWithParser to configprovider instead of calling get() directly - Keep all provider.getX calls together in loadConfig; move the schema-dependent peer service defaults override to the derived evaluations section below - Replace PeerServiceMappings map in TracerConf with a PeerServiceMapping func for single-key lookups, avoiding lock contention and per-call map copies on the hot path (setPeerService is called for every span) - Update setPeerService to use the function-based lookup with nil guard - Fix CiVisibility TracerConf test to compare fields individually since functions cannot be compared with reflect.DeepEqual
…al mutation Made-with: Cursor
Follow the existing configprovider pattern: use getString to read the raw DD_TRACE_SPAN_ATTRIBUTE_SCHEMA value and parse it in the derived evaluations section with parseSpanAttributeSchema, matching how featureFlags and logToStdout are handled. Remove the getIntWithParser method that was just a passthrough to get().
Resolve merge conflict in internal/config/config.go: adopt main's refactored provider API (p.GetX exported methods) while preserving our peer service and span attribute schema migrations. Update reportTelemetry calls to configtelemetry.Report to match main's rename. Co-Authored-By: Claude Opus 4.6 <[email protected]>
…rvice # Conflicts: # internal/config/config_helpers.go
…rvice # Conflicts: # ddtrace/tracer/api.txt
…race-go into config-revamp/peer-service
Co-Authored-By: Claude Opus 4.6 <[email protected]>
…race-go into config-revamp/peer-service
… map Avoid a breaking API change in this PR. The TracerConf cleanup (removing PeerServiceMappings entirely) will be handled in a follow-up PR. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Co-Authored-By: Claude Opus 4.6 <[email protected]>
…race-go into config-revamp/peer-service
|
✅ Tests 🎉 All green!❄️ No new flaky tests detected 🎯 Code Coverage (details) 🔗 Commit SHA: e62b453 | Docs | Datadog PR Page | Was this helpful? React with 👍/👎 or give us feedback! |
BenchmarksBenchmark execution time: 2026-04-10 14:46:13 Comparing candidate commit e62b453 in PR branch Found 0 performance improvements and 3 performance regressions! Performance is the same for 212 metrics, 9 unstable metrics.
|
## Summary - Adds a public `Config.SpanAttributeSchemaVersion()` getter on `internal/config.Config`. The field itself was already declared and initialised by `loadConfig`; this just exposes a public accessor. - Removes the duplicate `spanAttributeSchemaVersion` field from the legacy tracer `config` struct and the `c.spanAttributeSchemaVersion = int(namingschema.GetVersion())` assignment in `newConfig`. - Rewires the two readers (`telemetry.go` startup config and `tracer.go` `StartSpan` hot path) to read through the new getter. - Getter avoids `defer` because it is read once per local-root span — matches the hot-path pattern from the peer-service migration (#4653) and the README guidance. - `namingschema.LoadFromEnv()` is preserved: contrib packages still consume the namingschema global via `GetVersion()`. Jira: [APMAPI-1887](https://datadoghq.atlassian.net/browse/APMAPI-1887) EPIC: [APMAPI-1881](https://datadoghq.atlassian.net/browse/APMAPI-1881) — Go Config Revamp: Migrate tracer ## Test plan - [x] `go build ./...` - [x] `go vet ./ddtrace/tracer/... ./internal/config/...` - [x] `go test ./internal/config/...` - [x] `go test ./ddtrace/tracer/...` (full suite) - [x] Existing `attribute_schema_is_set_v0/v1/wrong_value` (tracer_test.go) and `defaults-with-schema-v1` (option_test.go) pass without modification. [APMAPI-1887]: https://datadoghq.atlassian.net/browse/APMAPI-1887?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [APMAPI-1881]: https://datadoghq.atlassian.net/browse/APMAPI-1881?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ Co-authored-by: daniil.stasiuk <[email protected]>
### What does this PR do? - Adds a public `Config.MaxTagsHeaderLen()` getter on `internal/config.Config`. - Initializes the field in `loadConfig` from `DD_TRACE_X_DATADOG_TAGS_MAX_LENGTH`, preserving the existing clamping semantics (negative → 0; > `MaxPropagatedTagsLength` → clamped down to that value). - Adds `DefaultMaxTagsHeaderLen` and `MaxPropagatedTagsLength` exported constants in `internal/config`. - Removes the duplicate env resolution from `tracer/option.go` and the `defaultMaxTagsHeaderLen` / `maxPropagatedTagsLength` constants there. - The propagator is now constructed using `c.internalConfig.MaxTagsHeaderLen()` instead of locally re-reading the env var. ### Motivation Continued config-migration work: move env resolution of `DD_TRACE_X_DATADOG_TAGS_MAX_LENGTH` into `internal/config` to match the pattern established by recent migrations (e.g. #4711, #4653). --------- Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
What does this PR do? Coninues the following PR: #4483
PR was created due to permission issues, I was unable to merge the fork branch initially.
Motivation
Reviewer's Checklist
make lintlocally.make testlocally.make generatelocally.make fix-moduleslocally.Unsure? Have a question? Request a review!