You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Define sdk extension component support in file configuration (open-telemetry#3802)
Part of incorporating [OTEP
open-telemetry#225](open-telemetry/oteps#225) into the
specification.
Followup to open-telemetry#3744.
This defines how file configuration works with custom SDK extension
components (Samplers, Exporters, etc).
It defines the concept of a Component Provider:
- Component providers are registered with the type of extension
component they provide and a name. Component providers are registered
automatically or manually based on what is idiomatic in the language.
- Component providers have a Create Plugin method, which passes
configuration properties as a parameter and returns the configured
component
- When Create is called to interpret a file configuration model, and it
comes across a reference to a extension component which is not built-in,
it invokes Create Plugin on the corresponding component provider. If no
corresponding component provider exists, or if Create Plugin returns an
Error, Create returns an error.
Prototype implementation in java here:
open-telemetry/opentelemetry-java-examples#227
cc @open-telemetry/configuration-maintainers
@@ -142,6 +146,93 @@ to provide this in-memory representation in a manner that is idiomatic for their
142
146
language. If an SDK needs to expose a class or interface, the
143
147
name `Configuration` is RECOMMENDED.
144
148
149
+
### SDK Extension Components
150
+
151
+
The SDK supports a variety of
152
+
extension [plugin interfaces](../glossary.md#sdk-plugins), allowing users and
153
+
libraries to customize behaviors including the sampling, processing, and
154
+
exporting of data. In general, the [configuration model](#configuration-model)
155
+
defines specific types for built-in implementations of these plugin interfaces.
156
+
For example,
157
+
the [BatchSpanProcessor](https://github.com/open-telemetry/opentelemetry-configuration/blob/f38ac7c3a499ae5f81924ef9c455c27a56130562/schema/tracer_provider.json#L22)
158
+
type refers to the
159
+
built-in [Batching span processor](../trace/sdk.md#batching-processor). The
160
+
schema SHOULD also support the ability to specify custom implementations of
161
+
plugin interfaces defined by libraries or users.
162
+
163
+
For example, a custom [span exporter](../trace/sdk.md#span-exporter) might be configured as follows:
164
+
165
+
```yaml
166
+
tracer_provider:
167
+
processors:
168
+
- batch:
169
+
exporter:
170
+
my-exporter:
171
+
config-parameter: value
172
+
```
173
+
174
+
Here we specify that the tracer provider has a batch span processor
175
+
paired with a custom span exporter named `my-exporter`, which is configured
176
+
with `config-parameter: value`. For this configuration to succeed,
177
+
a [component provider](#component-provider) must
178
+
be [registered](#register-component-provider) with `type: SpanExporter`,
179
+
and `name: my-exporter`. When [parse](#parse) is called, the implementation will
180
+
encounter `my-exporter` and translate the corresponding configuration to an
181
+
equivalent generic `properties` representation (
182
+
i.e. `properties: {config-parameter: value}`). When [create](#create) is called,
183
+
the implementation will encounter `my-exporter` and
184
+
invoke [create plugin](#create-plugin) on the registered component provider
185
+
with the configuration `properties` determined during `parse`.
186
+
187
+
Given the inherent differences across languages, the details of extension
188
+
component mechanisms are likely to vary to a greater degree than is the case
189
+
with other APIs defined by OpenTelemetry. This is to be expected and is
190
+
acceptable so long as the implementation results in the defined behaviors.
191
+
192
+
#### Component Provider
193
+
194
+
A component provider is responsible for interpreting configuration and returning
195
+
an implementation of a particular type of SDK extension plugin interface.
196
+
197
+
Component providers are registered with an SDK implementation of configuration
198
+
via [register](#register-component-provider). This MAY be done automatically or
199
+
require manual intervention by the user based on what is possible and idiomatic
200
+
in the language ecosystem. For example in Java, component providers might be
201
+
registered automatically using
202
+
the [service provider interface (SPI)](https://docs.oracle.com/javase/tutorial/sound/SPI-intro.html)
203
+
mechanism.
204
+
205
+
See [create](#create), which details component provider usage in file
206
+
configuration interpretation.
207
+
208
+
#### Create Plugin
209
+
210
+
Interpret configuration to create a instance of a SDK extension plugin
211
+
interface.
212
+
213
+
**Parameters:**
214
+
215
+
* `properties` - The configuration properties. Properties MUST fully represent
216
+
the configuration as specified in
217
+
the [configuration file](#configuration-file), including the ability to access
218
+
scalars, mappings, and sequences (of scalars and other structures). It MUST be
219
+
possible to determine if a particular property is present. It SHOULD be
220
+
possible to access properties in a type safe manner, based on what is idiomatic
221
+
in the language.
222
+
223
+
**Returns:** A configured SDK extension plugin interface implementation.
224
+
225
+
The plugin interface MAY have properties which are optional or required, and
226
+
have specific requirements around type or format. The set of properties a
227
+
component provider accepts, along with their requirement level and expected
228
+
type, comprise a configuration schema. A component provider SHOULD document its
229
+
configuration schema.
230
+
231
+
When Create Plugin is invoked, the component provider interprets `properties`
232
+
and attempts to extract data according to its configuration schema. If this
233
+
fails (e.g. a required property is not present, a type is mismatches, etc.),
234
+
Create Plugin SHOULD return an error.
235
+
145
236
### Operations
146
237
147
238
SDK implementations of configuration MUST provide the following operations.
@@ -157,10 +248,6 @@ with OpAmp
157
248
158
249
Parse and validate a [configuration file](#configuration-file).
159
250
160
-
Parse MUST perform [environment variable substitution](#environment-variable-substitution).
161
-
162
-
Parse MUST interpret null as equivalent to unset.
163
-
164
251
**Parameters:**
165
252
166
253
* `file`: The [configuration file](#configuration-file) to parse. This MAY be a
@@ -173,7 +260,17 @@ Parse MUST interpret null as equivalent to unset.
0 commit comments