Skip to content

feat: add support for proxying DSM requests#131

Open
jeastham1993 wants to merge 3 commits into
mainfrom
james.eastham/support-dsm
Open

feat: add support for proxying DSM requests#131
jeastham1993 wants to merge 3 commits into
mainfrom
james.eastham/support-dsm

Conversation

@jeastham1993
Copy link
Copy Markdown

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.

Copilot AI review requested due to automatic review settings May 14, 2026 07:08
@jeastham1993 jeastham1993 requested a review from a team as a code owner May 14, 2026 07:08
@jeastham1993 jeastham1993 requested review from Lewis-E and removed request for a team May 14, 2026 07:08
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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_stats handling, /info endpoint 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;
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.

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.

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: 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) {
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 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 👍 / 👎.

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.

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.

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: 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".

Comment on lines +115 to +119
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());
}
}
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 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 👍 / 👎.

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.

2 participants