feat: add support for proxying DSM requests#131
Conversation
There was a problem hiding this comment.
Pull request overview
Adds Data Streams Monitoring request proxying to the serverless mini trace agent, alongside the existing profiling proxy path.
Changes:
- Adds DSM intake configuration and default/custom endpoint construction.
- Introduces a shared proxy request kind for profiling and DSM forwarding.
- Adds
/v0.1/pipeline_statshandling,/infoendpoint advertising, and integration coverage.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
crates/datadog-trace-agent/src/config.rs |
Adds DSM intake endpoint configuration and tests. |
crates/datadog-trace-agent/src/mini_agent.rs |
Routes DSM requests through the generic proxy handler and advertises the endpoint. |
crates/datadog-trace-agent/src/proxy_flusher.rs |
Adds proxy request kinds and chooses API keys/headers per proxy type. |
crates/datadog-trace-agent/src/trace_processor.rs |
Updates test config with DSM intake. |
crates/datadog-trace-agent/tests/integration_test.rs |
Adds DSM endpoint setup, verification helper, and TCP proxy integration test. |
| @@ -148,7 +163,7 @@ impl ProxyFlusher { | |||
| let url = r.url().to_string(); | |||
| let status = r.status(); | |||
| let body = r.text().await; | |||
There was a problem hiding this comment.
Updated this so the proxy flusher no longer reads or logs the upstream response body on non-success responses. It now logs the status, URL, and elapsed time, with the body explicitly omitted to avoid leaking any sensitive request details.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 18f2f0e749
ℹ️ 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".
| return Err(format!("Failed to parse additional tags header: {}", e)); | ||
| } | ||
| }; | ||
| if matches!(request.kind, ProxyRequestKind::Profiling) { |
There was a problem hiding this comment.
Preserve DSM additional tags when proxying
When request.kind is DataStreams, this guard skips X-Datadog-Additional-Tags entirely, so proxied /v0.1/pipeline_stats payloads reach intake without the metadata the trace-agent normally adds for pipeline stats (for example host, default_env, and agent/orchestrator tags). In serverless DSM scenarios this can make the backend unable to attribute or filter the pipeline stats correctly even though the proxy returns 200 after buffering.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Addressed this by preserving any incoming X-Datadog-Additional-Tags on proxied DSM requests and merging in the serverless tags this mini-agent already knows how to add, instead of skipping the header for DataStreams requests.
That means DSM requests now keep upstream tags like host / default_env and also carry the serverless metadata we add locally, such as functionname, _dd.origin, and configured function tags. I also updated the integration test to assert the merged tag behavior on /v0.1/pipeline_stats.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0a5c21a8a7
ℹ️ 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".
| if let Some(function_tags) = self.config.tags.function_tags() { | ||
| for tag in Self::parse_additional_tags(function_tags) { | ||
| Self::push_unique_tag(&mut tags, tag.to_string()); | ||
| } | ||
| } |
There was a problem hiding this comment.
Include DD_ENV in DSM additional tags
When a serverless app is configured with the standard DD_ENV but does not duplicate env:<value> in DD_TAGS, DSM requests posted directly to this mini-agent are forwarded without any default environment tag because this merge only reads config.tags.function_tags(). The trace-agent pipeline-stats proxy adds default_env to X-Datadog-Additional-Tags, so these serverless pipeline stats can arrive unattributed to the configured environment; please add config.env (when set) to the DSM additional tags instead of relying on DD_TAGS to carry it.
Useful? React with 👍 / 👎.
What does this PR do?
Add support for proxying DSM requests to support Datadog data streams monitoring for Azure and GCP use cases. It follows the same conventions as other proxy requests inside this crate, as well as replicating the way DSM works in botttlecap.
Motivation
Several potential DSM customers have recently asked for better support for DSM/Azure Service Bus/Azure Functions. This functionality is a blocker to those customers onboarding.
Additional Notes
Review from DSM team would be helpful.
Describe how to test/QA your changes
Added additional integration tests. If someone can confirm how to manually build and test inside Azure Functions I can do that as well.