This repository contains the JSON schema that defines the OpenTelemetry configuration. This schema can be utilized to generate model code for implementations and to validate the structure of a configuration file. The repository comes as a result of OTEP #225, where JSON schema was chosen for the following reasons:
The examples directory contains a variety of sample configuration files to help get started and illustrate useful patterns. The following are noteworthy:
There are several tools available to generate code from a JSON schema. The following shows an example for generating code from the JSON schema in Go:
go-jsonschema \
-p telemetry \
--schema-package=https://opentelemetry.io/otelconfig/opentelemetry_configuration.json=github.com/open-telemetry/opentelemetry-collector/schema \
./schema/opentelemetry_configuration.json
Before reaching 1.0, each minor version change is equivalent to major version change. That is, there are no guarantees about compatibility and all changes are permitted. As of 1.0, we provide the following stability guarantees:
Allowable changes:
The following rules are enforced when modeling the configuration schema:
Only properties which are described in opentelemetry-specification or semantic-conventions are modeled in the schema. However, it's acceptable to allow additional properties specific to a particular language or implementation, and not covered by the schema. Model these by setting "additionalProperties": true
(see JSON schema additionalProperties). Types should set "additionalProperties": false
by default unless requested by an opentelemetry component maintainer which supports additional options.
To remove redundant information from the configuration file, prefixes for data produced by each of the providers will be removed from configuration options. For example, under the meter_provider
configuration, metric readers are identified by the word readers
rather than by metric_readers
. Similarly, the prefix span_
will be dropped for tracer provider configuration, and logrecord
for logger provider.
Properties defined in the schema should be lower snake case.
When a property requires pattern matching, use wildcard *
(match any number of any character, including none) and ?
(match any single character) instead of regex. If a single property with wildcards is likely to be insufficient to model the configuration requirements, accept included
and excluded
properties, each with an array of strings with wildcard entries. The wildcard entries should be joined with a logical OR. If included
is not specified, assume that all entries are included. Apply excluded
after applying included
. Examples:
excluded: ["a*"]
: Match all except values starting with a
.included: ["a*", "b*"]
, excluded: ["ab*"]
: Match any value starting with a
or b
, excluding values starting with ab
.included: ["a", "b"]
, excluded: ["a"]
: Match values equal to b
.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 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.
When a type requires a configurable list of name-value pairs (i.e. resource attributes, HTTP headers), model using an array of objects, each with name
and value
properties. While an array of name-value objects is slightly more verbose than an object where each key-value is an entry, the latter is preferred because:
Allows both the names and the values to be targets for env var substitution. For example:
tracer_provider:
processors:
- batch:
exporter:
otlp:
headers:
- name: ${AUTHORIZATION_HEADER_NAME:-api-key}
value: ${AUTHORIZATION_HEADER_VALUE}
See CONTRIBUTING.md
Approvers (@open-telemetry/configuration-approvers):
Find more about the approver role in community repository.
Maintainers (@open-telemetry/configuration-maintainers):
Find more about the maintainer role in community repository.