Skip to content

attribute: change INVALID Type to EMPTY and mark INVALID as deprecated#8038

Merged
pellared merged 17 commits intoopen-telemetry:mainfrom
pellared:attribute-empty
Mar 12, 2026
Merged

attribute: change INVALID Type to EMPTY and mark INVALID as deprecated#8038
pellared merged 17 commits intoopen-telemetry:mainfrom
pellared:attribute-empty

Conversation

@pellared
Copy link
Copy Markdown
Member

Fixes #7932

Noticeable comment from previous PR: #7942 (comment)

Print the empty value as empty string per https://opentelemetry.io/docs/specs/otel/common/#empty-values

@pellared pellared marked this pull request as ready for review March 10, 2026 18:48
@pellared pellared requested a review from Copilot March 10, 2026 18:48
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the go.opentelemetry.io/otel/attribute API to treat the zero attribute.Value{} as a first-class empty value (EMPTY) instead of an invalid value, aligning behavior with the OTel empty-value spec and deprecating the old INVALID identifier.

Changes:

  • Introduces attribute.EMPTY as the zero/default Type and deprecates attribute.INVALID as an alias.
  • Updates Emit()/AsInterface() and hashing logic to support EMPTY semantics (emit "", interface nil, stable hash).
  • Adjusts validity rules and tests to treat empty values as valid attributes.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
log/keyvalue.go Converts attribute.EMPTY into the log package’s empty Value{}.
attribute/value.go Adds EMPTY, deprecates INVALID, updates AsInterface/Emit behavior.
attribute/type_string.go Regenerated Type.String() output to include EMPTY.
attribute/kv.go Makes KeyValue.Valid() accept empty values (key-defined only).
attribute/value_test.go Adds EMPTY test coverage and equivalence/non-equivalence cases.
attribute/kv_test.go Updates validity and incorrect-cast tests for EMPTY.
attribute/key_test.go Adds Emit() test case for EMPTY emitting an empty string.
attribute/hash.go Adds EMPTY hashing discriminator and EMPTY handling.
attribute/hash_test.go Extends hash tests/fuzzing to include empty values.
CHANGELOG.md Documents the change and deprecation in Unreleased notes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

pellared and others added 2 commits March 10, 2026 20:00
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@pellared pellared marked this pull request as draft March 10, 2026 19:02
@pellared pellared requested a review from Copilot March 10, 2026 19:49
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 27 out of 27 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@pellared pellared marked this pull request as ready for review March 10, 2026 20:00
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 10, 2026

Codecov Report

❌ Patch coverage is 93.75000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 81.5%. Comparing base (205e244) to head (5539bc4).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...dk/metric/metricdata/metricdatatest/comparisons.go 0.0% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##            main   #8038     +/-   ##
=======================================
- Coverage   81.6%   81.5%   -0.1%     
=======================================
  Files        304     304             
  Lines      23425   23438     +13     
=======================================
- Hits       19128   19124      -4     
- Misses      3909    3926     +17     
  Partials     388     388             
Files with missing lines Coverage Δ
attribute/hash.go 91.4% <100.0%> (+2.3%) ⬆️
attribute/kv.go 100.0% <100.0%> (ø)
attribute/type_string.go 60.0% <ø> (ø)
attribute/value.go 92.8% <100.0%> (+0.2%) ⬆️
...otlp/otlplog/otlploggrpc/internal/transform/log.go 96.1% <100.0%> (-2.4%) ⬇️
...otlp/otlplog/otlploghttp/internal/transform/log.go 96.1% <100.0%> (-2.4%) ⬇️
...ric/otlpmetricgrpc/internal/transform/attribute.go 96.6% <100.0%> (-3.4%) ⬇️
...ric/otlpmetrichttp/internal/transform/attribute.go 96.6% <100.0%> (-3.4%) ⬇️
...tlp/otlptrace/internal/tracetransform/attribute.go 96.7% <100.0%> (-3.3%) ⬇️
log/keyvalue.go 97.0% <100.0%> (ø)
... and 1 more

... and 3 files with indirect coverage changes

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

XSAM

This comment was marked as resolved.

@pellared
Copy link
Copy Markdown
Member Author

Should we update the method


to include Empty? Otherwise this would panic.

Fixed 8015c7d

I tried to find similar cases, but it seemed to be the only one I missed.

@pellared pellared requested review from MrAlias and XSAM March 11, 2026 15:20
Copy link
Copy Markdown
Contributor

@MrAlias MrAlias left a comment

Choose a reason for hiding this comment

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

Awesome work 👏

@pellared pellared merged commit f4da59e into open-telemetry:main Mar 12, 2026
33 checks passed
@pellared pellared added this to the v1.43.0 milestone Mar 12, 2026
dmathieu added a commit that referenced this pull request Apr 3, 2026
Release issue:
#8127

## Added

- Add `IsRandom` and `WithRandom` on `TraceFlags`, and `IsRandom` on
`SpanContext` in `go.opentelemetry.io/otel/trace`
for [W3C Trace Context Level 2 Random Trace ID
Flag](https://www.w3.org/TR/trace-context-2/#random-trace-id-flag)
support. (#8012)
- Add service detection with `WithService` in
`go.opentelemetry.io/otel/sdk/resource`. (#7642)
- Add `DefaultWithContext` and `EnvironmentWithContext` in
`go.opentelemetry.io/otel/sdk/resource` to support plumbing
`context.Context` through default and environment detectors. (#8051)
- Support attributes with empty value (`attribute.EMPTY`) in
`go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc`.
(#8038)
- Support attributes with empty value (`attribute.EMPTY`) in
`go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc`.
(#8038)
- Support attributes with empty value (`attribute.EMPTY`) in
`go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc`. (#8038)
- Support attributes with empty value (`attribute.EMPTY`) in
`go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp`.
(#8038)
- Support attributes with empty value (`attribute.EMPTY`) in
`go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp`.
(#8038)
- Support attributes with empty value (`attribute.EMPTY`) in
`go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp`. (#8038)
- Support attributes with empty value (`attribute.EMPTY`) in
`go.opentelemetry.io/otel/sdk/metric/metricdata/metricdatatest`. (#8038)
- Add support for per-series start time tracking for cumulative metrics
in `go.opentelemetry.io/otel/sdk/metric`.
  Set `OTEL_GO_X_PER_SERIES_START_TIMESTAMPS=true` to enable. (#8060)
- Add `WithCardinalityLimitSelector` for metric reader for configuring
cardinality limits specific to the instrument kind. (#7855)

## Changed

- Introduce the `EMPTY` Type in `go.opentelemetry.io/otel/attribute` to
reflect that an empty value is now a valid value, with `INVALID`
remaining as a deprecated alias of `EMPTY`. (#8038)
- Refactor slice handling in `go.opentelemetry.io/otel/attribute` to
optimize short slice values with fixed-size fast paths. (#8039)
- Improve performance of span metric recording in
`go.opentelemetry.io/otel/sdk/trace` by returning early if
self-observability is not enabled. (#8067)
- Improve formatting of metric data diffs in
`go.opentelemetry.io/otel/sdk/metric/metricdata/metricdatatest`. (#8073)

## Deprecated

- Deprecate `INVALID` in `go.opentelemetry.io/otel/attribute`. Use
`EMPTY` instead. (#8038)

## Fixed

- Return spec-compliant `TraceIdRatioBased` description. This is a
breaking behavioral change, but it is necessary to
make the implementation
[spec-compliant](https://opentelemetry.io/docs/specs/otel/trace/sdk/#traceidratiobased).
(#8027)
- Fix a race condition in `go.opentelemetry.io/otel/sdk/metric` where
the lastvalue aggregation could collect the value 0 even when no
zero-value measurements were recorded. (#8056)
- Limit HTTP response body to 4 MiB in
`go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp` to
mitigate excessive memory usage caused by a misconfigured or malicious
server.
Responses exceeding the limit are treated as non-retryable errors.
(#8108)
- Limit HTTP response body to 4 MiB in
`go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp` to
mitigate excessive memory usage caused by a misconfigured or malicious
server.
Responses exceeding the limit are treated as non-retryable errors.
(#8108)
- Limit HTTP response body to 4 MiB in
`go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp` to
mitigate excessive memory usage caused by a misconfigured or malicious
server.
Responses exceeding the limit are treated as non-retryable errors.
(#8108)
- `WithHostID` detector in `go.opentelemetry.io/otel/sdk/resource` to
use full path for `kenv` command on BSD. (#8113)
- Fix missing `request.GetBody` in
`go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp` to
correctly handle HTTP2 GOAWAY frame. (#8096)

---------

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
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.

attribute: Add EMPTY type

7 participants