Skip to content

exporters: support MAP attributes - #8453

Merged
pellared merged 6 commits into
open-telemetry:mainfrom
pellared:map-exporters
Jun 16, 2026
Merged

pellared merged 6 commits into
open-telemetry:mainfrom
pellared:map-exporters

Conversation

@pellared

@pellared pellared commented Jun 12, 2026

Copy link
Copy Markdown
Member

Fixes #8163

Add end-to-end exporter handling for attribute.SLICE in the remaining paths that still treated it as invalid or relied on fallback formatting.

Changes:

  • encode attribute.MAP as OTLP AnyValue_AnyValue_KvlistValue for trace, log, and metric transforms
  • serialize Zipkin MAP attributes using the non-OTLP AnyValue string representation

@codecov

codecov Bot commented Jun 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.5%. Comparing base (e708781) to head (d6332d1).

Additional details and impacted files

Impacted file tree graph

@@          Coverage Diff          @@
##            main   #8453   +/-   ##
=====================================
  Coverage   83.4%   83.5%           
=====================================
  Files        322     322           
  Lines      25667   25692   +25     
=====================================
+ Hits       21431   21456   +25     
  Misses      3854    3854           
  Partials     382     382           
Files with missing lines Coverage Δ
...otlp/otlplog/otlploggrpc/internal/transform/log.go 96.3% <100.0%> (+<0.1%) ⬆️
...otlp/otlplog/otlploghttp/internal/transform/log.go 96.3% <100.0%> (+<0.1%) ⬆️
...ric/otlpmetricgrpc/internal/transform/attribute.go 97.1% <100.0%> (+0.1%) ⬆️
...ric/otlpmetrichttp/internal/transform/attribute.go 97.1% <100.0%> (+0.1%) ⬆️
...tlp/otlptrace/internal/tracetransform/attribute.go 97.2% <100.0%> (+0.1%) ⬆️
exporters/zipkin/model.go 99.4% <100.0%> (ø)

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR completes end-to-end support for the new attribute.MAP type across the remaining exporter transform paths, ensuring MAP attributes are encoded as OTLP AnyValue.KvlistValue (and rendered appropriately for Zipkin’s deprecated tag encoding). This aligns exporter behavior with the attribute.Value.String() AnyValue representation rules and resolves the linked MAP-handling gap.

Changes:

  • Encode attribute.MAP as OTLP AnyValue_KvlistValue in trace/log/metric attribute transforms (including shared gotmpl templates and generated exporter code).
  • Add comprehensive nested MAP test coverage (MAP containing bytes, slices, nested maps, and empty values) across the affected OTLP transform test suites.
  • Extend Zipkin’s deprecated exporter to serialize MAP attributes using attribute.Value.String() and add a validating JSON test; document the user-visible change in CHANGELOG.md.

Reviewed changes

Copilot reviewed 9 out of 17 changed files in this pull request and generated no comments.

Show a summary per file
File Description
internal/shared/otlp/otlpmetric/transform/attribute.go.tmpl Add MAP → OTLP KvlistValue encoding in shared metric attribute transform template.
internal/shared/otlp/otlpmetric/transform/attribute_test.go.tmpl Add MAP attribute golden expectations (including nested MAP/SLICE cases) to metric transform template tests.
internal/shared/otlp/otlplog/transform/log.go.tmpl Add MAP → OTLP KvlistValue encoding in shared log attribute transform template.
internal/shared/otlp/otlplog/transform/attr_test.go.tmpl Add MAP attribute golden expectations (including nested MAP/SLICE cases) to log transform template tests.
exporters/zipkin/model.go Treat MAP like SLICE and serialize via non-OTLP AnyValue string representation (Value.String()).
exporters/zipkin/model_test.go Add Zipkin MAP serialization test validated with assert.JSONEq.
exporters/otlp/otlptrace/internal/tracetransform/attribute.go Add MAP → OTLP KvlistValue encoding for trace exporter attribute transform.
exporters/otlp/otlptrace/internal/tracetransform/attribute_test.go Add trace attribute transform test coverage for MAP → KvlistValue (nested structures included).
exporters/otlp/otlpmetric/otlpmetrichttp/internal/transform/attribute.go Add MAP → OTLP KvlistValue encoding for OTLP/HTTP metric exporter transform.
exporters/otlp/otlpmetric/otlpmetrichttp/internal/transform/attribute_test.go Add MAP transform expectations for OTLP/HTTP metric exporter tests.
exporters/otlp/otlpmetric/otlpmetricgrpc/internal/transform/attribute.go Add MAP → OTLP KvlistValue encoding for OTLP/gRPC metric exporter transform.
exporters/otlp/otlpmetric/otlpmetricgrpc/internal/transform/attribute_test.go Add MAP transform expectations for OTLP/gRPC metric exporter tests.
exporters/otlp/otlplog/otlploghttp/internal/transform/log.go Add MAP → OTLP KvlistValue encoding for OTLP/HTTP log exporter transform.
exporters/otlp/otlplog/otlploghttp/internal/transform/attr_test.go Add MAP transform expectations for OTLP/HTTP log exporter tests.
exporters/otlp/otlplog/otlploggrpc/internal/transform/log.go Add MAP → OTLP KvlistValue encoding for OTLP/gRPC log exporter transform.
exporters/otlp/otlplog/otlploggrpc/internal/transform/attr_test.go Add MAP transform expectations for OTLP/gRPC log exporter tests.
CHANGELOG.md Record exporter MAP support as a user-visible addition.
Files not reviewed (8)
  • exporters/otlp/otlplog/otlploggrpc/internal/transform/attr_test.go: Generated file
  • exporters/otlp/otlplog/otlploggrpc/internal/transform/log.go: Generated file
  • exporters/otlp/otlplog/otlploghttp/internal/transform/attr_test.go: Generated file
  • exporters/otlp/otlplog/otlploghttp/internal/transform/log.go: Generated file
  • exporters/otlp/otlpmetric/otlpmetricgrpc/internal/transform/attribute.go: Generated file
  • exporters/otlp/otlpmetric/otlpmetricgrpc/internal/transform/attribute_test.go: Generated file
  • exporters/otlp/otlpmetric/otlpmetrichttp/internal/transform/attribute.go: Generated file
  • exporters/otlp/otlpmetric/otlpmetrichttp/internal/transform/attribute_test.go: Generated file

@pellared
pellared marked this pull request as ready for review June 12, 2026 09:19
@pellared
pellared merged commit dcfc16c into open-telemetry:main Jun 16, 2026
34 checks passed
@MrAlias MrAlias added this to the v1.45.0 milestone Jun 25, 2026
NesterovYehor pushed a commit to NesterovYehor/opentelemetry-go that referenced this pull request Jul 15, 2026
Fixes open-telemetry#8163

Add end-to-end exporter handling for `attribute.SLICE` in the remaining
paths that still treated it as invalid or relied on fallback formatting.

Changes:

- encode `attribute.MAP` as OTLP `AnyValue_AnyValue_KvlistValue` for
trace, log, and metric transforms
- serialize Zipkin `MAP` attributes using the non-OTLP AnyValue string
representation
@MrAlias MrAlias mentioned this pull request Aug 3, 2026
MrAlias added a commit that referenced this pull request Aug 3, 2026
### Added

- Add experimental observability metrics to `BatchProcessor` in
`go.opentelemetry.io/otel/sdk/log`. (#7124)
- Add the experimental `WithUnsafeAttributes` no-copy attribute option
to `go.opentelemetry.io/otel/metric/x` for future performance
improvements. This API is a work in progress. (#8251)
- Add `Map` and `MapValue` functions for the new `MAP` attribute type in
`go.opentelemetry.io/otel/attribute`. (#8445)
- Support `MAP` attributes in
`go.opentelemetry.io/otel/exporters/otlp/otlptrace`. (#8453)
- Support `MAP` attributes in
`go.opentelemetry.io/otel/exporters/otlp/otlplog`. (#8453)
- Support `MAP` attributes in
`go.opentelemetry.io/otel/exporters/otlp/otlpmetric`. (#8453)
- Support `MAP` attributes in
`go.opentelemetry.io/otel/exporters/zipkin`. (#8453)
- Apply `AttributeValueLengthLimit` recursively to values contained in
`attribute.MAP` attributes in `go.opentelemetry.io/otel/sdk/trace`.
(#8454)
- Remove duplicate keys from `attribute.MAP` values in
`go.opentelemetry.io/otel/sdk/resource` using last-value-wins semantics.
(#8471)
- Remove duplicate keys by default from `attribute.MAP` values in
instrumentation scope attributes in `go.opentelemetry.io/otel/sdk/log`
using last-value-wins semantics. (#8471)
- Remove duplicate keys by default from `attribute.MAP` values in span,
event, link, and instrumentation scope attributes in
`go.opentelemetry.io/otel/sdk/trace` using last-value-wins semantics.
(#8471)
- Remove duplicate keys by default from `attribute.MAP` values in
measurement and instrumentation scope attributes in
`go.opentelemetry.io/otel/sdk/metric` using last-value-wins semantics.
(#8471)
- Extend `WithAllowKeyDuplication` in `go.opentelemetry.io/otel/sdk/log`
to disable duplicate-key removal in `attribute.MAP` values for
instrumentation scope attributes. (#8471)
- Add the `go.opentelemetry.io/otel/semconv/v1.42.0` package.
The package contains semantic conventions from the `v1.42.0` version of
the OpenTelemetry Semantic Conventions.
See the [migration documentation](./semconv/v1.42.0/MIGRATION.md) for
information on how to upgrade from
`go.opentelemetry.io/otel/semconv/v1.41.0`. (#8484)
- Add `WithoutPanicRecording` as a `TracerProviderOption` in
`go.opentelemetry.io/otel/sdk/trace` to disable exception event
recording for panics. (#8532)
- Add the `go.opentelemetry.io/otel/semconv/v1.43.0` package.
The package contains semantic conventions from the `v1.43.0` version of
the OpenTelemetry Semantic Conventions.
See the [migration documentation](./semconv/v1.43.0/MIGRATION.md) for
information on how to upgrade from
`go.opentelemetry.io/otel/semconv/v1.42.0`. (#8628)

### Changed

- `HistogramReservoir` in `go.opentelemetry.io/otel/sdk/metric/exemplar`
now uses a time-unbiased sampling algorithm for exemplars. (#8306)
- ⚠️ **Breaking Change:** Use `go.opentelemetry.io/otel/attribute.Value`
and `go.opentelemetry.io/otel/attribute.KeyValue` for log bodies and
attributes in `go.opentelemetry.io/otel/log`,
`go.opentelemetry.io/otel/log/logtest`,
`go.opentelemetry.io/otel/sdk/log`, and
`go.opentelemetry.io/otel/sdk/log/logtest`. (#8490)
- Encode log bodies and attributes as
`go.opentelemetry.io/otel/attribute.Value` JSON in
`go.opentelemetry.io/otel/exporters/stdout/stdoutlog`. (#8490)
- Improve the performance of hashing `BOOLSLICE`, `INT64SLICE`,
`FLOAT64SLICE`, and `STRINGSLICE` attribute values by avoiding
reflection for short slices in `go.opentelemetry.io/otel/attribute`.
(#8511)
- ⚠️ **Breaking Change:** `WithEndpointURL` in
`go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp` no
longer appends the default signal path when an endpoint URL has no path,
making the behavior consistent with
`go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp` and with
setting the endpoint through `OTEL_EXPORTER_OTLP_METRICS_ENDPOINT`. If
the URL has no path component, the root path (`/`) is used. Use
`WithEndpointURL(url.JoinPath(endpoint, "/v1/metrics"))` to preserve the
previous behavior. (#8538)
- ⚠️ **Breaking Change:** `WithEndpointURL` in
`go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp` no
longer appends the default signal path when an endpoint URL has no path,
making the behavior consistent with
`go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp` and with
setting the endpoint through `OTEL_EXPORTER_OTLP_TRACES_ENDPOINT`. If
the URL has no path component, the root path (`/`) is used. Use
`WithEndpointURL(url.JoinPath(endpoint, "/v1/traces"))` to preserve the
previous behavior. (#8538)

### Deprecated

- Deprecate `WithExportBufferSize` in
`go.opentelemetry.io/otel/sdk/log`. The option remains available for
source compatibility but no longer affects behavior; `BatchProcessor` no
longer maintains a separate export-request buffer. (#8620)

### Removed

- ⚠️ **Breaking Change:** Remove `Kind`, `Value`, `KeyValue`, their
constructors, and attribute conversion helpers from
`go.opentelemetry.io/otel/log`. (#8490)
- ⚠️ **Breaking Change:** Remove the `AttributeValueLengthLimit` and
`AttributeCountLimit` fields from `RecordFactory` in
`go.opentelemetry.io/otel/sdk/log/logtest`; records produced by the
factory now keep attribute limits disabled so test code can append exact
attributes. (#8556)

### Fixed

- Fix an off-by-one error in `FixedSizeReservoir` in
`go.opentelemetry.io/otel/sdk/metric/exemplar` that prevented the first
exemplar from being sampled after the reservoir was filled. (#8309)
- Interpret HTTP `Retry-After` header values as seconds instead of
nanoseconds when retrying OTLP HTTP exports in
`go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp`,
`go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp`, and
`go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp`. (#8383)
- Fix a memory leak in the `Reservoir` implementation in
`go.opentelemetry.io/otel/sdk/metric/exemplar`, where storing the full
`context.Context` pinned large objects such as gRPC transport buffers.
(#8389)
- Prevent a non-empty attribute set whose computed hash is zero from
collapsing to an empty set in `go.opentelemetry.io/otel/attribute`.
(#8402)
- Fix histogram data point reuse in
`go.opentelemetry.io/otel/sdk/metric` aggregation to avoid leaking stale
sum, minimum, and maximum values when they are disabled in subsequent
collections. (#8403)
- Avoid preallocating scope attributes when they are disabled in
`go.opentelemetry.io/otel/exporters/prometheus`. (#8404)
- Support HTTP-date values in the HTTP `Retry-After` header when
retrying OTLP HTTP exports in
`go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp`,
`go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp`, and
`go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp`. (#8417)
- Reduce histogram heap allocations by reusing `BucketCounts` and
`Exemplars` slices across `Collect` cycles in the cumulative histogram
aggregation in `go.opentelemetry.io/otel/sdk/metric`. (#8428)
- Fix `go.opentelemetry.io/otel/exporters/stdout/stdouttrace`
self-observability to record `error.type` on the operation-duration
histogram when the `exportedSpans` metric is disabled. (#8432)
- Stop including trace exporter endpoint configuration in internal logs
from `go.opentelemetry.io/otel/sdk/trace`,
`go.opentelemetry.io/otel/exporters/otlp/otlptrace`,
`go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc`,
`go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp`, and
`go.opentelemetry.io/otel/exporters/zipkin`. (#8438)
- Fix invalid error formatting for out-of-range JSON code values in
`go.opentelemetry.io/otel/codes`. (#8497)
- Clarify in `go.opentelemetry.io/otel/log` that `Logger.Enabled` should
be checked for every log emission because its result may change over
time. (#8565)
- Preserve user-provided exception attributes while independently
deriving missing exception message and type attributes in
`go.opentelemetry.io/otel/sdk/log`. (#8566)
- Make `WithAttributeCountLimit(0)` and
`OTEL_LOGRECORD_ATTRIBUTE_COUNT_LIMIT=0` discard all log record
attributes in `go.opentelemetry.io/otel/sdk/log`. (#8570)
- Clarify that the `Record` methods of `Float64Histogram` and
`Int64Histogram` in `go.opentelemetry.io/otel/metric` expect
non-negative values. (#8574)
- Clarify in `go.opentelemetry.io/otel/log` that `LoggerProvider`
implementations should retain an empty `Logger` name instead of
replacing it with a default. (#8587)
- Ensure that the built-in processors in
`go.opentelemetry.io/otel/sdk/log` call exporter `ForceFlush` during
`Shutdown`. (#8599)
- Prevent panics in `go.opentelemetry.io/otel/bridge/opentracing` when
OpenTracing baggage is propagated concurrently with
`Span.SetBaggageItem`.
([GHSA-42cj-99w8-cp2p](GHSA-42cj-99w8-cp2p))
- Prevent processor operations in `go.opentelemetry.io/otel/sdk/log`
from overlapping with processor shutdown or running after
`LoggerProvider` shutdown. (#8608)
- Prevent `BatchProcessor` in `go.opentelemetry.io/otel/sdk/log` from
busy-spinning under exporter backpressure and serialize dequeue, export,
force-flush, and shutdown work in one worker. (#8620)
- Make `BatchProcessor` in `go.opentelemetry.io/otel/sdk/log` return
errors encountered while draining records during `ForceFlush` and
`Shutdown`, while continuing to attempt later batches as long as the
request context remains valid. (#8620)
- Keep the default `BatchProcessor` maximum export batch size in
`go.opentelemetry.io/otel/sdk/log` at or below the configured maximum
queue size. (#8620)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

exporters: Handle MAP type

4 participants