Skip to content

Commit cc7cd37

Browse files
jack-bergcodeboten
andauthored
Add sdk-config.yaml starter template w/ references to env vars (#76)
* Update schema to accept null values * Add sdk-config.yaml starter template * Split out starter with env vars and without * Fix typos, add links to examples from readme * Fix typo * Clarify comment in sdk-migration-config.yaml * Use signal specific env vars, ensure all endpoints include correct path * typos --------- Co-authored-by: Alex Boten <223565+codeboten@users.noreply.github.com>
1 parent 6709017 commit cc7cd37

15 files changed

+531
-122
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,6 @@
2121
# Node.js files for tools (e.g. markdown-toc)
2222
node_modules/
2323
package-lock.json
24+
25+
# Output directory after applying env substitution
26+
out

Makefile

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
SCHEMA_FILES := $(shell find . -path './schema/*.json' -exec basename {} \; | sort)
2-
EXAMPLE_FILES := $(shell find . -path './examples/*.yaml' | sort)
2+
EXAMPLE_FILES := $(shell find . -path './examples/*.yaml' -exec basename {} \; | sort)
3+
$(shell mkdir -p out)
34

45
.PHONY: all
56
all: install-tools compile-schema validate-examples
@@ -16,7 +17,8 @@ compile-schema:
1617
validate-examples:
1718
@if ! npm ls ajv-cli; then npm install; fi
1819
@for f in $(EXAMPLE_FILES); do \
19-
npx --no ajv-cli validate --spec=draft2020 --allow-matching-properties --errors=text -s ./schema/opentelemetry_configuration.json -r "./schema/!(opentelemetry_configuration.json)" -d $$f \
20+
npx envsub ./examples/$$f ./out/$$f || exit 1; \
21+
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 \
2022
|| exit 1; \
2123
done
2224

README.md

+9
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@ This repository contains the JSON schema that defines the OpenTelemetry configur
88
- code generation
99
- broad support across languages
1010

11+
## Starter templates
12+
13+
The [examples](./examples) repository contains a variety of sample configuration files to help get started and illustrate useful patterns. The following are noteworthy:
14+
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.
16+
- [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][].
17+
18+
[env var substitution]: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/file-configuration.md#environment-variable-substitution
19+
1120
## Code generation
1221

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

examples/anchors.yaml

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ file_format: "0.1"
44
exporters:
55
otlp: &otlp-exporter
66
protocol: http/protobuf
7-
endpoint: http://localhost:4318
87
certificate: /app/cert.pem
98
client_key: /app/cert.pem
109
client_certificate: /app/cert.pem
@@ -20,6 +19,7 @@ logger_provider:
2019
otlp:
2120
# expand the otlp-exporter anchor
2221
<<: *otlp-exporter
22+
endpoint: http://localhost:4318/v1/logs
2323

2424
meter_provider:
2525
readers:
@@ -30,6 +30,7 @@ meter_provider:
3030
otlp:
3131
# expand the otlp-exporter anchor and add metric specific configuration
3232
<<: *otlp-exporter
33+
endpoint: http://localhost:4318/v1/metrics
3334
temporality_preference: delta
3435
default_histogram_aggregation: base2_exponential_bucket_histogram
3536

@@ -40,3 +41,4 @@ tracer_provider:
4041
otlp:
4142
# expand the otlp-exporter anchor
4243
<<: *otlp-exporter
44+
endpoint: http://localhost:4318/v1/traces

examples/kitchen-sink.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ logger_provider:
6161
# Configure endpoint.
6262
#
6363
# Environment variable: OTEL_EXPORTER_OTLP_ENDPOINT, OTEL_EXPORTER_OTLP_LOGS_ENDPOINT
64-
endpoint: http://localhost:4318
64+
endpoint: http://localhost:4318/v1/logs
6565
# Configure certificate.
6666
#
6767
# Environment variable: OTEL_EXPORTER_OTLP_CERTIFICATE, OTEL_EXPORTER_OTLP_LOGS_CERTIFICATE
@@ -169,7 +169,7 @@ meter_provider:
169169
# Configure endpoint.
170170
#
171171
# Environment variable: OTEL_EXPORTER_OTLP_ENDPOINT, OTEL_EXPORTER_OTLP_METRICS_ENDPOINT
172-
endpoint: http://localhost:4318
172+
endpoint: http://localhost:4318/v1/metrics
173173
# Configure certificate.
174174
#
175175
# Environment variable: OTEL_EXPORTER_OTLP_CERTIFICATE, OTEL_EXPORTER_OTLP_METRICS_CERTIFICATE
@@ -293,7 +293,7 @@ tracer_provider:
293293
# Configure endpoint.
294294
#
295295
# Environment variable: OTEL_EXPORTER_OTLP_ENDPOINT, OTEL_EXPORTER_OTLP_TRACES_ENDPOINT
296-
endpoint: http://localhost:4318
296+
endpoint: http://localhost:4318/v1/traces
297297
# Configure certificate.
298298
#
299299
# Environment variable: OTEL_EXPORTER_OTLP_CERTIFICATE, OTEL_EXPORTER_OTLP_TRACES_CERTIFICATE

examples/sdk-config.yaml

+179
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
# sdk-config.yaml is a typical starting point for configuring the SDK, including exporting to
2+
# localhost via OTLP.
3+
4+
# NOTE: With the exception of env var substitution syntax (i.e. ${MY_ENV}), SDKs ignore
5+
# environment variables when interpreting config files. This including ignoring all env
6+
# vars defined in https://opentelemetry.io/docs/specs/otel/configuration/sdk-environment-variables/.
7+
8+
# The file format version
9+
file_format: "0.1"
10+
11+
# Configure if the SDK is disabled or not.
12+
disabled: false
13+
14+
# Configure resource for all signals.
15+
resource:
16+
# Configure resource attributes.
17+
attributes:
18+
# Configure `service.name` resource attribute
19+
service.name: unknown_service
20+
21+
# Configure general attribute limits. See also tracer_provider.limits, logger_provider.limits.
22+
attribute_limits:
23+
# Configure max attribute value size.
24+
attribute_value_length_limit:
25+
# Configure max attribute count.
26+
attribute_count_limit: 128
27+
28+
# Configure text map context propagators.
29+
propagator:
30+
composite: [tracecontext, baggage]
31+
32+
# Configure tracer provider.
33+
tracer_provider:
34+
# Configure span processors.
35+
processors:
36+
# Configure a batch span processor.
37+
- batch:
38+
# Configure delay interval (in milliseconds) between two consecutive exports.
39+
schedule_delay: 5000
40+
# Configure maximum allowed time (in milliseconds) to export data.
41+
export_timeout: 30000
42+
# Configure maximum queue size.
43+
max_queue_size: 2048
44+
# Configure maximum batch size.
45+
max_export_batch_size: 512
46+
# Configure exporter.
47+
exporter:
48+
# Configure exporter to be OTLP.
49+
otlp:
50+
# Configure protocol.
51+
protocol: http/protobuf
52+
# Configure endpoint.
53+
endpoint: http://localhost:4318/v1/traces
54+
# Configure certificate.
55+
certificate:
56+
# Configure mTLS private client key.
57+
client_key:
58+
# Configure mTLS client certificate.
59+
client_certificate:
60+
# Configure compression.
61+
compression: gzip
62+
# Configure max time (in milliseconds) to wait for each export.
63+
timeout: 10000
64+
# Configure headers:
65+
headers: {}
66+
# Configure span limits. See also attribute_limits.
67+
limits:
68+
# Configure max span attribute value size. Overrides attribute_limits.attribute_value_length_limit.
69+
attribute_value_length_limit:
70+
# Configure max span attribute count. Overrides attribute_limits.attribute_count_limit.
71+
attribute_count_limit: 128
72+
# Configure max span event count.
73+
event_count_limit: 128
74+
# Configure max span link count.
75+
link_count_limit: 128
76+
# Configure max attributes per span event.
77+
event_attribute_count_limit: 128
78+
# Configure max attributes per span link.
79+
link_attribute_count_limit: 128
80+
# Configure the sampler.
81+
sampler:
82+
# Configure sampler to be parent_based. Known values include: always_off, always_on, jaeger_remote, parent_based, trace_id_ratio_based.
83+
parent_based:
84+
# Configure root sampler.
85+
root:
86+
# Configure sampler to be always_on.
87+
always_on: {}
88+
# Configure remote_parent_sampled sampler.
89+
remote_parent_sampled:
90+
# Configure sampler to be always_on.
91+
always_on: {}
92+
# Configure remote_parent_not_sampled sampler.
93+
remote_parent_not_sampled:
94+
# Configure sampler to be always_off.
95+
always_off: {}
96+
# Configure local_parent_sampled sampler.
97+
local_parent_sampled:
98+
# Configure sampler to be always_on.
99+
always_on: {}
100+
# Configure local_parent_not_sampled sampler.
101+
local_parent_not_sampled:
102+
# Configure sampler to be always_off.
103+
always_off: {}
104+
105+
# Configure meter provider.
106+
meter_provider:
107+
# Configure metric readers.
108+
readers:
109+
# Configure a periodic metric reader.
110+
- periodic:
111+
# Configure delay interval (in milliseconds) between start of two consecutive exports.
112+
interval: 60000
113+
# Configure maximum allowed time (in milliseconds) to export data.
114+
timeout: 30000
115+
# Configure exporter.
116+
exporter:
117+
# Configure exporter to be OTLP.
118+
otlp:
119+
# Configure protocol.
120+
protocol: http/protobuf
121+
# Configure endpoint.
122+
endpoint: http://localhost:4318/v1/metrics
123+
# Configure certificate.
124+
certificate:
125+
# Configure mTLS private client key.
126+
client_key:
127+
# Configure mTLS client certificate.
128+
client_certificate:
129+
# Configure compression.
130+
compression: gzip
131+
# Configure max time (in milliseconds) to wait for each export.
132+
timeout: 10000
133+
# Configure headers:
134+
headers: {}
135+
# Configure temporality preference.
136+
temporality_preference: cumulative
137+
# Configure default histogram aggregation.
138+
default_histogram_aggregation: explicit_bucket_histogram
139+
140+
# Configure logger provider.
141+
logger_provider:
142+
# Configure log record processors.
143+
processors:
144+
# Configure a batch log record processor.
145+
- batch:
146+
# Configure delay interval (in milliseconds) between two consecutive exports.
147+
schedule_delay: 1000
148+
# Configure maximum allowed time (in milliseconds) to export data.
149+
export_timeout: 30000
150+
# Configure maximum queue size.
151+
max_queue_size: 2048
152+
# Configure maximum batch size.
153+
max_export_batch_size: 512
154+
# Configure exporter.
155+
exporter:
156+
# Configure exporter to be OTLP.
157+
otlp:
158+
# Configure protocol.
159+
protocol: http/protobuf
160+
# Configure endpoint.
161+
endpoint: http://localhost:4318/v1/logs
162+
# Configure certificate.
163+
certificate:
164+
# Configure mTLS private client key.
165+
client_key:
166+
# Configure mTLS client certificate.
167+
client_certificate:
168+
# Configure compression.
169+
compression: gzip
170+
# Configure max time (in milliseconds) to wait for each export.
171+
timeout: 10000
172+
# Configure headers:
173+
headers: {}
174+
# Configure log record limits. See also attribute_limits.
175+
limits:
176+
# Configure max log record attribute value size. Overrides attribute_limits.attribute_value_length_limit.
177+
attribute_value_length_limit:
178+
# Configure max log record attribute count. Overrides attribute_limits.attribute_count_limit.
179+
attribute_count_limit: 128

0 commit comments

Comments
 (0)