Skip to content

Conversation

@e-n-0
Copy link
Member

@e-n-0 e-n-0 commented Oct 23, 2025

What does this PR do?

This PR enables body processing by default for all proxies integrations except for GCP Service Extensions.

The challenge of this PR was to enable body processing by default for Envoy based proxies but excluding GCP Service Extension from this. As the final integration type is detected during runtime (based on metadata set inside the gRPC stream of requests), the message processor configuration needed to be updated after its initialization.
The integration type is chose either at startup via specification in the code (if integration is different than the default GCP Service Extension) or when the first request is received.

This PR changes the public api for ProcessorConfig of the proxy package, but as this is only used internally by contribs and we have no current usage of this module outside, we accept this breaking change.

The default value set for body processing is 10MB.

Note:

  • The default body processing value for gateway api have been changed from 5MB to 10MB.

Why excluding GCP Service Extension

We currently have an ongoing support case where some request could provoke some backend timeout when body processing is enabled using GCP Service Extension. This integration will also be updated later when this case will be closed.

Motivation

Body processing needs to be enabled for the GA of the AAP Envoy integration.

Reviewer's Checklist

  • Changed code has unit tests for its functionality at or near 100% coverage.
  • System-Tests covering this feature have been added and enabled with the va.b.c-dev version tag.
  • There is a benchmark for any new code, or changes to existing code.
  • If this interacts with the agent in a new way, a system test has been added.
  • New code is free of linting errors. You can check this by running ./scripts/lint.sh locally.
  • Add an appropriate team label so this PR gets put in the right place for the release notes.
  • Non-trivial go.mod changes, e.g. adding new modules, are reviewed by @DataDog/dd-trace-go-guild.

Unsure? Have a question? Request a review!

@github-actions github-actions bot added the apm:ecosystem contrib/* related feature requests or bugs label Oct 23, 2025
@e-n-0 e-n-0 force-pushed the flavien/proxies/default-body-processing branch from 6a965ca to 5d0feb8 Compare October 23, 2025 16:02
@e-n-0 e-n-0 added appsec and removed apm:ecosystem contrib/* related feature requests or bugs labels Oct 23, 2025
@pr-commenter
Copy link

pr-commenter bot commented Oct 23, 2025

Benchmarks

Benchmark execution time: 2025-10-24 16:30:09

Comparing candidate commit 48767a0 in PR branch flavien/proxies/default-body-processing with baseline commit 3d45ade in branch main.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 24 metrics, 0 unstable metrics.

@datadog-datadog-prod-us1
Copy link

datadog-datadog-prod-us1 bot commented Oct 23, 2025

⚠️ Tests

⚠️ Warnings

❄️ 1 New flaky test detected

TestHealthMetricsRaceCondition from github.com/DataDog/dd-trace-go/v2/ddtrace/tracer (Datadog)
Failed

=== RUN   TestHealthMetricsRaceCondition
    metrics_test.go:272: 
        	Error Trace:	/home/runner/work/dd-trace-go/dd-trace-go/ddtrace/tracer/metrics_test.go:272
        	Error:      	Condition never satisfied
        	Test:       	TestHealthMetricsRaceCondition
    metrics_test.go:274: 
        	Error Trace:	/home/runner/work/dd-trace-go/dd-trace-go/ddtrace/tracer/metrics_test.go:274
        	Error:      	Should be true
...

ℹ️ Info

🧪 All tests passed

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 48767a0 | Docs | Was this helpful? Give us feedback!

@e-n-0 e-n-0 force-pushed the flavien/proxies/default-body-processing branch from b363d29 to d31115a Compare October 24, 2025 13:02
@e-n-0 e-n-0 marked this pull request as ready for review October 24, 2025 14:38
@e-n-0 e-n-0 requested a review from a team as a code owner October 24, 2025 14:38

setup := func() (envoyextproc.ExternalProcessorClient, mocktracer.Tracer, func()) {
rig, err := newEnvoyAppsecRig(t, EnvoyIntegration, false, 0)
rig, err := newEnvoyAppsecRig(t, GCPServiceExtensionIntegration, false, nil)
Copy link
Member Author

@e-n-0 e-n-0 Oct 24, 2025

Choose a reason for hiding this comment

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

The integration was changed only to have a body parsing disabled for the tests

@e-n-0 e-n-0 force-pushed the flavien/proxies/default-body-processing branch from d31115a to e873ce2 Compare October 24, 2025 14:51
Comment on lines 58 to 62
// Set default body parsing size limit if not specified for non-default integrations
if config.BodyParsingSizeLimit == nil {
defaultBody := proxy.DefaultBodyParsingSizeLimit
config.BodyParsingSizeLimit = &defaultBody
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think at this point the integration is not set properly in most cases and since GCP is the default value...

Copy link
Member Author

@e-n-0 e-n-0 Oct 24, 2025

Choose a reason for hiding this comment

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

In the end yes it's not that useful. Removed in 48767a0

Comment on lines 60 to 61
defaultBody := proxy.DefaultBodyParsingSizeLimit
config.BodyParsingSizeLimit = &defaultBody
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
defaultBody := proxy.DefaultBodyParsingSizeLimit
config.BodyParsingSizeLimit = &defaultBody
config.BodyParsingSizeLimit = &
proxy.DefaultBodyParsingSizeLimit

Copy link
Member Author

Choose a reason for hiding this comment

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

proxy.DefaultBodyParsingSizeLimit is a const, I can't directly take its address


const (
// DefaultBodyParsingSizeLimit is the default number of bytes parsed for body analysis.
DefaultBodyParsingSizeLimit = 10_000_000 // 10MB
Copy link
Contributor

Choose a reason for hiding this comment

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

do you mind doing it in power of two ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Applied in f61a2f2


mp.firstRequest.Do(func() {
if mp.BodyParsingSizeLimit == nil {
mp.computedBodyParsingSizeLimit = req.BodyParsingSizeLimit(ctx)
Copy link
Contributor

Choose a reason for hiding this comment

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

There is a data race here

Copy link
Member Author

Choose a reason for hiding this comment

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

Are you sure there is a data race here? The value of computedBodyParsingSizeLimit is only set once with the firstRequest.Do.

Copy link
Member Author

Choose a reason for hiding this comment

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

Changed using atomic value in fb33a1e

@e-n-0 e-n-0 requested a review from eliottness October 24, 2025 16:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants