SpanLimitsBuilder Javadoc states setters must be positive but they accept zero
Describe the bug
SpanLimitsBuilder documents five setters as requiring a positive argument, but the code accepts zero. The Javadoc contract does not match the actual behavior.
Steps to reproduce
SpanLimits.builder().setMaxNumberOfAttributes(0); // Javadoc says this throws; it does not
What did you expect to see?
Javadoc that matches the real behavior. The >= 0 check is intentional (PR #7030 relaxed it to follow the spec, which allows 0), so the Javadoc should say the argument must not be negative.
What did you see instead?
setMaxNumberOfAttributes, setMaxNumberOfEvents, setMaxNumberOfLinks, setMaxNumberOfAttributesPerEvent, and setMaxNumberOfAttributesPerLink (SpanLimitsBuilder.java) each say @param ... Must be positive. and @throws IllegalArgumentException if {@code ...} is not positive., but each calls Utils.checkArgument(value >= 0, "... must be non-negative"). Passing 0 is accepted. The sixth setter, setMaxAttributeValueLength, already documents the same >= 0 check correctly as "Must not be negative" / "is negative".
What version and what artifacts are you using? Artifacts: opentelemetry-sdk-trace Version: main @ 824334c55 How did you reference these artifacts? N/A (source inspection)
Environment Compiler: Temurin 21 OS: N/A
Additional context
Fix is Javadoc-only, no behavior change. Related: PR #7030.
Codecov Report
:x: Patch coverage is 96.77419% with 1 line in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 76.17%. Comparing base (6b37ec2) to head (5b6e11d).
:white_check_mark: All tests successful. No failed tests found.
| Files with missing lines | Patch % | Lines |
|---|---|---|
| ...tation.AspNetCore/Implementation/HttpInListener.cs | 96.55% | 1 Missing :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## main #4548 +/- ##
==========================================
- Coverage 76.27% 76.17% -0.10%
==========================================
Files 442 442
Lines 18245 18262 +17
==========================================
- Hits 13916 13911 -5
- Misses 4329 4351 +22
Flags with carried forward coverage won't be shown. Click here to find out more.
| Files with missing lines | Coverage Δ | |
|---|---|---|
| ...erialization/CommonSchemaJsonSerializationState.cs | 97.72% <ø> (ø) |
|
| ...on.AWS/Implementation/AWSTracingPipelineHandler.cs | 93.47% <100.00%> (+0.09%) |
:arrow_up: |
| ...nstrumentation.AspNetCore/HttpContextExtensions.cs | 100.00% <ø> (ø) |
|
| ...tation.AspNetCore/Implementation/HttpInListener.cs | 88.11% <96.55%> (+0.41%) |
:arrow_up: |
:rocket: New features to boost your workflow:
- :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.