Repository navigation
Conversation
Pull request dashboard statusWaiting on the author · refreshed 2026-10-31 02:33 UTC Move out of draft to request review. Status above doesn't look right?
|
There was a problem hiding this comment.
🟡 Changes recommended
Logging unbounded rejected span types allocates memory proportional to their length on every span creation, even when logs are throttled, so the logged value needs truncation.
1 open issue
What changed in this PR
Adds incubating span-type support to the tracing API and SDK, exposing validated types to processors and exporters through internal interfaces. Exporter serialization remains unchanged.
Changes:
- Adds
ExtendedSpanBuilder.setType(String)and validates types before sampling. - Preserves span types in SDK spans and exposes them through readable-span and span-data interfaces.
- Adds validation tests and benchmarks with optional span types.
| File | Description |
|---|---|
| sdk/trace/src/testIncubating/java/io/opentelemetry/sdk/trace/SpanTypeTest.java | Tests type validation, builder behavior, and data exposure. |
| sdk/trace/src/test/java/io/opentelemetry/sdk/trace/SdkSpanTest.java | Updates span construction for the type parameter. |
| sdk/trace/src/test/java/io/opentelemetry/sdk/trace/SdkSpanBuilderTest.java | Updates expected span-data string output. |
| sdk/trace/src/main/java/io/opentelemetry/sdk/trace/SpanWrapper.java | Exposes the type through exported span data. |
| sdk/trace/src/main/java/io/opentelemetry/sdk/trace/SdkSpanBuilder.java | Stores, validates, and passes types to spans. |
| sdk/trace/src/main/java/io/opentelemetry/sdk/trace/SdkSpan.java | Stores and exposes the immutable span type. |
| sdk/trace/src/main/java/io/opentelemetry/sdk/trace/internal/ExtendedSpanData.java | Defines experimental span-data type access. |
| sdk/trace/src/main/java/io/opentelemetry/sdk/trace/internal/ExtendedReadableSpan.java | Defines experimental readable-span type access. |
| sdk/trace/src/main/java/io/opentelemetry/sdk/trace/ExtendedSdkSpanBuilder.java | Implements the fluent incubating type setter. |
| sdk/all/src/jmh/java/io/opentelemetry/sdk/SpanRecordBenchmark.java | Benchmarks recording with and without types. |
| api/incubator/src/test/java/io/opentelemetry/api/incubator/trace/ExtendedDefaultTracerTest.java | Tests no-op type-setter behavior. |
| api/incubator/src/main/java/io/opentelemetry/api/incubator/trace/ExtendedSpanBuilder.java | Adds and documents the incubating type setter. |
Review effort: Balanced
| logger.log( | ||
| Level.WARNING, | ||
| "Span type \"" | ||
| + validatedType |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #8991 +/- ##
============================================
+ Coverage 90.36% 90.39% +0.02%
- Complexity 10995 11019 +24
============================================
Files 1020 1020
Lines 30096 30130 +34
Branches 3929 3937 +8
============================================
+ Hits 27197 27235 +38
+ Misses 1942 1937 -5
- Partials 957 958 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|

Implements opentelemetry-specification#5378.
Changes
ExtendedSpanBuilder.setType(String)in the API incubator.ExtendedReadableSpanandExtendedSpanData.Open question
To read the type, exporters will cast to
ExtendedSpanData, an internal interface insdk-trace. OTLP already does this for metric data and resource entities, and event name did it before it was stable. Is there a better option?Benchmarks
SpanRecordBenchmarksets a 48-character type on every span, the longest span type in semantic conventions. Single thread, ops/s:Spans that need a type usually have several attributes, so SMALL doesn't reflect real use. For scale, the first attribute on a SMALL span costs +10 ns and +440 B. Span type costs +45 ns and +8 B.