Skip to content

Commit 50fbb1f

Browse files
jack-bergcodeboten
andauthored
Define modeling guidance for mismatches with standard env vars, add .resource.attribute_list (#106)
Co-authored-by: Alex Boten <223565+codeboten@users.noreply.github.com>
1 parent a6b2d44 commit 50fbb1f

4 files changed

Lines changed: 20 additions & 4 deletions

File tree

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ This repository contains the JSON schema that defines the OpenTelemetry configur
1212

1313
The [examples](./examples) repository contains a variety of sample configuration files to help get started and illustrate useful patterns. The following are noteworthy:
1414

15-
- [sdk-migration-config.yaml](./examples/sdk-migration-config.yaml): Includes env var substitution references to all [standard environment variables](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md) which map cleanly to file configuration (see notes in the example for the set of env vars which are not referenced). Note, SDKs parsing configuration files ignore all env vars besides those referenced via [env var substitution][]. This is a great starting point for transitioning from env var based configuration to file based configuration.
15+
- [sdk-migration-config.yaml](./examples/sdk-migration-config.yaml): Includes env var substitution references to all [standard env vars](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md) which map cleanly to file configuration (see notes in the example for the set of env vars which are not referenced). Note, SDKs parsing configuration files ignore all env vars besides those referenced via [env var substitution][]. This is a great starting point for transitioning from env var based configuration to file based configuration.
1616
- [sdk-config.yaml](./examples/sdk-config.yaml): Represents the typical default configuration. This is a good starting point if you are not using env var based configuration or wish to transition fully to file based configuration. Note, SDKs parsing configuration files ignore all env vars besides those referenced via [env var substitution][].
1717

1818
[env var substitution]: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/file-configuration.md#environment-variable-substitution
@@ -63,3 +63,9 @@ When a property requires pattern matching, use wildcard `*` (match any number of
6363
* Given `excluded: ["a*"]`: Match all except values starting with `a`.
6464
* Given `included: ["a*", "b*"]`, `excluded: ["ab*"]`: Match any value starting with `a` or `b`, excluding values starting with `ab`.
6565
* Given `included: ["a", "b"]`, `excluded: ["a"]`: Match values equal to `b`.
66+
67+
### Data modeling and environment variable substitution
68+
69+
Properties should be modeled using the most appropriate data structures and types to represent the information. This may result in a schema which doesn't support env var substitution for the [standard env vars](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md) where a type mismatch occurs. For example, the `OTEL_RESOURCE_ATTRIBUTES` env var is modeled as a string, consisting of a comma separated list of key-value pairs, which is not the natural way to model a mapping of key-value pairs in JSON schema.
70+
71+
In instances where there is a type mismatch between the JSON schema and equivalent standard env var, an alternative version of the property may be provided to resolve the mismatch. For example, resource attributes are configured at `.resource.attributes`, but `.resource.attributes_list` is available with a format matching that of `OTEL_RESOURCE_ATTRIBUTES`. Alternative properties are reserved for cases where there is a demonstrated need for platforms to be able to participate in configuration and there is no reasonable alternative.

examples/kitchen-sink.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,14 +406,18 @@ tracer_provider:
406406

407407
# Configure resource for all signals.
408408
resource:
409-
# Configure resource attributes.
409+
# Configure resource attributes. Entries have higher priority than entries from .resource.attributes_list.
410410
#
411411
# Environment variable: OTEL_RESOURCE_ATTRIBUTES
412412
attributes:
413413
# Configure `service.name` resource attribute
414414
#
415415
# Environment variable: OTEL_SERVICE_NAME
416416
service.name: !!str "unknown_service"
417+
# Configure resource attributes. Entries have lower priority than entries from .resource.attributes.
418+
#
419+
# The value is a list of comma separated key-value pairs, matching the format of OTEL_RESOURCE_ATTRIBUTES. See https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md#general-sdk-configuration for details.
420+
attributes_list: "service.namespace=my-namespace,service.version=1.0.0"
417421
# Configure resource detectors.
418422
detectors:
419423
# Configure attributes provided by resource detectors.

examples/sdk-migration-config.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
# for more information. The following spec defined env vars are NOT referenced and are thus
1515
# ignored:
1616
#
17-
# - OTEL_RESOURCE_ATTRIBUTES
1817
# - OTEL_LOG_LEVEL
1918
# - OTEL_PROPAGATORS
2019
# - OTEL_TRACES_SAMPLER
@@ -45,10 +44,14 @@ disabled: ${OTEL_SDK_DISABLED:-false}
4544

4645
# Configure resource for all signals.
4746
resource:
48-
# Configure resource attributes.
47+
# Configure resource attributes. Entries have higher priority than entries from .resource.attributes_list.
4948
attributes:
5049
# Configure `service.name` resource attribute
5150
service.name: ${OTEL_SERVICE_NAME:-unknown_service}
51+
# Configure resource attributes. Entries have lower priority than entries from .resource.attributes.
52+
#
53+
# The value is a list of comma separated key-value pairs, matching the format of OTEL_RESOURCE_ATTRIBUTES. See https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md#general-sdk-configuration for details.
54+
attributes_list: ${OTEL_RESOURCE_ATTRIBUTES}
5255

5356
# Configure general attribute limits. See also tracer_provider.limits, logger_provider.limits.
5457
attribute_limits:

schema/resource.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
},
1414
"schema_url": {
1515
"type": ["string", "null"]
16+
},
17+
"attributes_list": {
18+
"type": ["string", "null"]
1619
}
1720
},
1821
"$defs": {

0 commit comments

Comments
 (0)