diff --git a/README.md b/README.md index 292fd45b..4a6c0a02 100644 --- a/README.md +++ b/README.md @@ -7,9 +7,10 @@ This repository contains the JSON schema definitions of the OpenTelemetry [decla ## Starter templates The [examples](./examples) directory 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 env vars](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md) which map cleanly to declarative configuration (see notes in the example for the set of env vars that 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][]. + +* [getting-started.yaml](./examples/getting-started.yaml): A typical default configuration file to get started with declarative configuration. This is a good starting point if you are new to declarative 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 declarative configuration (see notes in the example for the set of env vars that 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 a comprehensive default configuration. This is a good starting point if you wish to have a template with more settings than `getting-started.yaml` and 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][]. ## Code generation diff --git a/examples/getting-started.yaml b/examples/getting-started.yaml new file mode 100644 index 00000000..30d88f37 --- /dev/null +++ b/examples/getting-started.yaml @@ -0,0 +1,55 @@ +# getting-started.yaml is a good starting point for configuring the SDK, including exporting to +# localhost via OTLP. +# +# NOTE: With the exception of env var substitution syntax (i.e. ${MY_ENV}), SDKs ignore +# environment variables when interpreting config files. This including ignoring all env +# vars defined in https://opentelemetry.io/docs/specs/otel/configuration/sdk-environment-variables/. +# +# For schema documentation, including required properties, semantics, default behavior, etc, +# see: https://github.com/open-telemetry/opentelemetry-configuration/blob/main/schema-docs.md + +file_format: "1.0-rc.2" + +resource: + # Read resource attributes from the OTEL_RESOURCE_ATTRIBUTES environment variable. + # This aligns well with the OpenTelemetry Operator and other deployment methods. + attributes_list: ${OTEL_RESOURCE_ATTRIBUTES} + detection/development: # /development properties may not be supported in all SDKs + detectors: + - service: # will add "service.instance.id" and "service.name" from the OTEL_SERVICE_NAME env var + - host: + - process: + - container: + +propagator: + composite: + - tracecontext: + - baggage: + +# Read backend endpoint from the OTEL_EXPORTER_OTLP_ENDPOINT environment variable. +# This aligns well with the OpenTelemetry Operator and other deployment methods. + +tracer_provider: + sampler: + parent_based: + root: + always_on: + processors: + - batch: + exporter: + otlp_http: + endpoint: ${OTEL_EXPORTER_OTLP_ENDPOINT:-http://localhost:4318}/v1/traces + +meter_provider: + readers: + - periodic: + exporter: + otlp_http: + endpoint: ${OTEL_EXPORTER_OTLP_ENDPOINT:-http://localhost:4318}/v1/metrics + +logger_provider: + processors: + - batch: + exporter: + otlp_http: + endpoint: ${OTEL_EXPORTER_OTLP_ENDPOINT:-http://localhost:4318}/v1/logs diff --git a/examples/sdk-config.yaml b/examples/sdk-config.yaml index 31e7dd28..3c8beebb 100644 --- a/examples/sdk-config.yaml +++ b/examples/sdk-config.yaml @@ -1,4 +1,4 @@ -# sdk-config.yaml is a typical starting point for configuring the SDK, including exporting to +# sdk-config.yaml is a comprehensive starting point for configuring the SDK, including exporting to # localhost via OTLP. # # NOTE: With the exception of env var substitution syntax (i.e. ${MY_ENV}), SDKs ignore diff --git a/examples/sdk-migration-config.yaml b/examples/sdk-migration-config.yaml index 188a52e6..f65654e9 100644 --- a/examples/sdk-migration-config.yaml +++ b/examples/sdk-migration-config.yaml @@ -56,7 +56,7 @@ tracer_provider: max_export_batch_size: ${OTEL_BSP_MAX_EXPORT_BATCH_SIZE:-512} exporter: otlp_http: - endpoint: ${OTEL_EXPORTER_OTLP_TRACES_ENDPOINT:-http://localhost:4318/v1/traces} + endpoint: ${OTEL_EXPORTER_OTLP_ENDPOINT:-http://localhost:4318}/v1/traces tls: ca_file: ${OTEL_EXPORTER_OTLP_TRACES_CERTIFICATE} key_file: ${OTEL_EXPORTER_OTLP_TRACES_CLIENT_KEY} @@ -90,7 +90,7 @@ meter_provider: timeout: ${OTEL_METRIC_EXPORT_TIMEOUT:-30000} exporter: otlp_http: - endpoint: ${OTEL_EXPORTER_OTLP_METRICS_ENDPOINT:-http://localhost:4318/v1/metrics} + endpoint: ${OTEL_EXPORTER_OTLP_ENDPOINT:-http://localhost:4318}/v1/metrics tls: ca_file: ${OTEL_EXPORTER_OTLP_METRICS_CERTIFICATE} key_file: ${OTEL_EXPORTER_OTLP_METRICS_CLIENT_KEY} @@ -110,7 +110,7 @@ logger_provider: max_export_batch_size: ${OTEL_BLRP_MAX_EXPORT_BATCH_SIZE:-512} exporter: otlp_http: - endpoint: ${OTEL_EXPORTER_OTLP_LOGS_ENDPOINT:-http://localhost:4318/v1/logs} + endpoint: ${OTEL_EXPORTER_OTLP_ENDPOINT:-http://localhost:4318}/v1/logs tls: ca_file: ${OTEL_EXPORTER_OTLP_LOGS_CERTIFICATE} key_file: ${OTEL_EXPORTER_OTLP_LOGS_CLIENT_KEY} diff --git a/validator/shelltests/examples.test b/validator/shelltests/examples.test index ff559aff..8d2b0bfe 100644 --- a/validator/shelltests/examples.test +++ b/validator/shelltests/examples.test @@ -1,6 +1,7 @@ make validator-validate-examples >>> +Validating getting-started.yaml Validating kitchen-sink.yaml Validating sdk-config.yaml Validating sdk-migration-config.yaml ->>>= 0 \ No newline at end of file +>>>= 0