Skip to content

Enable DSM tests for PHP - #8202

Open
arjunguhaswe wants to merge 9 commits into
mainfrom
arjun.guha/php-dsm-system-tests
Open

arjunguhaswe wants to merge 9 commits into
mainfrom
arjun.guha/php-dsm-system-tests

Conversation

@arjunguhaswe

@arjunguhaswe arjunguhaswe commented Oct 27, 2026 •

Copy link
Copy Markdown

What

Enables the DSM tests for PHP, for the DSM support added by DataDog/dd-trace-php#4380 (merged; ships in 1.27.0): Kafka (with kafka_cluster_id), RabbitMQ direct, topic and fanout exchanges, and base64 context injection and extraction.

How

  • weblogs/plain/dsm.php adds the /dsm, /dsm/inject and /dsm/extract endpoints to every php-fpm and apache-mod weblog. Kafka goes through php-rdkafka and RabbitMQ through php-amqplib. Each request waits for its own message before answering ok.
  • The Kafka consumer is assigned its partition instead of subscribing, so a group rebalance can't eat into Test_DsmKafka's 5 s default timeout. Its checkpoints still carry the group.
  • The PHP base images get php-rdkafka (the ondrej package on php-fpm, built from source on apache-mod) and php-amqplib. The base-image lock and mirror files are regenerated.
  • DD_DATA_STREAMS_ENABLED=true is set in Integrations.weblog_env. The other DSM tracers already set it in their Dockerfiles.
  • The manifest enables these from v1.27.0, except on laravel11x and symfony7x, which don't have the endpoint. Manual checkpoints, HTTP, SQS, SNS and Kinesis stay missing_feature.

Testing

  • Against dd-trace-php master (1.27.0+dev.aad0ff19, with dd-trace-php#4380 merged), on php-fpm-8.2: all 6 enabled DSM tests pass.
  • Against dd-trace-php#4380 at ab5998e35, on php-fpm-8.2 and apache-mod-8.0: the same 6 pass, and the full INTEGRATIONS scenario has no failures.
  • With leftover messages already in the RabbitMQ queues, the endpoints skip them and still consume their own.
  • All 25 PHP base images built on amd64 and arm64.

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

CODEOWNERS have been resolved as:

utils/build/docker/php/weblogs/plain/dsm.php                            @DataDog/system-tests-reviewers
manifests/php.yml                                                       @DataDog/system-tests-reviewers
mirror_images.lock.yaml                                                 @DataDog/system-tests-core
mirror_images.yaml                                                      @DataDog/system-tests-core
utils/_context/_scenarios/integrations.py                               @DataDog/system-tests-core
utils/build/docker/base-images.lock.json                                @DataDog/system-tests-reviewers
utils/build/docker/php/apache-mod/build.sh                              @DataDog/system-tests-reviewers
utils/build/docker/php/common/php.ini                                   @DataDog/system-tests-reviewers
utils/build/docker/php/common/rewrite-rules.conf                        @DataDog/system-tests-reviewers
utils/build/docker/php/php-fpm/build.sh                                 @DataDog/system-tests-reviewers
utils/build/docker/php/weblogs/plain/composer.gte8.2.json               @DataDog/system-tests-reviewers
utils/build/docker/php/weblogs/plain/composer.json                      @DataDog/system-tests-reviewers

@datadog-datadog-prod-us1

datadog-datadog-prod-us1 Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Pipelines  Tests

❌ Errors

Your PR has failed checks. Please review the issues below and take necessary action before merging.

🚦 2 Pipeline jobs failed

Testing the test | System Tests (php, prod) / End-to-end #2 / apache-mod-7.1-zts 2 — 🔧 Needs a code fix, caused by this PR

View more details · View in GitHub Actions

Testing the test | all-jobs-are-green

View more details · View in GitHub Actions

ℹ️ Info

No other issues found (see more)

🧪 All tests passed
❄️ No new flaky tests detected

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 9217985 | Docs | View more details | Give us feedback!

@arjunguhaswe
arjunguhaswe marked this pull request as ready for review October 30, 2026 05:07
@arjunguhaswe
arjunguhaswe requested review from a team as code owners October 30, 2026 05:07
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-30T05:14:40.315004Z aeb0812 Draft marked ready
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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

Copy link
Copy Markdown

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: aeb08123ef

ℹ️ 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".

ENV DD_TRACE_GENERATE_ROOT_SPAN=1
ENV DD_TRACE_AGENT_FLUSH_AFTER_N_REQUESTS=0
ENV DD_TRACE_HEADER_TAGS=user-agent
ENV DD_DATA_STREAMS_ENABLED=true

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Scope data-streams enablement to INTEGRATIONS

When either PHP weblog runs in DEFAULT, AppSec, telemetry, or any other scenario, this image-level setting still enables DSM and therefore changes tracer behavior outside the scenario being activated here. Since all new DSM tests are restricted to @scenarios.integrations, set DD_DATA_STREAMS_ENABLED in Integrations.weblog_env instead; the same issue also applies to php-fpm.base.Dockerfile.

AGENTS.md reference: AGENTS.md:L34-L36

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Agreed. 2cc141f moves DD_DATA_STREAMS_ENABLED from the PHP base Dockerfiles to Integrations.weblog_env, so DSM is on only in INTEGRATIONS. The other tracers with DSM tests already set it in their weblog Dockerfiles, so this changes nothing for them. Locally, the DSM tests still pass on php-fpm-8.2 and apache-mod-8.0 with the variable coming from the scenario.

Comment on lines +111 to +113
$channel->basic_consume($queue, '', false, true, false, false, function () use ($queue, &$pending) {
unset($pending[$queue]);
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Match RabbitMQ deliveries to the current request

When the reusable RabbitMQ container has a queued message from an earlier or timed-out request, this callback clears $pending for that queue without checking the payload, so the endpoint can return ok without consuming the message it just published and the DSM assertion can be satisfied by stale propagation context. This is especially likely for the topic case because queue 3 matches two routing keys while only one delivery is required; publish a unique request payload and clear a queue only after receiving that payload.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed in 2cc141f. Each request publishes a unique body, and a queue only counts as consumed once that body arrives, so messages left by an earlier request are consumed and skipped. I checked this locally by seeding a message with no DSM context into the direct queue and the three fanout queues, then calling the endpoints. Both returned ok, the queues ended empty, and the agent received the leftovers' checkpoints (parent 0) alongside the expected ones parented to the publish.

@cbeauchesne cbeauchesne left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

You'll also need to remove the branch selector, and rebase the PR.

@arjunguhaswe
arjunguhaswe force-pushed the arjun.guha/php-dsm-system-tests branch from 6e72a51 to 3782005 Compare November 2, 2026 17:57
@arjunguhaswe arjunguhaswe changed the title Enable DSM tests for PHP [php@feat/arjun.guha/dsm-php-integration] Enable DSM tests for PHP Nov 2, 2026
@arjunguhaswe
arjunguhaswe force-pushed the arjun.guha/php-dsm-system-tests branch from 217b74a to 55e1e66 Compare November 6, 2026 19:45
arjunguhaswe and others added 8 commits November 6, 2026 15:44
Add a /dsm endpoint to the plain PHP weblog (php-fpm and apache-mod):
Kafka through php-rdkafka, RabbitMQ direct, topic and fanout exchanges
through php-amqplib, and /dsm/inject and /dsm/extract. Install the
clients in the base images, enable DSM there, and enable the tests from
1.27.0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dd-trace-php#4380 now tags Kafka checkpoints with the cluster id, so PHP
runs test_dsm_kafka, and test_dsm_kafka_without_cluster_id is irrelevant
as for the other tracers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Set DD_DATA_STREAMS_ENABLED in Integrations.weblog_env instead of the PHP
base images, so DSM is on only in the scenario that tests it. The other
tracers with DSM tests already enable it in their weblogs.

The RabbitMQ endpoints now wait for the message they published, and
skip messages an earlier request left in a queue.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The apache-mod base images now download php-rdkafka's release tarball
from PECL, as dd-trace-php's CI images do, retry the download, and check
its sha256 before building it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Resolve digests for the PHP base images that build_base_images published,
and restore datadog/agent:latest, which a local binaries/agent-image pin
had replaced in mirror_images.yaml.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@arjunguhaswe
arjunguhaswe force-pushed the arjun.guha/php-dsm-system-tests branch from 52f9d98 to 55b63ca Compare November 6, 2026 20:45
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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