Skip to content

Commit ce097ec

Browse files
jack-bergpellared
andauthored
Declarative config: clarify null vs empty (#4269)
Fixes #4181 cc @open-telemetry/configuration-approvers --------- Co-authored-by: Robert Pająk <[email protected]>
1 parent 8548dfc commit ce097ec

File tree

3 files changed

+30
-9
lines changed

3 files changed

+30
-9
lines changed

CHANGELOG.md

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

3636
### SDK Configuration
3737

38+
- Clarify declarative configuration parse requirements for null vs empty.
39+
([#4269](https://github.com/open-telemetry/opentelemetry-specification/pull/4269))
40+
3841
### Common
3942

4043
### Supplementary Guidelines

specification/configuration/data-model.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ results are allowed) and an error describing the parse failure to the user.
8686

8787
Node types MUST be interpreted after environment variable substitution takes
8888
place. This ensures the environment string representation of boolean, integer,
89-
or floating point fields can be properly converted to expected types.
89+
or floating point properties can be properly converted to expected types.
9090

9191
It MUST NOT be possible to inject YAML structures by environment variables. For
9292
example, see references to `INVALID_MAP_VALUE` environment variable below.

specification/configuration/sdk.md

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,24 @@ Parse and validate a [configuration file](./data-model.md#file-based-configurati
179179

180180
Parse MUST perform [environment variable substitution](./data-model.md#environment-variable-substitution).
181181

182-
Parse MUST interpret null as equivalent to unset.
182+
Parse MUST differentiate between properties that are missing and properties that
183+
are present but null. For example, consider the following snippet,
184+
noting `.meter_provider.views[0].stream.drop` is present but null:
185+
186+
```yaml
187+
meter_provider:
188+
views:
189+
- selector:
190+
name: some.metric.name
191+
stream:
192+
aggregation:
193+
drop:
194+
```
195+
196+
As a result, the view stream should be configured with the `drop` aggregation.
197+
Note that some aggregations have additional arguments, but `drop` does not. The
198+
user MUST not be required to specify an empty object (i.e. `drop: {}`) in these
199+
cases.
183200

184201
When encountering a reference to
185202
a [SDK extension component](#sdk-extension-components) which is not built in to
@@ -212,14 +229,15 @@ Interpret configuration model and return SDK components.
212229
The multiple responses MAY be returned using a tuple, or some other data
213230
structure encapsulating the components.
214231

215-
If a field is null or unset and a default value is defined, Create MUST ensure
216-
the SDK component is configured with the default value. If a field is null or
217-
unset and no default value is defined, Create SHOULD return an error. For
218-
example, if configuring
232+
If a property has a default value defined (i.e. is _not_ required) and is
233+
missing or present but null, Create MUST ensure the SDK component is configured
234+
with the default value. If a property is required and is missing or present but
235+
null, Create SHOULD return an error. For example, if configuring
219236
the [span batching processor](../trace/sdk.md#batching-processor) and
220-
the `scheduleDelayMillis` field is null or unset, the component is configured
221-
with the default value of `5000`. However, if the `exporter` field is null or
222-
unset, Create fails fast since there is no default value for `exporter`.
237+
the `scheduleDelayMillis` property is missing or present but null, the component
238+
is configured with the default value of `5000`. However, if the `exporter`
239+
property is missing or present but null, Create fails fast since there is no
240+
default value for `exporter`.
223241

224242
When encountering a reference to
225243
a [SDK extension component](#sdk-extension-components) which is not built in to

0 commit comments

Comments
 (0)