Repository navigation
Stabilize Attribute and Attribute Collection representation for non-OTLP - #5149
Conversation
|
This should be part of v1.59.0 (and not upcoming v1.58.0). Therefore, I am adding a |
|
SIG meeting notes: |
|
This PR was marked stale. It will be closed in 14 days without additional activity. |
|
This PR was marked stale. It will be closed in 14 days without additional activity. |
Pull request dashboard statusMerged · refreshed 2026-09-18 06:19 UTC Status above doesn't look right?
|
|
I added a Java prototype. I think this should ready for review. |
jack-berg
left a comment
There was a problem hiding this comment.
I have no issues with stabilizing this because I think its perfectly reasonable guidance for non-OTLP protocols, but I don't think we would want to move forward with the java implementation that changes our debugging logging representation away from the java idiomatic form to JSON. See my comment here: https://github.com/open-telemetry/opentelemetry-java/pull/8768/changes#r3973166559
|
We'll merge this PR by the end of Sep. 18th, 2026 unless there is blocking concerns. |
This comment has been minimized.
This comment has been minimized.
Fixes #8146 Towards #7810 Adds `attribute.KeyValue.String`, using the stable [OpenTelemetry Attribute representation for non-OTLP protocols](https://opentelemetry.io/docs/specs/otel/common/#attribute-representation-for-non-otlp). Each key-value pair is encoded as a single-member JSON object, and the value reuses the existing non-OTLP AnyValue formatter so strings, byte slices, special floating-point values, empty values, slices, and maps are represented consistently with `attribute.Value.String`. The governing representation was stabilized by [open-telemetry/opentelemetry-specification#5149](open-telemetry/opentelemetry-specification#5149). The implementation delegates to the shared map formatter used by composite attribute values, keeping representation and escaping rules in one place. ## Benchmarks The direct `formatMap` call was compared with `formatMapValue([1]KeyValue{kv})` over six runs. It reduced scalar geomean latency by 35.84%, bytes by 57.14%, and allocations from two to one while retaining the shared formatter. Scalar values: ```console $ go test -run '^$' -bench 'Benchmark(Bool|Int|Int64|Float64|String|ByteSlice)/KeyValueString$' -benchmem -count=1 ./attribute goos: linux goarch: amd64 pkg: go.opentelemetry.io/otel/attribute cpu: AMD EPYC 7571 BenchmarkBool/KeyValueString-16 10230636 114.4 ns/op 48 B/op 1 allocs/op BenchmarkInt/KeyValueString-16 9173830 128.7 ns/op 48 B/op 1 allocs/op BenchmarkInt64/KeyValueString-16 8910942 131.9 ns/op 48 B/op 1 allocs/op BenchmarkFloat64/KeyValueString-16 5223004 228.3 ns/op 48 B/op 1 allocs/op BenchmarkString/KeyValueString-16 8326384 142.8 ns/op 48 B/op 1 allocs/op BenchmarkByteSlice/KeyValueString-16 6661430 178.3 ns/op 48 B/op 1 allocs/op ``` Slice, composite, and map values: ```console $ go test -run '^$' -bench 'Benchmark(BoolSlice|IntSlice|Int64Slice|Float64Slice|StringSlice|Slice|Map)/.*/KeyValueString$' -benchmem -count=1 ./attribute goos: linux goarch: amd64 pkg: go.opentelemetry.io/otel/attribute cpu: AMD EPYC 7571 BenchmarkBoolSlice/Len2/KeyValueString-16 7323930 159.9 ns/op 48 B/op 1 allocs/op BenchmarkBoolSlice/Len8/KeyValueString-16 2761668 436.5 ns/op 208 B/op 2 allocs/op BenchmarkIntSlice/Len2/KeyValueString-16 3621410 330.8 ns/op 192 B/op 2 allocs/op BenchmarkIntSlice/Len8/KeyValueString-16 1857816 646.6 ns/op 336 B/op 2 allocs/op BenchmarkInt64Slice/Len2/KeyValueString-16 5898504 201.9 ns/op 64 B/op 1 allocs/op BenchmarkInt64Slice/Len8/KeyValueString-16 1785464 670.7 ns/op 384 B/op 2 allocs/op BenchmarkFloat64Slice/Len2/KeyValueString-16 2145739 557.6 ns/op 256 B/op 2 allocs/op BenchmarkFloat64Slice/Len8/KeyValueString-16 829886 1315 ns/op 416 B/op 2 allocs/op BenchmarkStringSlice/Len2/KeyValueString-16 4942752 241.9 ns/op 64 B/op 1 allocs/op BenchmarkStringSlice/Len8/KeyValueString-16 1290357 929.6 ns/op 288 B/op 2 allocs/op BenchmarkSlice/Len3/KeyValueString-16 5399734 221.3 ns/op 48 B/op 1 allocs/op BenchmarkSlice/Len5Nested/KeyValueString-16 2104201 573.2 ns/op 208 B/op 2 allocs/op BenchmarkMap/Len3/KeyValueString-16 2254777 533.8 ns/op 272 B/op 2 allocs/op BenchmarkMap/Len5Nested/KeyValueString-16 1000000 1018 ns/op 368 B/op 2 allocs/op ```
### Traces - Add `Sampler.Shutdown` operation. ([open-telemetry#5335](open-telemetry#5335)) - Clarify that calls to the Development `SpanProcessor.OnEnding` method are not allowed after `Shutdown`. ([open-telemetry#5316](open-telemetry#5316)) ### Metrics - Specify that `Shutdown` of the periodic exporting MetricReader MUST include the effects of `ForceFlush`. ([open-telemetry#5305](open-telemetry#5305)) ### Logs - Add systemd-journald example mapping to the logs data model appendix and align syslog mapping. ([open-telemetry#4995](open-telemetry#4995)) ### Resource - Update resource detectors to generate entities and indicate resource detectors should be entity-aware unless new `OTEL_EXPERIMENTAL_ENTITIES_ENABLED != true`. ([open-telemetry#5147](open-telemetry#5147)) ### Entities - Add in-development entity-resource startup specification. ([open-telemetry#5057](open-telemetry#5057)) - Remove `OTEL_ENTITIES` from general env var configuration spec. ([open-telemetry#5147](open-telemetry#5147)) ### Common - Stabilize Attribute and Attribute Collection representation for non-OTLP. ([open-telemetry#5149](open-telemetry#5149)) ### OpenTelemetry Protocol - Clarify that the OTLP exporter timeout bounds the entire batch export, including all request attempts and waits between retries, and that earlier caller deadlines take precedence. ([open-telemetry#5347](open-telemetry#5347)) ### Compatibility - Stabilize Prometheus Unknown-typed metric transformation. ([open-telemetry#5213](open-telemetry#5213)) - Stabilize Prometheus Info metric transformation. ([open-telemetry#5211](open-telemetry#5211)) ### SDK Configuration - Declarative config should gracefully degrade when encountering unrecognized resource detectors. Other SDK plugin components continue to produce errors when missing. ([open-telemetry#5323](open-telemetry#5323)) ### Supplementary Guidelines - Allow narrowly scoped security-related changes to stable SDK and Contrib behavior, configuration defaults, supported values, and emitted telemetry without a major version bump, while preserving API compatibility and requiring release notes describing the security rationale, user impact, and migration. ([open-telemetry#5357](open-telemetry#5357)) ### OTEPs - Add OTEP proposing a top-level span type field in API, SDK, and OTLP. ([open-telemetry#5233](open-telemetry#5233))
This is needed to unblock:
Prototypes:
I think that this sections are not controversial and could be stabilized without having more prototypes.
Please double-check the sections that are being stabilized in this PR.