opentelemetry-java icon indicating copy to clipboard operation
opentelemetry-java copied to clipboard

SpanLimitsBuilder Javadoc states setters must be positive but they accept zero

Open thswlsqls opened this issue 5 months ago • 0 comments

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.

thswlsqls avatar Jun 22 '26 08:06 thswlsqls

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

Impacted file tree graph

@@            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     
Flag Coverage Δ
unittests-Contrib.Shared.Tests 89.93% <ø> (ø)
unittests-Exporter.Geneva 55.42% <ø> (-0.33%) :arrow_down:
unittests-Exporter.InfluxDB 95.75% <ø> (ø)
unittests-Exporter.OneCollector 95.60% <ø> (ø)
unittests-Extensions 90.61% <ø> (ø)
unittests-Extensions.Enrichment 100.00% <ø> (ø)
unittests-Extensions.Enrichment.AspNetCore 86.27% <ø> (ø)
unittests-Extensions.Enrichment.Http 94.33% <ø> (ø)
unittests-Instrumentation.AWS 85.24% <100.00%> (+0.02%) :arrow_up:
unittests-Instrumentation.AspNet 77.50% <ø> (ø)
unittests-Instrumentation.AspNetCore 87.92% <96.55%> (+0.23%) :arrow_up:
unittests-Instrumentation.Cassandra 92.68% <ø> (ø)
unittests-Instrumentation.ConfluentKafka 82.04% <ø> (ø)
unittests-Instrumentation.ElasticsearchClient 80.36% <ø> (ø)
unittests-Instrumentation.EntityFrameworkCore 81.02% <ø> (ø)
unittests-Instrumentation.EventCounters 77.47% <ø> (ø)
unittests-Instrumentation.GrpcCore 91.12% <ø> (ø)
unittests-Instrumentation.GrpcNetClient 78.09% <ø> (ø)
unittests-Instrumentation.Hangfire 88.83% <ø> (ø)
unittests-Instrumentation.Http 74.81% <ø> (ø)
unittests-Instrumentation.Owin 88.88% <ø> (ø)
unittests-Instrumentation.Process 100.00% <ø> (ø)
unittests-Instrumentation.Quartz 78.37% <ø> (ø)
unittests-Instrumentation.Remoting 65.59% <ø> (ø)
unittests-Instrumentation.Runtime 100.00% <ø> (ø)
unittests-Instrumentation.ServiceFabricRemoting 39.91% <ø> (ø)
unittests-Instrumentation.SqlClient 82.36% <ø> (ø)
unittests-Instrumentation.StackExchangeRedis 94.18% <ø> (ø)
unittests-Instrumentation.Wcf 82.64% <ø> (ø)
unittests-OpAmp.Client 86.05% <ø> (-0.38%) :arrow_down:
unittests-PersistentStorage 67.74% <ø> (ø)
unittests-Resources.AWS 73.61% <ø> (ø)
unittests-Resources.Azure 87.67% <ø> (ø)
unittests-Resources.Container 67.34% <ø> (ø)
unittests-Resources.Gcp 71.42% <ø> (ø)
unittests-Resources.Host 72.26% <ø> (ø)
unittests-Resources.OperatingSystem 76.98% <ø> (ø)
unittests-Resources.Process 90.47% <ø> (ø)
unittests-Resources.ProcessRuntime 79.59% <ø> (ø)
unittests-Sampler.AWS 95.97% <ø> (ø)

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:

... and 5 files with indirect coverage changes

:rocket: New features to boost your workflow:
  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

codecov[bot] avatar Jun 22 '26 16:06 codecov[bot]