Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move attribute definition from spec #636

Closed
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
d541ee7
Centralize attributes definition (#722)
bogdandrutu Jul 22, 2020
a2fe1a3
DocFX sanity check (#742)
reyang Jul 27, 2020
3f8bc51
Consistency between Span and Resource attributes (#777)
thisthat Aug 13, 2020
79d4166
Add conventions for attribute names (#807)
tigrannajaryan Aug 17, 2020
00959df
Extend attribute naming rules to metric labels (#821)
tigrannajaryan Aug 19, 2020
56f7730
Fix lint check in makefile, fix errors (#837)
bogdandrutu Aug 19, 2020
596379f
Require that names and namespaces are one global space across all sem…
tigrannajaryan Aug 24, 2020
f52034c
Define `null` as an invalid value for attributes and declare attempts…
arminru Sep 25, 2020
89262a0
Fix absolute links to spec (#1192)
Oberon00 Nov 4, 2020
b8ab101
Remove ordering reqirement for attributes. (#1212)
Oberon00 Nov 10, 2020
ccef73a
Include attribute name pluralization guidelines (#1115) (#1140)
pmm-sumo Nov 10, 2020
e99bc0b
Add guidance on when to use and not use nested namespaces (#1197)
tigrannajaryan Nov 10, 2020
640a5c5
Nulls SHOULD NOT be allowed in arrays. (#1214)
Oberon00 Nov 11, 2020
49b70ba
Declare freeze of Trace API Specification 1.0 (#1121)
tigrannajaryan Nov 17, 2020
f3aaff6
Add lifecycle statuses to all documents (#1385)
tedsuo Feb 4, 2021
8d474bf
Clarify usage of "otel." attribute namespace (#1640)
tigrannajaryan Apr 28, 2021
c74933e
Rename Metrics labels to attributes (#1775)
jtmalinowski Jun 30, 2021
93c8323
Add an option to limit length of values of attributes and metric valu…
jtmalinowski Aug 3, 2021
7ff2672
Prefer global limit over model-specific default (#1893)
owais Sep 14, 2021
64387bc
Exempt resources from attribute limits (#1892)
owais Sep 22, 2021
a66bd4d
Provide a normative definition of Attribute (singular) rather than At…
chalin Nov 16, 2021
02c9500
[editorial] Ensure all ToCs are generated using markdown-toc (#2146)
chalin Nov 24, 2021
3321b3e
Prohibit usage of retired names in semantic conventions (#2191)
tigrannajaryan Dec 13, 2021
aeab663
Clarify that attribute keys are unique in collections (#2248)
tigrannajaryan Jan 26, 2022
96108c0
Clarify that Trace/Meter are associated with Instrumentation Scope (#…
tigrannajaryan Feb 15, 2022
6ea7155
Describe how to convert non-string primitives for protocols which onl…
dashpole Mar 3, 2022
d7400c8
Fix links (#2426)
reyang Mar 22, 2022
91bf1f1
Implement OTEP 0178: Mapping external data to AnyValue (#2385)
tigrannajaryan Mar 22, 2022
a2feb34
[editorial] Ensure common section has a README (#2479)
chalin Apr 8, 2022
5bcfad4
Define attribute requirement levels (#2522)
lmolkova May 16, 2022
1174ab5
[editorial] Add missing READMEs to section (#2559)
chalin May 20, 2022
5902a67
Move non-otlp.md to common directory (#2587)
tigrannajaryan Jun 2, 2022
eaa6744
Introduce Instrumentation Scope Attributes (#2579)
tigrannajaryan Jun 11, 2022
22d04d6
Use consistent file name for data-model.md (#2586)
tigrannajaryan Jun 13, 2022
00e0849
[editorial] Add note to Hugo front matter (#2651)
chalin Jul 8, 2022
e7134eb
Define net.sock attributes and clarify logical net.peer|host.name att…
lmolkova Jul 13, 2022
95338c6
Align log sdk naming with api (#2768)
jack-berg Sep 13, 2022
a82836b
Define semantic conventions yaml for non-otlp conventions (#2850)
bogdandrutu Oct 25, 2022
e7e679d
Add log attribute limit configuration (#2861)
alanwest Jan 27, 2023
cfcd551
Mark Attribute naming conventions as stable. (#3220)
jsuereth Feb 23, 2023
229c66c
Rename Optional attribute requirement level to Opt-In (#3228)
trask Mar 1, 2023
33069b0
Proofread of attribute requirement levels in preparation for stabilit…
trask Mar 6, 2023
0089575
Attribute requirement level follow-up edits (#3293)
trask Mar 7, 2023
c9c56e0
Clarify that attribute requirement levels apply to instrumentation li…
trask Mar 16, 2023
9cf537a
Mark attribute requirement levels as stable (#3368)
trask Apr 7, 2023
32292d9
[editorial] Use path, not external URL, for link into glossary (#3375)
chalin Apr 7, 2023
c5237e8
BREAKING: Replace `net.peer.*`/`net.host.*` with `client.*`/`server.*…
lmolkova May 8, 2023
cf7de34
BREAKING: Rename remaining network attributes from `net.*` to `networ…
trask May 9, 2023
a99da5e
BREAKING: Introduce common `url.*` attributes, and improve use of nam…
lmolkova May 9, 2023
c98792c
Explain why custom attributes are not recommended to be placed in Ote…
tigrannajaryan May 26, 2023
e40b6d5
[editorial] Hugo front-matter fixes for aliases and linkTitle (#3592)
chalin Jul 12, 2023
d028b06
Remove local stubs of semantic conventions. (#3711)
jsuereth Oct 3, 2023
093bd1f
Add a new AddLink() operation to Span. (#3678)
carlosalberto Oct 10, 2023
33d1c2f
Rename/replace `(client|server).socket.(address|port)` attributes wit…
trask Oct 23, 2023
dc5e136
Move attribute documents to semantic-conventions repository (#3758)
jack-berg Nov 24, 2023
1d52d31
Merge remote-tracking branch 'remotes/spec/main' into move-attribute-…
joaopgrassi Jan 10, 2024
5ab265d
Remove unwanted files and update links to spec repo
joaopgrassi Jan 10, 2024
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
158 changes: 158 additions & 0 deletions docs/general/attribute-definition.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
<!--- Hugo front matter used to generate the website version of this page:
--->

# Attribute definition

**Status**: [Stable, Feature-freeze][DocumentStatus]

<details>
<summary>Table of Contents</summary>

<!-- toc -->

- [Attribute](#attribute)
* [Attribute Limits](#attribute-limits)
+ [Configurable Parameters](#configurable-parameters)
+ [Exempt Entities](#exempt-entities)
- [Attribute Collections](#attribute-collections)

<!-- tocstop -->

</details>

## Attribute

<a id="attributes"></a>

An `Attribute` is a key-value pair, which MUST have the following properties:

- The attribute key MUST be a non-`null` and non-empty string.
- Case sensitivity of keys is preserved. Keys that differ in casing are treated as distinct keys.
- The attribute value is either:
- A primitive type: string, boolean, double precision floating point (IEEE 754-1985) or signed 64 bit integer.
- An array of primitive type values. The array MUST be homogeneous,
i.e., it MUST NOT contain values of different types.

For protocols that do not natively support non-string values, non-string values SHOULD be represented as JSON-encoded strings. For example, the expression `int64(100)` will be encoded as `100`, `float64(1.5)` will be encoded as `1.5`, and an empty array of any type will be encoded as `[]`.

Attribute values expressing a numerical value of zero, an empty string, or an
empty array are considered meaningful and MUST be stored and passed on to
processors / exporters.

Attribute values of `null` are not valid and attempting to set a `null` value is
undefined behavior.

`null` values SHOULD NOT be allowed in arrays. However, if it is impossible to
make sure that no `null` values are accepted
(e.g. in languages that do not have appropriate compile-time type checking),
`null` values within arrays MUST be preserved as-is (i.e., passed on to span
processors / exporters as `null`). If exporters do not support exporting `null`
values, they MAY replace those values by 0, `false`, or empty strings.
This is required for map/dictionary structures represented as two arrays with
indices that are kept in sync (e.g., two attributes `header_keys` and `header_values`,
both containing an array of strings to represent a mapping
`header_keys[i] -> header_values[i]`).

See [Attribute Naming](attribute-naming.md) for naming guidelines.

See [Requirement Level](attribute-requirement-level.md) for requirement levels guidelines.

See
[Mapping Arbitrary Data to OTLP AnyValue](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/common/attribute-type-mapping.md)
to find out how to map values obtained
outside OpenTelemetry into OpenTelemetry attribute values.

### Attribute Limits

Execution of erroneous code can result in unintended attributes. If there are no
limits placed on attributes, they can quickly exhaust available memory, resulting
in crashes that are difficult to recover from safely.

By default an SDK SHOULD apply truncation as per the list of
[configurable parameters](#configurable-parameters) below.

If an SDK provides a way to:
Comment on lines +71 to +74
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this document belongs into the semantic conventions repository, as it mostly contains requirements that need to be implemented by SDKs.


- set an attribute value length limit such that for each
attribute value:
- if it is a string, if it exceeds that limit (counting any character in it as
1), SDKs MUST truncate that value, so that its length is at most equal
to the limit,
- if it is an array of strings, then apply the above rule to each of the
values separately,
- otherwise a value MUST NOT be truncated;
- set a limit of unique attribute keys such that:
- for each unique attribute key, addition of which would result in exceeding
the limit, SDK MUST discard that key/value pair.

There MAY be a log emitted to indicate to the user that an attribute was
truncated or discarded. To prevent excessive logging, the log MUST NOT be
emitted more than once per record on which an attribute is set.

If the SDK implements the limits above, it MUST provide a way to change these
limits programmatically. Names of the configuration options SHOULD be the same as
in the list below.

An SDK MAY implement model-specific limits, for example
`SpanAttributeCountLimit` or `LogRecordAttributeCountLimit`. If both a general
and a model-specific limit are implemented, then the SDK MUST first attempt to
use the model-specific limit, if it isn't set, then the SDK MUST attempt to use
the general limit. If neither are defined, then the SDK MUST try to use the
model-specific limit default value, followed by the global limit default value.

#### Configurable Parameters

* `AttributeCountLimit` (Default=128) - Maximum allowed attribute count per record;
* `AttributeValueLengthLimit` (Default=Infinity) - Maximum allowed attribute value length;

#### Exempt Entities

Resource attributes SHOULD be exempt from the limits described above as resources
are not susceptible to the scenarios (auto-instrumentation) that result in
excessive attributes count or size. Resources are also sent only once per batch
instead of per span so it is relatively cheaper to have more/larger attributes
on them. Resources are also immutable by design and they are generally passed
down to TracerProvider along with limits. This makes it awkward to implement
attribute limits for Resources.

Attributes, which belong to Metrics, are exempt from the limits described above
at this time, as discussed in
[Metrics Attribute Limits](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk.md#attribute-limits).

## Attribute Collections

[Resources](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/resource/sdk.md), Metrics
[data points](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/data-model.md#metric-points),
[Spans](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/api.md#set-attributes), Span
[Events](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/api.md#add-events), Span
[Links](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/api.md#link) and
[Log Records](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/logs/data-model.md) may contain a collection of attributes. The
keys in each such collection are unique, i.e. there MUST NOT exist more than one
key-value pair with the same key. The enforcement of uniqueness may be performed
in a variety of ways as it best fits the limitations of the particular
implementation.

Normally for the telemetry generated using OpenTelemetry SDKs the attribute
key-value pairs are set via an API that either accepts a single key-value pair
or a collection of key-value pairs. Setting an attribute with the same key as an
existing attribute SHOULD overwrite the existing attribute's value. See for
example Span's
[SetAttribute](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/api.md#set-attributes)
API.

A typical implementation of
[SetAttribute](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/api.md#set-attributes)
API will enforce the uniqueness by overwriting any existing attribute values pending
to be exported, so that when the Span is eventually exported the exporters see
only unique attributes. The OTLP format in particular requires that exported
Resources, Spans, Metric data points and Log Records contain only unique
attributes.

Some other implementations may use a streaming approach where every
[SetAttribute](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/api.md#set-attributes)
API call immediately results in that individual attribute value being exported
using a streaming wire protocol. In such cases the enforcement of uniqueness
will likely be the responsibility of the recipient of this data.

[DocumentStatus]:
https://github.com/open-telemetry/opentelemetry-specification/tree/v1.26.0/specification/document-status.md
Loading