Skip to content

Commit 5169cac

Browse files
committed
feat(internal): expose trace sampling as env var
1 parent e4b76fd commit 5169cac

File tree

1 file changed

+31
-10
lines changed

1 file changed

+31
-10
lines changed
Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
##### Example configuration for internal telemetry
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.
4+
##### Requirements
5+
# - nrdot-collector (any distro) >= 1.3.0 or collector core version >= v1.35.0 / v0.129.0
46
##### Configuration via environment variables
5-
# For valid values, see: https://opentelemetry.io/docs/collector/internal-telemetry/
7+
# For official documentation, see: https://opentelemetry.io/docs/collector/internal-telemetry/
68
## Required
79
# - INTERNAL_TELEMETRY_NEW_RELIC_LICENSE_KEY
810
## 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
11+
# - INTERNAL_TELEMETRY_SERVICE_NAME: defaults to 'otel-collector', determines entity name in New Relic
12+
# - 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/
13+
# - INTERNAL_TELEMETRY_METRICS_LEVEL: defaults to 'detailed', other values are 'normal', 'basic', 'none'
14+
# - INTERNAL_TELEMETRY_LOG_LEVEL: defaults to INFO, other values are DEBUG, WARN, ERROR
15+
# - INTERNAL_TELEMETRY_TRACE_LEVEL: defaults to 'basic', other value is 'none'
16+
# - 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
1317
service:
1418
telemetry:
1519
metrics:
@@ -19,29 +23,46 @@ service:
1923
exporter:
2024
otlp:
2125
protocol: http/protobuf
22-
# https://docs.newrelic.com/docs/opentelemetry/best-practices/opentelemetry-otlp-troubleshooting/
2326
endpoint: "${env:INTERNAL_TELEMETRY_OTLP_ENDPOINT:-https://otlp.nr-data.net}"
2427
headers:
25-
api-key: "${env:INTERNAL_TELEMETRY_NEW_RELIC_LICENSE_KEY}"
28+
- name: api-key
29+
value: "${env:INTERNAL_TELEMETRY_NEW_RELIC_LICENSE_KEY}"
2630
logs:
2731
level: "${env:INTERNAL_TELEMETRY_LOG_LEVEL:-INFO}"
32+
# 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
33+
sampling:
34+
enabled: true
35+
# The interval in seconds that the logger applies to each sampling.
36+
tick: 10s
37+
# The number of messages logged at the start of each sampling::tick
38+
initial: 10
39+
# 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.
40+
thereafter: 100
2841
processors:
2942
- batch:
3043
exporter:
3144
otlp:
3245
protocol: http/protobuf
3346
endpoint: "${env:INTERNAL_TELEMETRY_OTLP_ENDPOINT:-https://otlp.nr-data.net}"
3447
headers:
35-
api-key: "${env:INTERNAL_TELEMETRY_NEW_RELIC_LICENSE_KEY}"
48+
- name: api-key
49+
value: "${env:INTERNAL_TELEMETRY_NEW_RELIC_LICENSE_KEY}"
3650
traces:
51+
level: "${env:INTERNAL_TELEMETRY_TRACE_LEVEL:-basic}"
52+
sampler:
53+
parent_based:
54+
root:
55+
trace_id_ratio_based:
56+
ratio: ${env:INTERNAL_TELEMETRY_TRACE_SAMPLE_RATIO:-1.0}
3757
processors:
3858
- batch:
3959
exporter:
4060
otlp:
4161
protocol: http/protobuf
4262
endpoint: "${env:INTERNAL_TELEMETRY_OTLP_ENDPOINT:-https://otlp.nr-data.net}"
4363
headers:
44-
api-key: "${env:INTERNAL_TELEMETRY_NEW_RELIC_LICENSE_KEY}"
64+
- name: api-key
65+
value: "${env:INTERNAL_TELEMETRY_NEW_RELIC_LICENSE_KEY}"
4566
resource:
46-
newrelic.collector_telemetry.version: 0.1.0
67+
newrelic.collector_telemetry.version: 0.2.0
4768
service.name: "${env:INTERNAL_TELEMETRY_SERVICE_NAME:-otel-collector}"

0 commit comments

Comments
 (0)