Skip to content

Add tests for _dd.base_service#6596

Merged
amarziali merged 5 commits intomainfrom
andrea.marziali/base_service
Mar 26, 2026
Merged

Add tests for _dd.base_service#6596
amarziali merged 5 commits intomainfrom
andrea.marziali/base_service

Conversation

@amarziali
Copy link
Contributor

@amarziali amarziali commented Mar 26, 2026

Motivation

Adds end-to-end and parametric tests to verify that tracers correctly set the _dd.base_service meta tag on spans whose service name differs from the global configured service (DD_SERVICE).

End-to-end tests (tests/integrations/test_base_service.py):

  • Test_BaseService_RootSpan — verifies that the root/entry span never carries _dd.base_service (its service is the global service)
  • Test_BaseService_SqlSpan — verifies that SQL spans produced by database integrations carry _dd.base_service pointing back to the global service, using the /rasp/sqli endpoint (since that endpoint will create an override systematically)

Parametric tests (tests/parametric/test_tracer.py):

  • Test_TracerBaseService::test_base_service_set_when_service_overridden — creates a child span with an overridden service name and asserts _dd.base_service is set to DD_SERVICE
  • Test_TracerBaseService::test_base_service_absent_when_service_not_overridden — asserts _dd.base_service is absent when the span service matches DD_SERVICE

*Notes: it seems that in Ruby that's not correctly implemented since the simple parametric test case is not passing

Changes

Workflow

  1. ⚠️ Create your PR as draft ⚠️
  2. Work on you PR until the CI passes
  3. Mark it as ready for review
    • Test logic is modified? -> Get a review from RFC owner.
    • Framework is modified, or non obvious usage of it -> get a review from R&P team

🚀 Once your PR is reviewed and the CI green, you can merge it!

🛟 #apm-shared-testing 🛟

Reviewer checklist

  • Anything but tests/ or manifests/ is modified ? I have the approval from R&P team
  • A docker base image is modified?
    • the relevant build-XXX-image label is present
  • A scenario is added, removed or renamed?

@github-actions
Copy link
Contributor

github-actions bot commented Mar 26, 2026

CODEOWNERS have been resolved as:

tests/integrations/test_base_service.py                                 @DataDog/system-tests-core
manifests/cpp.yml                                                       @DataDog/dd-trace-cpp
manifests/cpp_httpd.yml                                                 @DataDog/dd-trace-cpp
manifests/cpp_nginx.yml                                                 @DataDog/dd-trace-cpp
manifests/java.yml                                                      @DataDog/asm-java @DataDog/apm-java
manifests/nodejs.yml                                                    @DataDog/dd-trace-js
manifests/php.yml                                                       @DataDog/apm-php @DataDog/asm-php
manifests/ruby.yml                                                      @DataDog/ruby-guild @DataDog/asm-ruby
tests/parametric/test_tracer.py                                         @DataDog/system-tests-core @DataDog/apm-sdk-capabilities
utils/_features.py                                                      @DataDog/system-tests-core

@datadog-official
Copy link

datadog-official bot commented Mar 26, 2026

✅ Tests

🎉 All green!

❄️ No new flaky tests detected
🧪 All tests passed

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 4e192ba | Docs | Datadog PR Page | Was this helpful? React with 👍/👎 or give us feedback!

@amarziali amarziali force-pushed the andrea.marziali/base_service branch from 28f5924 to 4e192ba Compare March 26, 2026 10:44
@amarziali amarziali marked this pull request as ready for review March 26, 2026 10:45
@amarziali amarziali requested review from a team as code owners March 26, 2026 10:45
@amarziali amarziali requested review from anna-git, cataphract, jandro996, manuel-alvarez-alvarez and raphaelgavache and removed request for a team March 26, 2026 10:45
Copy link

@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: 4e192baaca

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +240 to +241
@parametrize("library_env", [{"DD_SERVICE": "global-service"}])
def test_base_service_set_when_service_overridden(self, test_agent: TestAgentAPI, test_library: APMLibrary) -> None:

Choose a reason for hiding this comment

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

P1 Badge Skip DD_SERVICE-dependent base_service test where unsupported

This new test assumes DD_SERVICE is reliably applied (_dd.base_service must equal global-service), but many libraries already declare that same prerequisite as unsupported in existing manifests (for example tests/parametric/test_tracer.py::Test_TracerUniversalServiceTagging::test_tracer_service_name_environment_variable is marked missing_feature in manifests/nodejs.yml and manifests/dotnet.yml because the test client sets an empty service). Adding this class without corresponding manifest gating will make parametric runs fail for those libraries for a known pre-existing limitation rather than the feature under test.

Useful? React with 👍 / 👎.

nccatoni

This comment was marked as duplicate.

@nccatoni nccatoni self-requested a review March 26, 2026 13:13
Copy link
Collaborator

@nccatoni nccatoni left a comment

Choose a reason for hiding this comment

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

LGTM (for @DataDog/system-tests-core) but you should get a review from someone familiar with the feature

@amarziali
Copy link
Contributor Author

LGTM (for @DataDog/system-tests-core) but you should get a review from someone familiar with the feature

I think I'm the most familiar one today :)

@amarziali amarziali merged commit 4188d2d into main Mar 26, 2026
877 of 879 checks passed
@amarziali amarziali deleted the andrea.marziali/base_service branch March 26, 2026 14:12
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.

3 participants