Skip to content

Commit 5feebb3

Browse files
Define how Schema URL works for Resources
This adds to the Resource SDK the concept of Schema URL proposed in OTEP 0152: https://github.com/open-telemetry/oteps/blob/main/text/0152-telemetry-schemas.md Related earlier PR that adds the Schema URL to the API: #1666
1 parent 31122cd commit 5feebb3

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ release.
2121

2222
### Logs
2323

24+
### Resource
25+
26+
- Add schema_url support to `Resource`. ([#1692](https://github.com/open-telemetry/opentelemetry-specification/pull/1692))
27+
2428
### Semantic Conventions
2529

2630
- Add JSON RPC specific conventions ([#1643](https://github.com/open-telemetry/opentelemetry-specification/pull/1643)).

specification/resource/sdk.md

+24
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ object. A factory method is recommended to enable support for cached objects.
5656
Required parameters:
5757

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

6063
### Merge
6164

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

76+
The resulting resource will have the Schema URL calculated as follows:
77+
78+
- If the old resource's Schema URL is empty then the resulting resource's Schema
79+
URL will be set to the Schema URL of the updating resource,
80+
- Else if the updating resource's Schema URL is empty then the resulting
81+
resource's Schema URL will be set to the Schema URL of the old resource,
82+
- Else if the Schema URLs of the old and updating resources are the same then
83+
that will be the Schema URL of the resulting resource,
84+
- Else this is a merging error (this is the case when the Schema URL of the old
85+
and updating resources are not empty and are different).
86+
7387
Required parameters:
7488

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

119+
Resource detectors that populate resource attributes according to OpenTelemetry
120+
semantic conventions MUST ensure that the resource has a Schema URL set to a
121+
value that matches the semantic conventions. Empty Schema URL SHOULD be used if
122+
the detector does not populate the resource with any known attributes that have
123+
a semantic convention or if the detector does not know what attributes it will
124+
populate (e.g. the detector that reads the attributes from environment values
125+
will not know what Schema URL to use). If multiple detectors are combined and
126+
the detectors use different non-empty Schema URL it MUST be an error since it is
127+
impossible to merge such resources.
128+
105129
### Specifying resource information via an environment variable
106130

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

0 commit comments

Comments
 (0)