Skip to content

Commit 26b8666

Browse files
committed
Enable debug exporter when debug section is configured
Signed-off-by: Stanley Liu <stanley.liu@datadoghq.com>
1 parent a83dc9d commit 26b8666

6 files changed

Lines changed: 55 additions & 13 deletions

File tree

comp/otelcol/otlp/collector.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,12 @@ type PipelineConfig struct {
161161
MetricsBatch map[string]interface{}
162162
}
163163

164-
// shouldSetLoggingSection reports whether the debug exporter should be attached
165-
// to the OTLP ingest pipelines. It is enabled only when the user explicitly sets
166-
// otlp_config.debug.verbosity to a valid value other than "none". When verbosity
167-
// is unset, the debug exporter is not attached, so no per-batch debug logs are
168-
// emitted by default.
164+
// shouldSetLoggingSection reports whether the debug exporter should be attached to
165+
// the OTLP ingest pipelines. FromAgentConfig populates Debug["verbosity"] whenever the
166+
// user configures the otlp_config.debug section (defaulting it when the section is
167+
// declared without a verbosity), so a missing verbosity here means the section was not
168+
// configured and the exporter is not attached. An explicit "none" also leaves it
169+
// detached. As a result, no per-batch debug logs are emitted unless the user opts in.
169170
func (p *PipelineConfig) shouldSetLoggingSection() bool {
170171
v, ok := p.Debug["verbosity"]
171172
if !ok {

comp/otelcol/otlp/config.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,15 @@ func FromAgentConfig(cfg config.Reader) (PipelineConfig, error) {
109109
}
110110

111111
debugConfig := configcheck.ReadConfigSection(cfg, coreconfig.OTLPDebug)
112+
debugMap := debugConfig.ToStringMap()
113+
// If the user explicitly declares the otlp_config.debug section but does not set a
114+
// verbosity, attach the debug exporter using the default verbosity. When the section
115+
// is absent entirely, verbosity is left unset so the debug exporter is not attached.
116+
if _, ok := debugMap["verbosity"]; !ok {
117+
if cfg.HasSection(coreconfig.OTLPDebug) || cfg.IsConfigured(coreconfig.OTLPDebug) {
118+
debugMap["verbosity"] = cfg.GetString(coreconfig.OTLPDebug + ".verbosity")
119+
}
120+
}
112121

113122
return PipelineConfig{
114123
OTLPReceiverConfig: otlpReceiverConfigMap,
@@ -122,7 +131,7 @@ func FromAgentConfig(cfg config.Reader) (PipelineConfig, error) {
122131
LogsTagsAsDDTags: logsTagsAsDDTags,
123132
MetricsBatch: metricsBatchConfig.ToStringMap(),
124133
Logs: logsConfig.ToStringMap(),
125-
Debug: debugConfig.ToStringMap(),
134+
Debug: debugMap,
126135
}, multierr.Combine(errs...)
127136
}
128137

comp/otelcol/otlp/config_test.go

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -729,9 +729,9 @@ func TestFromAgentConfigDebug(t *testing.T) {
729729
err string
730730
}{
731731
{
732-
// A debug section with no verbosity does not enable the debug exporter:
733-
// only an explicit non-"none" verbosity attaches it.
734-
path: "debug/empty_but_set_debug.yaml",
732+
// A fully absent debug section leaves the exporter detached: verbosity is
733+
// never populated, so no per-batch debug logs are emitted by default.
734+
path: "debug/absent_debug.yaml",
735735
shouldSet: false,
736736
cfg: PipelineConfig{
737737
OTLPReceiverConfig: map[string]interface{}{},
@@ -752,6 +752,31 @@ func TestFromAgentConfigDebug(t *testing.T) {
752752
MetricsBatch: map[string]interface{}{},
753753
},
754754
},
755+
{
756+
// Explicitly declaring the debug section without a verbosity attaches the
757+
// debug exporter using the default verbosity ("basic"). Only a fully absent
758+
// debug section or an explicit "none" leaves the exporter detached.
759+
path: "debug/empty_but_set_debug.yaml",
760+
shouldSet: true,
761+
cfg: PipelineConfig{
762+
OTLPReceiverConfig: map[string]interface{}{},
763+
TracePort: 5003,
764+
MetricsEnabled: true,
765+
TracesEnabled: true,
766+
LogsEnabled: false,
767+
TracesInfraAttributesEnabled: true,
768+
TracesContainerTagPromotion: "off",
769+
Logs: map[string]interface{}{},
770+
Debug: map[string]interface{}{"verbosity": "basic"},
771+
Metrics: map[string]interface{}{
772+
"enabled": true,
773+
"tag_cardinality": "low",
774+
"apm_stats_receiver_addr": "http://localhost:8126/v0.6/stats",
775+
"instrumentation_scope_metadata_as_tags": true,
776+
},
777+
MetricsBatch: map[string]interface{}{},
778+
},
779+
},
755780
{
756781
path: "debug/verbosity_detailed.yaml",
757782
shouldSet: true,
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
otlp_config:

pkg/config/schema/yaml/core_schema.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5928,6 +5928,9 @@ properties:
59285928
This template lists the most commonly used settings; see the OpenTelemetry Collector documentation
59295929
for a full list of available settings:
59305930
https://github.com/open-telemetry/opentelemetry-collector/tree/main/exporter/debugexporter#getting-started
5931+
The debugexporter is off by default; it is attached only when this debug section
5932+
is configured. Declaring the section (even empty) enables it with the default
5933+
verbosity; set verbosity to none to leave it detached.
59315934
tags:
59325935
- template_section:CoreAgent
59335936
properties:
@@ -5939,8 +5942,8 @@ properties:
59395942
description: |-
59405943
Verbosity of debug logs when Datadog Agent receives otlp traces/metrics.
59415944
Valid values are basic, normal, detailed, none.
5942-
The debugexporter is off unless this is explicitly set; when unset,
5943-
no per-batch debug logs are emitted.
5945+
This default applies only once the debug section is configured; set it to
5946+
none to keep the debugexporter detached even when the section is present.
59445947
comment: Debug settings (default from OTel debugexporter)
59455948
grpc_port:
59465949
node_type: setting

releasenotes/notes/otlp-ingest-debug-exporter-default-off-3f6c1a9b7e2d4c85.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,8 @@ fixes:
33
- |
44
Agent OTLP Ingest no longer attaches the OpenTelemetry
55
``debugexporter`` by default. The ``debugexporter`` is now attached only when
6-
``otlp_config.debug.verbosity`` (or ``DD_OTLP_CONFIG_DEBUG_VERBOSITY``) is
7-
explicitly set to ``basic``, ``normal``, or ``detailed``.
6+
the ``otlp_config.debug`` section is explicitly configured. Declaring the
7+
section without a verbosity uses the default verbosity (``basic``), while
8+
setting ``otlp_config.debug.verbosity`` (or ``DD_OTLP_CONFIG_DEBUG_VERBOSITY``)
9+
to ``basic``, ``normal``, or ``detailed`` selects the verbosity. Setting it to
10+
``none`` leaves the exporter detached.

0 commit comments

Comments
 (0)