Skip to content
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ release.

### Common

- Add in-development guidance recommending a JSON object as the string
representation for an attribute in non-OTLP or debugging contexts.
([#8205](https://github.com/open-telemetry/opentelemetry-specification/pull/8205))
Comment thread
pellared marked this conversation as resolved.
Outdated

### OpenTelemetry Protocol

### Compatibility
Expand Down
36 changes: 36 additions & 0 deletions specification/common/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ path_base_for_github_subdir:
+ [Arrays](#arrays)
+ [Maps](#maps)
- [Attribute](#attribute)
* [Attribute representation for non-OTLP](#attribute-representation-for-non-otlp)
* [Attribute Collections](#attribute-collections)
- [Attribute Limits](#attribute-limits)
* [Configurable Parameters](#configurable-parameters)
Expand Down Expand Up @@ -195,6 +196,41 @@ See [Requirement Level](https://github.com/open-telemetry/semantic-conventions/b
See [this document](attribute-type-mapping.md) to find out how to map values obtained
outside OpenTelemetry into OpenTelemetry attribute values.

### Attribute representation for non-OTLP
Comment thread
bogdandrutu marked this conversation as resolved.

**Status**: [Development](../document-status.md)

For non-OTLP protocols or other debugging-oriented contexts that need to
Comment thread
pellared marked this conversation as resolved.
Outdated
represent a single `Attribute` as a string, the RECOMMENDED form is a JSON
Comment thread
pellared marked this conversation as resolved.
Outdated
object containing a single key-value pair.

> [!NOTE]
> This string representation is lossy. Type information is lost as all
Comment thread
pellared marked this conversation as resolved.
> values are converted to strings, and precision loss may occur for numeric values
> (particularly for floating point numbers and large integers that exceed the
> precision capabilities of the receiving system's string-to-number conversion).

The `key` portion SHOULD be represented as a
[JSON string](https://datatracker.ietf.org/doc/html/rfc8259#section-7) member
name.

The `value` portion SHOULD use the JSON representation that corresponds to the
attribute value:

- strings as JSON strings,
- booleans as JSON booleans,
- integers and floating point numbers as JSON numbers, except that `NaN`,
Comment thread
pellared marked this conversation as resolved.
Outdated
`Infinity`, and `-Infinity` SHOULD be represented as JSON strings,
- byte arrays as [Base64-encoded](https://datatracker.ietf.org/doc/html/rfc4648#section-4)
JSON strings,
- arrays as JSON arrays,
- maps as JSON objects,
- empty values as JSON null.
Comment thread
pellared marked this conversation as resolved.
Outdated

Examples: `{"http.request.method": "GET"}`, `{"retries": 3}`,
`{"payload": "aGVsbG8gd29ybGQ="}`, `{"session.id": null}`,
`{"colors": ["red", "blue"]}`, `{"context": {"nested": true}}`

### Attribute Collections

[Resources](../resource/sdk.md),
Expand Down
Loading