Skip to content
Open
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
32 changes: 23 additions & 9 deletions specification/configuration/sdk.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,15 +260,29 @@ 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 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` 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`.
Create requirements around default and null behavior are described below. Note that
[`defaultBehavior` and `nullBehavior`](https://github.com/open-telemetry/opentelemetry-configuration/blob/main/CONTRIBUTING.md#json-schema-source-and-output)
are defined in the configuration data model.

* If a property is present and the value is non-null, Create MUST use the value.
* If a property is not present, Create MUST use `defaultBehavior`.
* If a property is present and the value is null, Create MUST use the
`nullBehavior`, or `defaultBehavior` if `nullBehavior` is not set.
* If a property is required, and not present, Create MUST return an error.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the same behavior expected if a property is present but invalid, and not just when a property is present but null? Can we clarify that here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A property can be present and invalid in two ways:

  1. The value can fail to validate according to the JSON schema. I.e provide a string when a property required an integer. In this case, parse should have failed, since its responsible for parsing a content to an in memory model and ensuring it conforms to the schema.
  2. The value can be invalid according to the property semantics. I.e. HttpTls.key_file value is not a absolute path to a file. In this case, it would be up to create to return an error since its create that is interpreting the contents of the data model and mapping properties to equivalent programmatic config options of SDK components.

So after typing this, I actually think that the text I have here is adding responsibilities to create that actually belong in parse. In particular:

If a property is required, and not present, Create MUST return an error.

This is the responsibility of create.

I do think its worth discussing here that create is responsible for returning an error if a value is present, matches the JSON schema, BUT is invalid according to the property semantics which are described in the description.

* If a property is not nullable, and the value is null, Create MUST return an
error.

A few examples to illustrate:

* If configuring [`BatchSpanProcessor`](https://github.com/open-telemetry/opentelemetry-configuration/blob/main/schema-docs.md#batchspanprocessor-)
and `schedule_delay` is not present or present but null, the component is
configured according to the `defaultBehavior` of `5000`.
* If configuring `BatchSpanProcessor` and `exporter` is not present or present
but null, Create returns an error since `exporter` is required and not
nullable.
* If configuring [`SpanExporter`](https://github.com/open-telemetry/opentelemetry-configuration/blob/main/schema-docs.md#spanexporter)
and `console` is present and null, the component is configured with a
`console` exporter with default configuration since `console` is nullable.

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