opentelemetry-exporter-otlp-proto-http: add max request size limit to OTLP HTTP exporters#5369
Open
Krishnachaitanyakc wants to merge 2 commits into
Open
Conversation
herin049
requested changes
Jun 30, 2026
… OTLP HTTP exporters Implements the client side of opentelemetry-proto#782: serialized OTLP/HTTP requests larger than a configurable limit are dropped before sending, measured before compression. Adds a max_request_size keyword-only argument to the trace, log, and metric HTTP exporters. Default 64 MiB; 0 (or any non-positive value) disables. Mirrors opentelemetry-go#8157. Refs open-telemetry#4533.
d487296 to
7b30681
Compare
herin049
approved these changes
Jul 3, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds a client-side guardrail to OTLP/HTTP exporters (traces/logs/metrics) to drop exports whose uncompressed serialized request exceeds a configurable maximum size (defaulting to 64 MiB), recording the drop as a failed export.
Changes:
- Added
max_request_sizeparameter and enforced a “measure before compression” request-size check in trace/log/metric OTLP HTTP exporters. - Introduced a shared
RequestPayloadTooLargeError+_is_request_too_large()helper for consistent failure classification/metrics. - Added unit tests covering default, disablement (0/negative), pre-send drop behavior, and a basic end-to-end HTTP server test for traces; added changelog fragment.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| exporter/opentelemetry-exporter-otlp-proto-http/tests/test_proto_span_exporter.py | Adds max-request-size tests and an end-to-end HTTP server test for the trace exporter. |
| exporter/opentelemetry-exporter-otlp-proto-http/tests/test_proto_log_exporter.py | Adds max-request-size tests for the log exporter. |
| exporter/opentelemetry-exporter-otlp-proto-http/tests/metrics/test_otlp_metrics_exporter.py | Adds max-request-size tests for the metrics exporter (including interaction with batch splitting). |
| exporter/opentelemetry-exporter-otlp-proto-http/src/opentelemetry/exporter/otlp/proto/http/trace_exporter/init.py | Implements max_request_size enforcement and failure recording for trace exports. |
| exporter/opentelemetry-exporter-otlp-proto-http/src/opentelemetry/exporter/otlp/proto/http/_log_exporter/init.py | Implements max_request_size enforcement and failure recording for log exports. |
| exporter/opentelemetry-exporter-otlp-proto-http/src/opentelemetry/exporter/otlp/proto/http/metric_exporter/init.py | Implements max_request_size enforcement and failure recording for metric exports. |
| exporter/opentelemetry-exporter-otlp-proto-http/src/opentelemetry/exporter/otlp/proto/http/_common/init.py | Adds shared exception + helper used by all three exporters. |
| .changelog/5369.changed | Documents the new max_request_size behavior and default. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+144
to
+148
| self._max_request_size = ( | ||
| _DEFAULT_MAX_REQUEST_SIZE | ||
| if max_request_size is None | ||
| else max_request_size | ||
| ) |
Comment on lines
+149
to
+153
| self._max_request_size = ( | ||
| _DEFAULT_MAX_REQUEST_SIZE | ||
| if max_request_size is None | ||
| else max_request_size | ||
| ) |
Comment on lines
+215
to
+219
| self._max_request_size = ( | ||
| _DEFAULT_MAX_REQUEST_SIZE | ||
| if max_request_size is None | ||
| else max_request_size | ||
| ) |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Implements the client side of opentelemetry-proto#782: the OTLP/HTTP exporters drop a serialized request larger than a configurable limit (measured before compression) instead of sending it. Adds a
max_request_sizeargument andOTEL_EXPORTER_OTLP_MAX_REQUEST_SIZE(plus per-signal_TRACES_/_METRICS_/_LOGS_overrides) to the trace, log, and metric HTTP exporters. Default 64 MiB (the spec's RECOMMENDED value, enabled);0(or any non-positive value) disables. Mirrors opentelemetry-go#8157.Behavior-change note: with the default-on limit, batches whose serialized size exceeds 64 MiB (previously sent) are now dropped client-side and recorded as a failed export. gRPC exporters are out of scope here and will follow separately.
Related to #4533 (this is the proactive request-size half; reactive 413 splitting is tracked in #5032).
Type of change
How Has This Been Tested?
Session.post(asserted not called);0/negative disables; env precedence (constructor > per-signal > generic > default) including malformed/empty fallback; failed-export metric recordserror.type.Does This PR Require a Contrib Repo Change?
Checklist: