Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sdk-config.yaml starter template w/ references to env vars #76

Merged
merged 13 commits into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@
# Node.js files for tools (e.g. markdown-toc)
node_modules/
package-lock.json

# Output directory after applying env substitution
out
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
SCHEMA_FILES := $(shell find . -path './schema/*.json' -exec basename {} \; | sort)
EXAMPLE_FILES := $(shell find . -path './examples/*.yaml' | sort)
EXAMPLE_FILES := $(shell find . -path './examples/*.yaml' -exec basename {} \; | sort)
$(shell mkdir -p out)

.PHONY: all
all: install-tools compile-schema validate-examples
Expand All @@ -16,7 +17,8 @@ compile-schema:
validate-examples:
@if ! npm ls ajv-cli; then npm install; fi
@for f in $(EXAMPLE_FILES); do \
npx --no ajv-cli validate --spec=draft2020 --allow-matching-properties --errors=text -s ./schema/opentelemetry_configuration.json -r "./schema/!(opentelemetry_configuration.json)" -d $$f \
npx envsub ./examples/$$f ./out/$$f || exit 1; \
npx --no ajv-cli validate --spec=draft2020 --allow-matching-properties --errors=text -s ./schema/opentelemetry_configuration.json -r "./schema/!(opentelemetry_configuration.json)" -d ./out/$$f \
|| exit 1; \
done

Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ This repository contains the JSON schema that defines the OpenTelemetry configur
- code generation
- broad support across languages

## Starter templates

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-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

## Code generation

There are [several tools](https://json-schema.org/implementations.html) available to generate code from a JSON schema. The following shows an example for generating code from the JSON schema in Go:
Expand Down
4 changes: 3 additions & 1 deletion examples/anchors.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ file_format: "0.1"
exporters:
otlp: &otlp-exporter
protocol: http/protobuf
endpoint: http://localhost:4318
certificate: /app/cert.pem
client_key: /app/cert.pem
client_certificate: /app/cert.pem
Expand All @@ -20,6 +19,7 @@ logger_provider:
otlp:
# expand the otlp-exporter anchor
<<: *otlp-exporter
endpoint: http://localhost:4318/v1/logs

meter_provider:
readers:
Expand All @@ -30,6 +30,7 @@ meter_provider:
otlp:
# expand the otlp-exporter anchor and add metric specific configuration
<<: *otlp-exporter
endpoint: http://localhost:4318/v1/metrics
temporality_preference: delta
default_histogram_aggregation: base2_exponential_bucket_histogram

Expand All @@ -40,3 +41,4 @@ tracer_provider:
otlp:
# expand the otlp-exporter anchor
<<: *otlp-exporter
endpoint: http://localhost:4318/v1/traces
6 changes: 3 additions & 3 deletions examples/kitchen-sink.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ logger_provider:
# Configure endpoint.
#
# Environment variable: OTEL_EXPORTER_OTLP_ENDPOINT, OTEL_EXPORTER_OTLP_LOGS_ENDPOINT
endpoint: http://localhost:4318
endpoint: http://localhost:4318/v1/logs
# Configure certificate.
#
# Environment variable: OTEL_EXPORTER_OTLP_CERTIFICATE, OTEL_EXPORTER_OTLP_LOGS_CERTIFICATE
Expand Down Expand Up @@ -169,7 +169,7 @@ meter_provider:
# Configure endpoint.
#
# Environment variable: OTEL_EXPORTER_OTLP_ENDPOINT, OTEL_EXPORTER_OTLP_METRICS_ENDPOINT
endpoint: http://localhost:4318
endpoint: http://localhost:4318/v1/metrics
# Configure certificate.
#
# Environment variable: OTEL_EXPORTER_OTLP_CERTIFICATE, OTEL_EXPORTER_OTLP_METRICS_CERTIFICATE
Expand Down Expand Up @@ -293,7 +293,7 @@ tracer_provider:
# Configure endpoint.
#
# Environment variable: OTEL_EXPORTER_OTLP_ENDPOINT, OTEL_EXPORTER_OTLP_TRACES_ENDPOINT
endpoint: http://localhost:4318
endpoint: http://localhost:4318/v1/traces
# Configure certificate.
#
# Environment variable: OTEL_EXPORTER_OTLP_CERTIFICATE, OTEL_EXPORTER_OTLP_TRACES_CERTIFICATE
Expand Down
179 changes: 179 additions & 0 deletions examples/sdk-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
# sdk-config.yaml is a typical 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/.

# The file format version
file_format: "0.1"

# Configure if the SDK is disabled or not.
disabled: false

# Configure resource for all signals.
resource:
# Configure resource attributes.
attributes:
# Configure `service.name` resource attribute
service.name: unknown_service

# Configure general attribute limits. See also tracer_provider.limits, logger_provider.limits.
attribute_limits:
# Configure max attribute value size.
attribute_value_length_limit:
# Configure max attribute count.
attribute_count_limit: 128

# Configure text map context propagators.
propagator:
composite: [tracecontext, baggage]

# Configure tracer provider.
tracer_provider:
# Configure span processors.
processors:
# Configure a batch span processor.
- batch:
# Configure delay interval (in milliseconds) between two consecutive exports.
schedule_delay: 5000
# Configure maximum allowed time (in milliseconds) to export data.
export_timeout: 30000
# Configure maximum queue size.
max_queue_size: 2048
# Configure maximum batch size.
max_export_batch_size: 512
# Configure exporter.
exporter:
# Configure exporter to be OTLP.
otlp:
# Configure protocol.
protocol: http/protobuf
# Configure endpoint.
endpoint: http://localhost:4318/v1/traces
# Configure certificate.
certificate:
# Configure mTLS private client key.
client_key:
# Configure mTLS client certificate.
client_certificate:
# Configure compression.
compression: gzip
# Configure max time (in milliseconds) to wait for each export.
timeout: 10000
# Configure headers:
headers: {}
# Configure span limits. See also attribute_limits.
limits:
# Configure max span attribute value size. Overrides attribute_limits.attribute_value_length_limit.
attribute_value_length_limit:
# Configure max span attribute count. Overrides attribute_limits.attribute_count_limit.
attribute_count_limit: 128
# Configure max span event count.
event_count_limit: 128
# Configure max span link count.
link_count_limit: 128
# Configure max attributes per span event.
event_attribute_count_limit: 128
# Configure max attributes per span link.
link_attribute_count_limit: 128
# Configure the sampler.
sampler:
# Configure sampler to be parent_based. Known values include: always_off, always_on, jaeger_remote, parent_based, trace_id_ratio_based.
parent_based:
# Configure root sampler.
root:
# Configure sampler to be always_on.
always_on: {}
# Configure remote_parent_sampled sampler.
remote_parent_sampled:
# Configure sampler to be always_on.
always_on: {}
# Configure remote_parent_not_sampled sampler.
remote_parent_not_sampled:
# Configure sampler to be always_off.
always_off: {}
# Configure local_parent_sampled sampler.
local_parent_sampled:
# Configure sampler to be always_on.
always_on: {}
# Configure local_parent_not_sampled sampler.
local_parent_not_sampled:
# Configure sampler to be always_off.
always_off: {}

# Configure meter provider.
meter_provider:
# Configure metric readers.
readers:
# Configure a periodic metric reader.
- periodic:
# Configure delay interval (in milliseconds) between start of two consecutive exports.
interval: 60000
# Configure maximum allowed time (in milliseconds) to export data.
timeout: 30000
# Configure exporter.
exporter:
# Configure exporter to be OTLP.
otlp:
# Configure protocol.
protocol: http/protobuf
# Configure endpoint.
endpoint: http://localhost:4318/v1/metrics
# Configure certificate.
certificate:
# Configure mTLS private client key.
client_key:
# Configure mTLS client certificate.
client_certificate:
# Configure compression.
compression: gzip
# Configure max time (in milliseconds) to wait for each export.
timeout: 10000
# Configure headers:
headers: {}
# Configure temporality preference.
temporality_preference: cumulative
# Configure default histogram aggregation.
default_histogram_aggregation: explicit_bucket_histogram

# Configure logger provider.
logger_provider:
# Configure log record processors.
processors:
# Configure a batch log record processor.
- batch:
# Configure delay interval (in milliseconds) between two consecutive exports.
schedule_delay: 1000
# Configure maximum allowed time (in milliseconds) to export data.
export_timeout: 30000
# Configure maximum queue size.
max_queue_size: 2048
# Configure maximum batch size.
max_export_batch_size: 512
# Configure exporter.
exporter:
# Configure exporter to be OTLP.
otlp:
# Configure protocol.
protocol: http/protobuf
# Configure endpoint.
endpoint: http://localhost:4318/v1/logs
# Configure certificate.
certificate:
# Configure mTLS private client key.
client_key:
# Configure mTLS client certificate.
client_certificate:
# Configure compression.
compression: gzip
# Configure max time (in milliseconds) to wait for each export.
timeout: 10000
# Configure headers:
headers: {}
# Configure log record limits. See also attribute_limits.
limits:
# Configure max log record attribute value size. Overrides attribute_limits.attribute_value_length_limit.
attribute_value_length_limit:
# Configure max log record attribute count. Overrides attribute_limits.attribute_count_limit.
attribute_count_limit: 128
Loading
Loading