Repository navigation
Conversation
Pull request dashboard statusMerged · refreshed 2026-11-05 18:14 UTC Status above doesn't look right?
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8945 +/- ##
=========================================
Coverage 90.37% 90.37%
- Complexity 11012 11015 +3
=========================================
Files 1020 1020
Lines 30119 30120 +1
Branches 3932 3933 +1
=========================================
+ Hits 27219 27220 +1
Misses 1941 1941
Partials 959 959 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
psx95
left a comment
There was a problem hiding this comment.
Could we instead make this change in the internal exporter builders instead?
For instance, we could make this change in here in HttpExporterBuilder.
The handling of 0 value for timeout is also done here. This would make the behavior of configuring SDK programmatically vs via declarative config consistent.
The config options listed in exporter spec do not explicitly state how to handle 0, but I think the spec might just be outdated.
Perhaps other maintainers would want to chime in here?
cc: @jack-berg , @jkwatson
|
@psx95 Thanks for the review. Moving it into the internal builders makes sense to me, and it would match how One catch: the public setters reject 0 before the internal builder sees it ( I'll wait for @jack-berg / @jkwatson to weigh in and update the PR either way. |
So we're inconsistent:
We can relax the more restrictive APIs, but we can't make the more relaxed APIs more restrictive because doing so is a breaking change. I'm ok with relaxing the APIs for consistency, but I want to make sure that we can come up with standard guidance for this that makes sense in all the cases, which we can add to the knowledge base. In particular, I'm thinking about cases like BatchSpanProcessorBuilder#setMaxQueueSize. On first glance, it seems like another case where you can assign the 0 value to mean infinite, but you can't / shouldn't initialize a queue with Integer.MAX_VALUE, so tolerating 0 would be a foot gun. What is the litmus test that determines whether a property should allow 0 to be set or not? |
This comment has been minimized.
This comment has been minimized.
|
Adding a policy around this here: #8986 |
| if (maxRequestSize != null) { | ||
| setMaxRequestSize.accept(maxRequestSize.longValue()); | ||
| // The declarative config schema defines 0 as no limit | ||
| setMaxRequestSize.accept(maxRequestSize == 0 ? Long.MAX_VALUE : maxRequestSize.longValue()); |
There was a problem hiding this comment.
should we be erroring if someone passes in a negative?
There was a problem hiding this comment.
@jkwatson Thanks. It already errors: a negative value reaches the public setter, whose checkArgument rejects it, so building the exporter fails.
After the rework the setters check >= 0, so negatives keep failing. I'll add a negative case to the declarative config tests to keep that covered.
|
We've got consensus on #8986, so let's go ahead with this. I agree with @psx95's comment about doing this programmatic config layer - i.e. changing Otlp{Protocol}{Signal}ExporterBuilder and the underlying {Protocol}ExporterBuilder to relax the constraints and translate 0 to to Long.MAX_VALUE. This approach is most aligned with #8986 which tries to standardize behavior at the programmatic API level. Declarative config would get 0 handling for free. |
|
@jack-berg Thanks, I'll rework the PR that way. The seven public |
|
@jack-berg Reworked in 30659ac: the seven setters now accept 0, |
|
Thank you for your contribution @thswlsqls! 🎉 We would like to hear from you about your experience contributing to OpenTelemetry by taking a few minutes to fill out this survey. |
Fixes #8940
Description
max_request_size: "A value of 0 indicates no limit (infinity) and is not recommended." Setting it to 0 made SDK creation fail, because the OTLP builders only accepted positive values.setMaxRequestBodySize/setMaxRequestMessageSizesetters (OTLP HTTP and gRPC span, metric and log exporters, and the gRPC profiles exporter) now accept 0 and document it as no limit. Negative values are still rejected.HttpExporterBuilderandGrpcExporterBuildermap 0 toLong.MAX_VALUE, like they already do for a 0 timeout. The limit is only used insize > maxchecks, so nothing is allocated up front.OtlpDeclarativeConfigUtilpasses the value through unchanged.Testing done
AbstractHttpTelemetryExporterTest/AbstractGrpcTelemetryExporterTest:setMaxRequestSize(0)is now accepted,-1still throws ("must be non-negative"), and the newrequestBodySizeLimitDisabledWithZero/requestMessageSizeLimitDisabledWithZerotests export successfully with 0.max_request_size 0cases and added negative cases for otlp_http and otlp_grpc inSpanExporterFactoryTest,MetricExporterFactoryTestandLogRecordExporterFactoryTest.Long.MAX_VALUEmapping reverted, the new zero tests fail; with it, they pass../gradlew :exporters:otlp:all:check :exporters:otlp:profiles:check :exporters:otlp:testing-internal:check :sdk-extensions:declarative-config:checkpassed. No apidiff change (only argument checks and Javadoc changed).