Skip to content

Add MaxRequestSize option to OTLP exporters#8157

Open
pellared wants to merge 6 commits intoopen-telemetry:mainfrom
pellared:otlp-req-size
Open

Add MaxRequestSize option to OTLP exporters#8157
pellared wants to merge 6 commits intoopen-telemetry:mainfrom
pellared:otlp-req-size

Conversation

@pellared
Copy link
Copy Markdown
Member

@pellared pellared commented Apr 8, 2026

Per and blocked by: open-telemetry/opentelemetry-proto#782

  • Introduced WithMaxRequestSize option for OTLP exporters to set a limit on the size of serialized export requests.
  • Implemented logic in the HTTP and gRPC clients to check the request size against the configured maximum before compression and sending.
  • The default configuration is that the maximum request size is 32 MiB.

- Introduced WithMaxRequestSize option for both metric and trace exporters to set a limit on the size of serialized export requests.
- Implemented logic in the HTTP and gRPC clients to check the request size against the configured maximum before sending.
- Added tests to verify that oversized requests are rejected and do not reach the server.
- Updated default configurations to include a maximum request size of 32 MB.
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 8, 2026

Codecov Report

❌ Patch coverage is 98.51852% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.1%. Comparing base (8d70624) to head (5f4da20).

Files with missing lines Patch % Lines
exporters/otlp/otlplog/otlploghttp/client.go 80.0% 1 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@          Coverage Diff          @@
##            main   #8157   +/-   ##
=====================================
  Coverage   82.0%   82.1%           
=====================================
  Files        308     308           
  Lines      24060   24128   +68     
=====================================
+ Hits       19748   19810   +62     
- Misses      3936    3942    +6     
  Partials     376     376           
Files with missing lines Coverage Δ
exporters/otlp/otlplog/otlploggrpc/client.go 95.7% <100.0%> (+1.7%) ⬆️
exporters/otlp/otlplog/otlploggrpc/config.go 92.8% <100.0%> (+0.2%) ⬆️
exporters/otlp/otlplog/otlploghttp/config.go 94.2% <100.0%> (+0.1%) ⬆️
exporters/otlp/otlpmetric/otlpmetricgrpc/client.go 92.7% <100.0%> (+0.2%) ⬆️
exporters/otlp/otlpmetric/otlpmetricgrpc/config.go 45.6% <100.0%> (+1.9%) ⬆️
...tlpmetric/otlpmetricgrpc/internal/oconf/options.go 90.2% <100.0%> (+0.4%) ⬆️
exporters/otlp/otlpmetric/otlpmetrichttp/client.go 83.8% <100.0%> (+0.2%) ⬆️
exporters/otlp/otlpmetric/otlpmetrichttp/config.go 88.5% <100.0%> (+0.6%) ⬆️
...tlpmetric/otlpmetrichttp/internal/oconf/options.go 93.2% <100.0%> (+0.2%) ⬆️
exporters/otlp/otlptrace/otlptracegrpc/client.go 91.2% <100.0%> (+0.2%) ⬆️
... and 6 more

... and 4 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

This PR adds a configurable maximum request size for OTLP exporters (traces, metrics, logs) and enforces it in both HTTP and gRPC clients to fail oversized exports early. The default maximum request size is set to 32 MiB (applies to serialized payload size before compression).

Changes:

  • Introduce WithMaxRequestSize option across OTLP trace/metric/log exporters and plumb it through configs.
  • Enforce max request size checks in HTTP (byte length of marshaled request) and gRPC (protobuf encoded size) clients before sending.
  • Add unit tests verifying default behavior and that oversized requests fail before any network call.

Reviewed changes

Copilot reviewed 33 out of 33 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
internal/shared/otlp/otlptrace/otlpconfig/options.go.tmpl Adds DefaultMaxRequestSize and MaxRequestSize to trace shared config + option wiring.
internal/shared/otlp/otlptrace/otlpconfig/options_test.go.tmpl Tests default and WithMaxRequestSize behavior for shared trace config.
internal/shared/otlp/otlpmetric/oconf/options.go.tmpl Adds DefaultMaxRequestSize and MaxRequestSize to metric shared config + option wiring.
internal/shared/otlp/otlpmetric/oconf/options_test.go.tmpl Tests default and WithMaxRequestSize behavior for shared metric config.
exporters/otlp/otlptrace/otlptracehttp/options.go Exposes WithMaxRequestSize on the OTLP trace HTTP exporter options.
exporters/otlp/otlptrace/otlptracehttp/internal/otlpconfig/options.go Adds default max request size + config field + option wiring for trace HTTP exporter internals.
exporters/otlp/otlptrace/otlptracehttp/internal/otlpconfig/options_test.go Tests default and WithMaxRequestSize behavior for trace HTTP internal config.
exporters/otlp/otlptrace/otlptracehttp/client.go Enforces max request size for HTTP trace exports before sending.
exporters/otlp/otlptrace/otlptracehttp/client_test.go Adds test to ensure oversized HTTP trace requests fail before any request is sent.
exporters/otlp/otlptrace/otlptracegrpc/options.go Exposes WithMaxRequestSize on the OTLP trace gRPC exporter options.
exporters/otlp/otlptrace/otlptracegrpc/internal/otlpconfig/options.go Adds default max request size + config field + option wiring for trace gRPC exporter internals.
exporters/otlp/otlptrace/otlptracegrpc/internal/otlpconfig/options_test.go Tests default and WithMaxRequestSize behavior for trace gRPC internal config.
exporters/otlp/otlptrace/otlptracegrpc/client.go Enforces max request size for gRPC trace exports before calling Export.
exporters/otlp/otlptrace/otlptracegrpc/client_test.go Adds test to ensure oversized gRPC trace requests fail before reaching the collector.
exporters/otlp/otlpmetric/otlpmetrichttp/internal/oconf/options.go Adds default max request size + config field + option wiring for metric HTTP exporter internals.
exporters/otlp/otlpmetric/otlpmetrichttp/internal/oconf/options_test.go Tests default and WithMaxRequestSize behavior for metric HTTP internal config.
exporters/otlp/otlpmetric/otlpmetrichttp/config.go Exposes WithMaxRequestSize on the OTLP metric HTTP exporter options.
exporters/otlp/otlpmetric/otlpmetrichttp/client.go Enforces max request size for HTTP metric exports before sending.
exporters/otlp/otlpmetric/otlpmetrichttp/client_test.go Adds test to ensure oversized HTTP metric requests fail before any request is sent.
exporters/otlp/otlpmetric/otlpmetricgrpc/internal/oconf/options.go Adds default max request size + config field + option wiring for metric gRPC exporter internals.
exporters/otlp/otlpmetric/otlpmetricgrpc/internal/oconf/options_test.go Tests default and WithMaxRequestSize behavior for metric gRPC internal config.
exporters/otlp/otlpmetric/otlpmetricgrpc/config.go Exposes WithMaxRequestSize on the OTLP metric gRPC exporter options.
exporters/otlp/otlpmetric/otlpmetricgrpc/client.go Enforces max request size for gRPC metric exports before calling Export.
exporters/otlp/otlpmetric/otlpmetricgrpc/client_test.go Adds test to ensure oversized gRPC metric requests fail before reaching the collector.
exporters/otlp/otlplog/otlploghttp/config.go Adds max request size to log HTTP exporter config, defaulting to 32 MiB, and exposes WithMaxRequestSize.
exporters/otlp/otlplog/otlploghttp/config_test.go Updates config tests to cover default and explicit max request size settings.
exporters/otlp/otlplog/otlploghttp/client.go Enforces max request size for HTTP log exports before sending.
exporters/otlp/otlplog/otlploghttp/client_test.go Adds test to ensure oversized HTTP log requests fail before any request is sent.
exporters/otlp/otlplog/otlploggrpc/config.go Adds max request size to log gRPC exporter config, defaulting to 32 MiB, and exposes WithMaxRequestSize.
exporters/otlp/otlplog/otlploggrpc/config_test.go Updates config tests to cover default and explicit max request size settings.
exporters/otlp/otlplog/otlploggrpc/client.go Enforces max request size for gRPC log exports before calling Export.
exporters/otlp/otlplog/otlploggrpc/client_test.go Adds test to ensure oversized gRPC log requests fail before sending.
CHANGELOG.md Documents the new option and the default 32 MiB request size limit behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@pellared pellared marked this pull request as ready for review April 8, 2026 16:05
Copy link
Copy Markdown
Contributor

@dashpole dashpole left a comment

Choose a reason for hiding this comment

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

Just nits and questions for my own education

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.

5 participants