Skip to content

opentelemetry-exporter-otlp-proto-http: add max request size limit to OTLP HTTP exporters#5369

Open
Krishnachaitanyakc wants to merge 1 commit into
open-telemetry:mainfrom
Krishnachaitanyakc:feat/otlp-max-request-size
Open

opentelemetry-exporter-otlp-proto-http: add max request size limit to OTLP HTTP exporters#5369
Krishnachaitanyakc wants to merge 1 commit into
open-telemetry:mainfrom
Krishnachaitanyakc:feat/otlp-max-request-size

Conversation

@Krishnachaitanyakc

@Krishnachaitanyakc Krishnachaitanyakc commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

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_size constructor argument 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.

Configuration is constructor-only; no OTLP environment variable is exposed for this option. An earlier revision added one but it was dropped per review, since this option is not part of the spec's environment-variable surface.

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

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

  • Unit tests across all three HTTP exporters: oversized request dropped before Session.post (asserted not called); 0/negative disables the limit; failed-export metric records error.type.
  • Discriminating "before compression" test: a payload whose gzip size is below the limit but uncompressed size exceeds it is still dropped.
  • End-to-end test against a real local HTTP server: a normal payload is received; an oversized one never reaches the server.

Does This PR Require a Contrib Repo Change?

  • No.

Checklist:

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added

@Krishnachaitanyakc Krishnachaitanyakc requested a review from a team as a code owner June 29, 2026 16:50
Comment thread opentelemetry-sdk/src/opentelemetry/sdk/environment_variables/__init__.py Outdated
@github-project-automation github-project-automation Bot moved this to Reviewed PRs that need fixes in Python PR digest Jun 30, 2026
@Krishnachaitanyakc Krishnachaitanyakc force-pushed the feat/otlp-max-request-size branch from d487296 to 7b30681 Compare June 30, 2026 01:35
@github-project-automation github-project-automation Bot moved this from Reviewed PRs that need fixes to Approved PRs in Python PR digest Jul 3, 2026
@herin049 herin049 requested a review from Copilot July 3, 2026 22:12

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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_size parameter 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.

@xrmx

xrmx commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

@Krishnachaitanyakc I think that copilot is confused by the PR description, could you please clean that up and fix conflicts?

… 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.
@Krishnachaitanyakc Krishnachaitanyakc force-pushed the feat/otlp-max-request-size branch from 1e91ce5 to 2aedcb7 Compare July 10, 2026 18:35
@Krishnachaitanyakc

Copy link
Copy Markdown
Contributor Author

@xrmx I've updated it. Can you take a look?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Approved PRs

Development

Successfully merging this pull request may close these issues.

4 participants