Skip to content

Commit 74c6267

Browse files
authored
Add resource detector name (#4461)
All SDK extension plugin interfaces are referred to by name in declarative config. For SDK extension plugin interfaces like exporters, processors, metric readers, we have well-defined sets of built-in implementations. E.g.: - span exporter: otlp, otlp_file, console, zipkin - metric exporter: otlp, otlp_file, console - log exporter: otlp, otlp_file, console - span processor: simple, batch - metric reader: periodic, prometheus - log processor: simple, batch These well-defined names provide obvious choices to name things in the declarative config JSON schema. Resource detectors are currently much more open ended, with no defined list of built-in detectors. This is a problem for declarative config because we want to have a config story where you can plug the same YAML into different SDK language implementation and get the same behavior. Without defining this list, users will have to carefully lookup language-specific resource detector names and modify their YAML accordingly. Yikes. This PR solves this by: - Establishing that resource detectors have a name, used for reference in configuration (where declarative config is the primary use case but other config solutions could similarly use the name) - Provide normative language for naming resource detectors according the root namespace of attributes they (e.g. `os` resource detector populates `os.*` attributes) - Carve out a list of reserved resource detector names, which should become standard in SDK-implementations See also [https://github.com/open-telemetry/opentelemetry-configuration/pull/188](https://github.com/open-telemetry/opentelemetry-configuration/pull/188) for a reference at how these resource detector names are used in declarative configuration. cc @open-telemetry/configuration-approvers
1 parent 4f82878 commit 74c6267

File tree

2 files changed

+44
-1
lines changed

2 files changed

+44
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ release.
1919

2020
### Resource
2121

22+
- Add experimental resource detector name.
23+
([#4461](https://github.com/open-telemetry/opentelemetry-specification/pull/4461))
24+
2225
### Profiles
2326

2427
### OpenTelemetry Protocol

specification/resource/sdk.md

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Resource SDK
22

3-
**Status**: [Stable](../document-status.md)
3+
**Status**: [Stable](../document-status.md) except where otherwise specified
44

55
A [Resource](../overview.md#resources) is an immutable representation of the entity producing
66
telemetry as [Attributes](../common/README.md#attribute).
@@ -128,6 +128,46 @@ the detectors use different non-empty Schema URL it MUST be an error since it is
128128
impossible to merge such resources. The resulting resource is undefined, and its
129129
contents are implementation specific.
130130

131+
#### Resource detector name
132+
133+
**Status**: [Development](../document-status.md)
134+
135+
Resource detectors SHOULD have a unique name for reference in configuration. For
136+
example, users list and configure individual resource detectors by name
137+
in [declarative configuration](../configuration/README.md#declarative-configuration).
138+
Names SHOULD be [snake case](https://en.wikipedia.org/wiki/Snake_case) and
139+
consist of lowercase alphanumeric and `_` characters, which ensures they conform
140+
to declarative
141+
configuration [property name requirements](https://github.com/open-telemetry/opentelemetry-configuration/blob/main/CONTRIBUTING.md#property-name-case).
142+
143+
Resource detector names SHOULD reflect
144+
the [root namespace](https://github.com/open-telemetry/semantic-conventions/blob/main/docs/general/naming.md#general-naming-considerations)
145+
of attributes they populate. For example, a resource detector named `os`
146+
populates `os.*` attributes. Resource detectors which populate attributes from
147+
multiple root namespaces SHOULD choose a name which appropriately conveys their
148+
purpose.
149+
150+
An SDK which identifies multiple resource detectors with the same name SHOULD
151+
report an error. In order to limit collisions, resource detectors SHOULD
152+
document their name in a manner which is easily discoverable. Authors of
153+
resource detectors should check existing resource detectors to ensure their
154+
target name isn't already in use. Additionally, the following detector names are
155+
reserved for built-in resource detectors published with language SDKs:
156+
157+
* `container`:
158+
Populates [container.*](https://github.com/open-telemetry/semantic-conventions/blob/main/docs/resource/container.md)
159+
attributes.
160+
* `host`:
161+
Populates [host.*](https://github.com/open-telemetry/semantic-conventions/blob/main/docs/resource/host.md) and [os.*](https://github.com/open-telemetry/semantic-conventions/blob/main/docs/resource/os.md)
162+
attributes.
163+
* `process`:
164+
Populates [process.*](https://github.com/open-telemetry/semantic-conventions/blob/main/docs/resource/process.md)
165+
attributes.
166+
* `service`: Populates `service.name` based
167+
on [OTEL_SERVICE_NAME](../configuration/sdk-environment-variables.md#general-sdk-configuration)
168+
environment variable; populates `service.instance.id`
169+
as [defined here](https://github.com/open-telemetry/semantic-conventions/blob/main/docs/attributes-registry/service.md#service-attributes).
170+
131171
### Specifying resource information via an environment variable
132172

133173
The SDK MUST extract information from the `OTEL_RESOURCE_ATTRIBUTES` environment

0 commit comments

Comments
 (0)