Skip to content

Commit fcb8a93

Browse files
committed
feat(int-tel): expose trace sampling as env var
1 parent e4b76fd commit fcb8a93

File tree

1 file changed

+29
-10
lines changed

1 file changed

+29
-10
lines changed

examples/internal-telemetry-config.yaml

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@
22
# This configuration is intended to be used in conjunction with a configuration of components and pipelines. The
33
# collector supports config merging on startup.
44
##### Configuration via environment variables
5-
# For valid values, see: https://opentelemetry.io/docs/collector/internal-telemetry/
5+
# For official documentation, see: https://opentelemetry.io/docs/collector/internal-telemetry/
66
## Required
77
# - INTERNAL_TELEMETRY_NEW_RELIC_LICENSE_KEY
88
## Optional
9-
# - INTERNAL_TELEMETRY_SERVICE_NAME: determines entity name in New Relic
10-
# - INTERNAL_TELEMETRY_OTLP_ENDPOINT: defaults to https://otlp.nr-data.net (https://docs.newrelic.com/docs/opentelemetry/best-practices/opentelemetry-otlp/)
11-
# - INTERNAL_TELEMETRY_METRICS_LEVEL
12-
# - INTERNAL_TELEMETRY_LOG_LEVEL
9+
# - INTERNAL_TELEMETRY_SERVICE_NAME: defaults to 'otel-collector', determines entity name in New Relic
10+
# - INTERNAL_TELEMETRY_OTLP_ENDPOINT: defaults to 'https://otlp.nr-data.net', see https://docs.newrelic.com/docs/opentelemetry/best-practices/opentelemetry-otlp/ and https://docs.newrelic.com/docs/opentelemetry/best-practices/opentelemetry-otlp-troubleshooting/
11+
# - INTERNAL_TELEMETRY_METRICS_LEVEL: defaults to 'detailed', other values are 'normal', 'basic', 'none'
12+
# - INTERNAL_TELEMETRY_LOG_LEVEL: defaults to INFO, other values are DEBUG, WARN, ERROR
13+
# - INTERNAL_TELEMETRY_TRACE_LEVEL: defaults to 'basic', other value is 'none'
14+
# - INTERNAL_TELEMETRY_TRACE_SAMPLE_RATIO: defaults to 1.0, i.e. all spans get sampled, use float <1, e.g. 0.1 for 10% sampling
1315
service:
1416
telemetry:
1517
metrics:
@@ -19,29 +21,46 @@ service:
1921
exporter:
2022
otlp:
2123
protocol: http/protobuf
22-
# https://docs.newrelic.com/docs/opentelemetry/best-practices/opentelemetry-otlp-troubleshooting/
2324
endpoint: "${env:INTERNAL_TELEMETRY_OTLP_ENDPOINT:-https://otlp.nr-data.net}"
2425
headers:
25-
api-key: "${env:INTERNAL_TELEMETRY_NEW_RELIC_LICENSE_KEY}"
26+
- name: api-key
27+
value: "${env:INTERNAL_TELEMETRY_NEW_RELIC_LICENSE_KEY}"
2628
logs:
2729
level: "${env:INTERNAL_TELEMETRY_LOG_LEVEL:-INFO}"
30+
# default sampling config for reference to simplify overwrites even if not exposed via env var, e.g. --config=yaml:service::telemetry::logs::sampling::enabled::false
31+
sampling:
32+
enabled: true
33+
# The interval in seconds that the logger applies to each sampling.
34+
tick: 10s
35+
# The number of messages logged at the start of each sampling::tick
36+
initial: 10
37+
# Sets the sampling policy for subsequent messages after sampling::initial messages are logged. When sampling::thereafter is set to N, every Nth message is logged and all others are dropped. If N is zero, the logger drops all messages after sampling::initial messages are logged.
38+
thereafter: 100
2839
processors:
2940
- batch:
3041
exporter:
3142
otlp:
3243
protocol: http/protobuf
3344
endpoint: "${env:INTERNAL_TELEMETRY_OTLP_ENDPOINT:-https://otlp.nr-data.net}"
3445
headers:
35-
api-key: "${env:INTERNAL_TELEMETRY_NEW_RELIC_LICENSE_KEY}"
46+
- name: api-key
47+
value: "${env:INTERNAL_TELEMETRY_NEW_RELIC_LICENSE_KEY}"
3648
traces:
49+
level: "${env:INTERNAL_TELEMETRY_TRACE_LEVEL:-basic}"
50+
sampler:
51+
parent_based:
52+
root:
53+
trace_id_ratio_based:
54+
ratio: ${env:INTERNAL_TELEMETRY_TRACE_SAMPLE_RATIO:-1.0}
3755
processors:
3856
- batch:
3957
exporter:
4058
otlp:
4159
protocol: http/protobuf
4260
endpoint: "${env:INTERNAL_TELEMETRY_OTLP_ENDPOINT:-https://otlp.nr-data.net}"
4361
headers:
44-
api-key: "${env:INTERNAL_TELEMETRY_NEW_RELIC_LICENSE_KEY}"
62+
- name: api-key
63+
value: "${env:INTERNAL_TELEMETRY_NEW_RELIC_LICENSE_KEY}"
4564
resource:
46-
newrelic.collector_telemetry.version: 0.1.0
65+
newrelic.collector_telemetry.version: 0.2.0
4766
service.name: "${env:INTERNAL_TELEMETRY_SERVICE_NAME:-otel-collector}"

0 commit comments

Comments
 (0)