Skip to content

Fix assumptions about what a top_level span is#3916

Open
bwoebi wants to merge 2 commits into
masterfrom
bob/fix-span-stats
Open

Fix assumptions about what a top_level span is#3916
bwoebi wants to merge 2 commits into
masterfrom
bob/fix-span-stats

Conversation

@bwoebi
Copy link
Copy Markdown
Collaborator

@bwoebi bwoebi commented May 25, 2026

Otherwise span stats will be broken for nested services.

Also properly handling version propagation, its removal according to UST was too aggressive until now.

@bwoebi bwoebi requested review from a team as code owners May 25, 2026 15:26
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 531586746b

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread ext/span_stats.c
Comment on lines +394 to +397
zval *root_version_zv = &span->root->property_version;
ZVAL_DEREF(root_version_zv);
if (Z_TYPE_P(root_version_zv) == IS_STRING && ZSTR_LEN(Z_STR_P(root_version_zv)) > 0) {
version_zstr = Z_STR_P(root_version_zv);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Use resolved version when keying concentrator writes

ddtrace_feed_span_to_concentrator now ignores pre->version and reads only span->root->property_version when it is already a string, which drops versions that were resolved via deprecated meta["version"] (still supported in ddtrace_precompute_span) or via non-string values converted during precompute. In those cases spans are emitted with a version tag but stats are keyed with an empty version, causing version-level stats to be mis-grouped or split from trace data.

Useful? React with 👍 / 👎.

@datadog-prod-us1-3
Copy link
Copy Markdown

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

Pipelines  Tests

Fix all issues with BitsAI

⚠️ Warnings

🚦 47 Pipeline jobs failed

DataDog/apm-reliability/dd-trace-php | ASAN test_c: [7.4, arm64]   View in Datadog   GitLab

🔧 Fix in code (Fix with Cursor). Command terminated with exit code 2 during ASAN test execution.

🧪 1 Test failed

tmp/build_extension/tests/ext/ust.phpt (Foo) from PHP.tmp.build_extension.tests.ext   View in Datadog (Fix with Cursor)
030+       ["version"]=>
031+       string(5) "5.2.0"

DataDog/apm-reliability/dd-trace-php | ASAN test_c: [8.5, arm64]   View in Datadog   GitLab

🔧 Fix in code (Fix with Cursor). Test command failed with exit code 2 due to make error in the test_c target.

🧪 1 Test failed

tmp/build_extension/tests/ext/ust.phpt (Foo) from php.tmp.build_extension.tests.ext   View in Datadog (Fix with Cursor)
--
           string(8) "env_test"
           ["runtime-id"]=>
           string(36) "%s"
030+       ["version"]=>
031+       string(5) "5.2.0"
         }
         ["metrics"]=>
         array(%d) {
--

DataDog/apm-reliability/dd-trace-php | System Tests: [parametric]   View in Datadog   GitLab

🔧 Fix in code (Fix with Cursor). 1 failed test due to assertion error: assert 'version' not in span2['meta']

🧪 1 Test failed

tests.parametric.test_config_consistency.Test_Config_UnifiedServiceTagging.test_specific_version[library_env0, parametric-php] from system_tests_suite   View in Datadog (Fix with Cursor)
AssertionError: assert 'version' not in {'_dd.p.dm': '-0', '_dd.p.tid': '6a14715c00000000', '_dd.tags.process': 'entrypoint.basedir:binaries,entrypoint.name:s...t.type:script,entrypoint.workdir:binaries,runtime.sapi:cli', 'runtime-id': '72b10d8d-601e-4ee5-91ab-6602753638a6', ...}

self = <tests.parametric.test_config_consistency.Test_Config_UnifiedServiceTagging object at 0x7fd1ae5894c0>
test_agent = <utils.docker_fixtures._test_agent.TestAgentAPI object at 0x7fd185bdb2c0>
test_library = <utils.docker_fixtures._test_clients._test_client_parametric.ParametricTestClientApi object at 0x7fd1865abb30>

    @parametrize("library_env", [{"DD_SERVICE": "version_test", "DD_VERSION": "5.2.0"}])
    def test_specific_version(self, test_agent: TestAgentAPI, test_library: APMLibrary):
        with test_library:
            with test_library.dd_start_span(name="s1") as s1:
...

View all 47 failed jobs.

ℹ️ Info

No other issues found (see more)

❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 60.70% (-0.05%)

Useful? React with 👍 / 👎

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

@pr-commenter
Copy link
Copy Markdown

pr-commenter Bot commented May 25, 2026

Benchmarks [ tracer ]

Benchmark execution time: 2026-05-25 16:40:49

Comparing candidate commit 5315867 in PR branch bob/fix-span-stats with baseline commit 0fb4c56 in branch master.

Found 0 performance improvements and 14 performance regressions! Performance is the same for 178 metrics, 2 unstable metrics.

scenario:PDOBench/benchPDOOverhead

  • 🟥 execution_time [+11.019µs; +13.417µs] or [+4.477%; +5.452%]

scenario:PDOBench/benchPDOOverhead-opcache

  • 🟥 execution_time [+12.974µs; +14.846µs] or [+5.316%; +6.083%]

scenario:PDOBench/benchPDOOverheadWithDBM

  • 🟥 execution_time [+10.846µs; +13.490µs] or [+4.412%; +5.488%]

scenario:PDOBench/benchPDOOverheadWithDBM-opcache

  • 🟥 execution_time [+12.006µs; +14.084µs] or [+4.915%; +5.766%]

scenario:PHPRedisBench/benchRedisOverhead

  • 🟥 execution_time [+51.400µs; +69.178µs] or [+5.375%; +7.234%]

scenario:PHPRedisBench/benchRedisOverhead-opcache

  • 🟥 execution_time [+56.329µs; +71.108µs] or [+5.632%; +7.110%]

scenario:SpanBench/benchDatadogAPI

  • 🟥 execution_time [+4.812µs; +6.296µs] or [+7.480%; +9.788%]

scenario:SpanBench/benchDatadogAPI-opcache

  • 🟥 execution_time [+4.909µs; +5.752µs] or [+7.595%; +8.900%]

scenario:SpanBench/benchOpenTelemetryInteroperability

  • 🟥 execution_time [+4.724µs; +7.261µs] or [+2.505%; +3.850%]

scenario:SpanBench/benchOpenTelemetryInteroperability-opcache

  • 🟥 execution_time [+81.080µs; +85.228µs] or [+28.622%; +30.086%]

scenario:TraceFlushBench/benchFlushTrace

  • 🟥 execution_time [+53.371µs; +91.629µs] or [+4.570%; +7.846%]

scenario:TraceFlushBench/benchFlushTrace-opcache

  • 🟥 execution_time [+71.057µs; +93.143µs] or [+6.066%; +7.952%]

scenario:TraceSerializationBench/benchSerializeTrace

  • 🟥 execution_time [+94.875µs; +111.725µs] or [+22.730%; +26.767%]

scenario:TraceSerializationBench/benchSerializeTrace-opcache

  • 🟥 execution_time [+96.650µs; +110.750µs] or [+27.925%; +32.000%]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant