Skip to content

Commit d91c1b4

Browse files
pgimalaciglendd
andauthored
Add warning for COAT on NoDoubleUnderscoreSep (#36492)
Co-authored-by: iglendd <len.gamburg@datadoghq.com>
1 parent 8f7b8f7 commit d91c1b4

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

comp/core/agenttelemetry/impl/agenttelemetry.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,12 @@ func (a *atel) loadPayloads(profiles []*Profile) (*senderSession, error) {
489489
a.logComp.Errorf("failed to get filtered telemetry metrics: %v", err)
490490
}
491491

492+
// All metrics stored in the "pms" slice above must follow the format:
493+
// <subsystem>__<metric_name>
494+
// The "subsystem" and "name" should be concatenated with a double underscore ("__") separator,
495+
// e.g., "checks__execution_time". Therefore, the "Options.NoDoubleUnderscoreSep: true" option
496+
// must not be used when creating metrics.
497+
492498
session := a.sender.startSession(a.cancelCtx)
493499
for _, p := range profiles {
494500
a.reportAgentMetrics(session, pms, p)

comp/core/agenttelemetry/impl/config.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,10 @@ type Event struct {
107107
//
108108
// profiles[].metric.metrics[].name (required)
109109
// -------------------------------------------
110-
// Metric's full name typically in the form of "<metric group>.<metric name>".
111-
// It is required parameter to avoid emitting all available metrics unintentionally.
110+
// The full metric name is formatted as "<metric group>.<metric name>". In telemetry.NewGauge()
111+
// and similar APIs, "metric group" corresponds to the "subsystem" parameter, and "metric name"
112+
// corresponds to the "name" parameter. Do not use the "Options.NoDoubleUnderscoreSep" option
113+
// in these APIs, as it is not supported in agent telemetry.
112114
//
113115
// profiles[].metric.metrics[].aggregate_tags (optional)
114116
// -----------------------------------------------------
@@ -338,7 +340,9 @@ func compileMetric(p *Profile, m *MetricConfig) error {
338340
return fmt.Errorf("profile '%s' 'metrics[].name' '(%s)' attribute should have two elements separated by '.'", p.Name, m.Name)
339341
}
340342

341-
// Convert Datadog metric name to Prometheus metric name (used for quick(er) matching)
343+
// Converts a Datadog metric name to a Prometheus metric name for quicker matching. Prometheus metrics
344+
// (from the "telemetry" package) must be declared without setting Options.NoDoubleUnderscoreSep to true,
345+
// ensuring the full metric name includes double underscores ("__"); otherwise, matching will fail.
342346
promName := fmt.Sprintf("%s__%s", names[0], names[1])
343347
p.metricsMap[promName] = m
344348

comp/core/telemetry/options.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import "fmt"
1313
type Options struct {
1414
// NoDoubleUnderscoreSep is set to true when you don't want to
1515
// separate the subsystem and the name with a double underscore separator.
16+
//
17+
// This option is not compatible with the cross-org agent telemetry
1618
NoDoubleUnderscoreSep bool
1719

1820
// DefaultMetric exports metric by default via built-in agent_telemetry core check.

0 commit comments

Comments
 (0)