Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for OTel Python runtime metrics #114

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .chloggen/stanley.liu_python-runtime-metrics.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: The OTLP metrics converter now maps OpenTelemetry Python runtime metrics to their Datadog counterparts.

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

# (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:
52 changes: 49 additions & 3 deletions pkg/otlp/metrics/runtime_metric_mappings.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package metrics

// runtimeMetricPrefixLanguageMap defines the runtime metric prefixes and which languages they map to
var runtimeMetricPrefixLanguageMap = map[string]string{
"process.runtime.go": "go",
"process.runtime.dotnet": "dotnet",
"process.runtime.jvm": "jvm",
"process.runtime.go": "go",
"process.runtime.dotnet": "dotnet",
"process.runtime.jvm": "jvm",
"process.runtime.cpython": "python",
}

// runtimeMetricMapping defines the fields needed to map OTel runtime metrics to their equivalent
Expand Down Expand Up @@ -224,6 +225,48 @@ var javaRuntimeMetricsMappings = runtimeMetricMappingList{
}},
}

var pythonRuntimeMetricsMappings = runtimeMetricMappingList{
"process.runtime.cpython.cpu_time": {{
mappedName: "runtime.python.cpu.time.sys",
attributes: []runtimeMetricAttribute{{
key: "type",
values: []string{"system"},
}},
}, {
mappedName: "runtime.python.cpu.time.user",
attributes: []runtimeMetricAttribute{{
key: "type",
values: []string{"user"},
}},
}},
"process.runtime.cpython.gc_count": {{
mappedName: "runtime.python.gc.count.gen0",
attributes: []runtimeMetricAttribute{{
key: "count",
values: []string{"0"},
}},
}, {
mappedName: "runtime.python.gc.count.gen1",
attributes: []runtimeMetricAttribute{{
key: "count",
values: []string{"1"},
}},
}, {
mappedName: "runtime.python.gc.count.gen2",
attributes: []runtimeMetricAttribute{{
key: "count",
values: []string{"2"},
}},
}},
"process.runtime.cpython.memory": {{
mappedName: "runtime.python.mem.rss",
attributes: []runtimeMetricAttribute{{
key: "type",
values: []string{"rss"},
}},
}},
}

func getRuntimeMetricsMappings() runtimeMetricMappingList {
res := runtimeMetricMappingList{}
for k, v := range goRuntimeMetricsMappings {
Expand All @@ -235,6 +278,9 @@ func getRuntimeMetricsMappings() runtimeMetricMappingList {
for k, v := range javaRuntimeMetricsMappings {
res[k] = v
}
for k, v := range pythonRuntimeMetricsMappings {
res[k] = v
}
return res
}

Expand Down