Add MaxRequestSize option to OTLP exporters#8157
Add MaxRequestSize option to OTLP exporters#8157pellared wants to merge 6 commits intoopen-telemetry:mainfrom
Conversation
- 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 Report❌ Patch coverage is
Additional details and impacted files@@ 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
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
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
WithMaxRequestSizeoption 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.
dashpole
left a comment
There was a problem hiding this comment.
Just nits and questions for my own education
Per and blocked by: open-telemetry/opentelemetry-proto#782