Skip to content

Commit

Permalink
Declarative config: clarify null vs empty (open-telemetry#4269)
Browse files Browse the repository at this point in the history
Fixes open-telemetry#4181

cc @open-telemetry/configuration-approvers

---------

Co-authored-by: Robert Pająk <[email protected]>
  • Loading branch information
jack-berg and pellared authored Oct 28, 2024
1 parent eab9fb8 commit e107198
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 9 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ release.

### SDK Configuration

- Clarify declarative configuration parse requirements for null vs empty.
([#4269](https://github.com/open-telemetry/opentelemetry-specification/pull/4269))

### Common

### Supplementary Guidelines
Expand Down
2 changes: 1 addition & 1 deletion specification/configuration/data-model.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ results are allowed) and an error describing the parse failure to the user.

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

It MUST NOT be possible to inject YAML structures by environment variables. For
example, see references to `INVALID_MAP_VALUE` environment variable below.
Expand Down
34 changes: 26 additions & 8 deletions specification/configuration/sdk.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,24 @@ Parse and validate a [configuration file](./data-model.md#file-based-configurati

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

Parse MUST interpret null as equivalent to unset.
Parse MUST differentiate between properties that are missing and properties that
are present but null. For example, consider the following snippet,
noting `.meter_provider.views[0].stream.drop` is present but null:

```yaml
meter_provider:
views:
- selector:
name: some.metric.name
stream:
aggregation:
drop:
```

As a result, the view stream should be configured with the `drop` aggregation.
Note that some aggregations have additional arguments, but `drop` does not. The
user MUST not be required to specify an empty object (i.e. `drop: {}`) in these
cases.

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

If a field is null or unset and a default value is defined, Create MUST ensure
the SDK component is configured with the default value. If a field is null or
unset and no default value is defined, Create SHOULD return an error. For
example, if configuring
If a property has a default value defined (i.e. is _not_ required) and is
missing or present but null, Create MUST ensure the SDK component is configured
with the default value. If a property is required and is missing or present but
null, Create SHOULD return an error. For example, if configuring
the [span batching processor](../trace/sdk.md#batching-processor) and
the `scheduleDelayMillis` field is null or unset, the component is configured
with the default value of `5000`. However, if the `exporter` field is null or
unset, Create fails fast since there is no default value for `exporter`.
the `scheduleDelayMillis` property is missing or present but null, the component
is configured with the default value of `5000`. However, if the `exporter`
property is missing or present but null, Create fails fast since there is no
default value for `exporter`.

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

0 comments on commit e107198

Please sign in to comment.