Skip to content

Commit

Permalink
[OTEL-2048] Add otelcol_ prefix to internal metrics from trace agent (#…
Browse files Browse the repository at this point in the history
…387)

* [OTEL-2048] Add otelcol_ prefix to internal metrics from trace agent

* changelog

* Update .chloggen/agent-metrics-prefix.yaml

* fmt
  • Loading branch information
songy23 committed Aug 22, 2024
1 parent f562e42 commit dc3e35e
Show file tree
Hide file tree
Showing 3 changed files with 366 additions and 286 deletions.
16 changes: 16 additions & 0 deletions .chloggen/agent-metrics-prefix.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: enhancement

# The name of the component (e.g. pkg/quantile)
component: pkg/otlp/metrics

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: "Add `otelcol_` prefix to internal metrics from trace agent"

# The PR related to this change
issues: [387]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:
24 changes: 23 additions & 1 deletion pkg/otlp/metrics/metrics_remapping.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@ func remapMetrics(all pmetric.MetricSlice, m pmetric.Metric) {
remapJvmMetrics(all, m)
}

// renameMetrics adds the `otel.` prefix to metrics.
// renameMetrics adds the `otel.` or `otelcol_` prefix to metrics.
func renameMetrics(m pmetric.Metric) {
renameHostMetrics(m)
renameKafkaMetrics(m)
renameAgentInternalOTelMetric(m)
}

// remapSystemMetrics extracts system metrics from m and appends them to all.
Expand Down Expand Up @@ -237,3 +238,24 @@ func renameHostMetrics(m pmetric.Metric) {
m.SetName("otel." + m.Name())
}
}

var agentHTTPMetrics = map[string]struct{}{
"http_server_duration": {},
"http_server_request_size": {},
"http_server_response_size": {},
}

// isAgentInternalOTelMetric determines whether a metric is a internal metric in Agent on OTLP
func isAgentInternalOTelMetric(name string) bool {
if _, ok := agentHTTPMetrics[name]; ok {
return true
}
return strings.HasPrefix(name, "datadog_trace_agent") || strings.HasPrefix(name, "datadog_otlp")
}

// renameAgentInternalOTelMetric adds prefix to internal metrics in Agent on OTLP
func renameAgentInternalOTelMetric(m pmetric.Metric) {
if isAgentInternalOTelMetric(m.Name()) {
m.SetName("otelcol_" + m.Name())
}
}
Loading

0 comments on commit dc3e35e

Please sign in to comment.