Skip to content

Commit

Permalink
Merge branch 'main' into add-validator
Browse files Browse the repository at this point in the history
  • Loading branch information
codeboten authored Aug 20, 2024
2 parents b2b7c83 + 50fbb1f commit 854033d
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Unreleased

* Adding initial instrumentation configuration schema
* Split MetricExporter into PullMetricExporter and PushMetricExporter and ensure only PushMetricExporters can be associated with PeriodicMetricReader [#110](https://github.com/open-telemetry/opentelemetry-configuration/pull/110)

## [v0.2.0] - 2024-05-08

Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ This repository contains the JSON schema that defines the OpenTelemetry configur

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

- [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.
- [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.
- [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][].

[env var substitution]: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/file-configuration.md#environment-variable-substitution
Expand Down Expand Up @@ -63,3 +63,9 @@ When a property requires pattern matching, use wildcard `*` (match any number of
* Given `excluded: ["a*"]`: Match all except values starting with `a`.
* Given `included: ["a*", "b*"]`, `excluded: ["ab*"]`: Match any value starting with `a` or `b`, excluding values starting with `ab`.
* Given `included: ["a", "b"]`, `excluded: ["a"]`: Match values equal to `b`.

### Data modeling and environment variable substitution

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.

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.
6 changes: 5 additions & 1 deletion examples/kitchen-sink.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -406,14 +406,18 @@ tracer_provider:

# Configure resource for all signals.
resource:
# Configure resource attributes.
# Configure resource attributes. Entries have higher priority than entries from .resource.attributes_list.
#
# Environment variable: OTEL_RESOURCE_ATTRIBUTES
attributes:
# Configure `service.name` resource attribute
#
# Environment variable: OTEL_SERVICE_NAME
service.name: !!str "unknown_service"
# Configure resource attributes. Entries have lower priority than entries from .resource.attributes.
#
# 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.
attributes_list: "service.namespace=my-namespace,service.version=1.0.0"
# Configure resource detectors.
detectors:
# Configure attributes provided by resource detectors.
Expand Down
7 changes: 5 additions & 2 deletions examples/sdk-migration-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
# for more information. The following spec defined env vars are NOT referenced and are thus
# ignored:
#
# - OTEL_RESOURCE_ATTRIBUTES
# - OTEL_LOG_LEVEL
# - OTEL_PROPAGATORS
# - OTEL_TRACES_SAMPLER
Expand Down Expand Up @@ -45,10 +44,14 @@ disabled: ${OTEL_SDK_DISABLED:-false}

# Configure resource for all signals.
resource:
# Configure resource attributes.
# Configure resource attributes. Entries have higher priority than entries from .resource.attributes_list.
attributes:
# Configure `service.name` resource attribute
service.name: ${OTEL_SERVICE_NAME:-unknown_service}
# Configure resource attributes. Entries have lower priority than entries from .resource.attributes.
#
# 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.
attributes_list: ${OTEL_RESOURCE_ATTRIBUTES}

# Configure general attribute limits. See also tracer_provider.limits, logger_provider.limits.
attribute_limits:
Expand Down
21 changes: 17 additions & 4 deletions schema/meter_provider.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"minimum": 0
},
"exporter": {
"$ref": "#/$defs/MetricExporter"
"$ref": "#/$defs/PushMetricExporter"
}
},
"required": [
Expand All @@ -45,15 +45,15 @@
"additionalProperties": false,
"properties": {
"exporter": {
"$ref": "#/$defs/MetricExporter"
"$ref": "#/$defs/PullMetricExporter"
}
},
"required": [
"exporter"
],
"title": "PullMetricReader"
},
"MetricExporter": {
"PushMetricExporter": {
"type": ["object", "null"],
"additionalProperties": true,
"minProperties": 1,
Expand All @@ -64,7 +64,20 @@
},
"console": {
"$ref": "common.json#/$defs/Console"
},
}
},
"patternProperties": {
".*": {
"type": ["object", "null"]
}
}
},
"PullMetricExporter": {
"type": ["object", "null"],
"additionalProperties": true,
"minProperties": 1,
"maxProperties": 1,
"properties": {
"prometheus": {
"$ref": "#/$defs/Prometheus"
}
Expand Down
3 changes: 3 additions & 0 deletions schema/resource.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
},
"schema_url": {
"type": ["string", "null"]
},
"attributes_list": {
"type": ["string", "null"]
}
},
"$defs": {
Expand Down

0 comments on commit 854033d

Please sign in to comment.