You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Companion PHP evaluation-metrics work needs FFE metrics to follow the sidecar architecture used by the rest of the tracer: configure endpoints once on the session, then send typed sidecar actions without carrying endpoint strings on every flush.
The previous FFE metrics path accepted an OTLP endpoint alongside each metrics batch. That diverged from the normal Endpoint flow, made test-session-token propagation easy to miss, and forced PHP to keep fetching endpoint configuration during request flushes.
Add an optional OTLP metrics Endpoint to sidecar session configuration.
Thread that endpoint through ddog_sidecar_session_set_config and session state.
Dispatch SidecarAction::FfeEvaluationMetrics through the session's configured OTLP metrics endpoint instead of an endpoint passed with each metrics batch.
Preserve request-replayer test-session routing by inheriting the agent endpoint test_token when the OTLP metrics endpoint does not already have one.
Update runtime test-token changes so the configured OTLP metrics endpoint is updated with the rest of the session endpoints.
Extend the sidecar FFE metrics dispatch test to assert the outgoing OTLP request carries x-datadog-test-session-token through Endpoint standard headers.
Decisions
FFE metrics remain caller-driven. This PR does not make shared evaluator calls auto-emit metrics, so SDKs that still log metrics in host language implementations can continue to coexist without double counting.
The sidecar owns metrics transport, aggregation, OTLP/protobuf encoding, and endpoint/header handling. PHP remains responsible for constructing the appropriate OTLP metrics endpoint from its existing configuration resolver and supplying it once during sidecar session setup.
The test-session-token behavior is intentionally implemented through Endpoint, not by manually adding FFE-specific headers. Production endpoints normally have no test token, so production behavior is unchanged.
Validation
Local targeted test:
cargo test -p datadog-sidecar ffe_metric_actions_dispatch_without_registered_application
Result: passed locally.
Negative validation during review:
Removing only the mock header matcher still allows the request through, but stops proving token propagation.
Keeping the matcher and removing Endpoint.test_token fails with a missing x-datadog-test-session-token header.
Restoring both passes, confirming the request uses Endpoint standard headers.
CI on commit 091c98d reports all tests passed and no new flaky tests.
This report tracks Clippy allow annotations for specific rules, showing how they've changed in this PR. Decreasing the number of these annotations generally improves code quality.
❌ Patch coverage is 62.74510% with 19 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.47%. Comparing base (b2ef19f) to head (091c98d). ⚠️ Report is 1 commits behind head on main.
leoromanovsky
changed the title
fix(sidecar): preserve FFE metrics test token
fix(sidecar): configure OTLP endpoint for FFE metrics
Jun 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Companion PHP evaluation-metrics work needs FFE metrics to follow the sidecar architecture used by the rest of the tracer: configure endpoints once on the session, then send typed sidecar actions without carrying endpoint strings on every flush.
The previous FFE metrics path accepted an OTLP endpoint alongside each metrics batch. That diverged from the normal
Endpointflow, made test-session-token propagation easy to miss, and forced PHP to keep fetching endpoint configuration during request flushes.Design context: https://docs.google.com/document/d/1NvMfTpZWLBlFmEFNjdnlMyeVpy5l7KD8qujGFco6w2w/edit?tab=t.0
Companion PHP PR: DataDog/dd-trace-php#3911
Changes
Endpointto sidecar session configuration.ddog_sidecar_session_set_configand session state.SidecarAction::FfeEvaluationMetricsthrough the session's configured OTLP metrics endpoint instead of an endpoint passed with each metrics batch.test_tokenwhen the OTLP metrics endpoint does not already have one.x-datadog-test-session-tokenthroughEndpointstandard headers.Decisions
FFE metrics remain caller-driven. This PR does not make shared evaluator calls auto-emit metrics, so SDKs that still log metrics in host language implementations can continue to coexist without double counting.
The sidecar owns metrics transport, aggregation, OTLP/protobuf encoding, and endpoint/header handling. PHP remains responsible for constructing the appropriate OTLP metrics endpoint from its existing configuration resolver and supplying it once during sidecar session setup.
The test-session-token behavior is intentionally implemented through
Endpoint, not by manually adding FFE-specific headers. Production endpoints normally have no test token, so production behavior is unchanged.Validation
Local targeted test:
cargo test -p datadog-sidecar ffe_metric_actions_dispatch_without_registered_applicationResult: passed locally.
Negative validation during review:
Endpoint.test_tokenfails with a missingx-datadog-test-session-tokenheader.Endpointstandard headers.CI on commit
091c98dreports all tests passed and no new flaky tests.