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

Define how Schema URL works for Resources #1692

Merged
Show file tree
Hide file tree
Changes from all 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 @@ -21,6 +21,10 @@ release.

### Logs

### Resource

- Add schema_url support to `Resource`. ([#1692](https://github.com/open-telemetry/opentelemetry-specification/pull/1692))

### Semantic Conventions

- Add JSON RPC specific conventions ([#1643](https://github.com/open-telemetry/opentelemetry-specification/pull/1643)).
Expand Down
24 changes: 24 additions & 0 deletions specification/resource/sdk.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ object. A factory method is recommended to enable support for cached objects.
Required parameters:

- [`Attributes`](../common/common.md#attributes)
- [since 1.4.0] `schema_url` (optional): Specifies the Schema URL that should be
recorded in the emitted resource. If the `schema_url` parameter is unspecified
then the created resource will have an empty Schema URL.

### Merge

Expand All @@ -70,6 +73,17 @@ The resulting resource MUST have all attributes that are on any of the two input
If a key exists on both the old and updating resource, the value of the updating
resource MUST be picked (even if the updated value is empty).

The resulting resource will have the Schema URL calculated as follows:

- If the old resource's Schema URL is empty then the resulting resource's Schema
URL will be set to the Schema URL of the updating resource,
- Else if the updating resource's Schema URL is empty then the resulting
resource's Schema URL will be set to the Schema URL of the old resource,
- Else if the Schema URLs of the old and updating resources are the same then
that will be the Schema URL of the resulting resource,
- Else this is a merging error (this is the case when the Schema URL of the old
and updating resources are not empty and are different).

Required parameters:

- the old resource
Expand Down Expand Up @@ -102,6 +116,16 @@ failure to detect any resource information MUST NOT be considered an error,
whereas an error that occurs during an attempt to detect resource information
SHOULD be considered an error.

Resource detectors that populate resource attributes according to OpenTelemetry
semantic conventions MUST ensure that the resource has a Schema URL set to a
value that matches the semantic conventions. Empty Schema URL SHOULD be used if
the detector does not populate the resource with any known attributes that have
a semantic convention or if the detector does not know what attributes it will
populate (e.g. the detector that reads the attributes from environment values
will not know what Schema URL to use). If multiple detectors are combined and
the detectors use different non-empty Schema URL it MUST be an error since it is
impossible to merge such resources.

### Specifying resource information via an environment variable

The SDK MUST extract information from the `OTEL_RESOURCE_ATTRIBUTES` environment
Expand Down