Skip to content

Commit 99fbf08

Browse files
anna-gitclaude
andcommitted
refactor(golang): remove Go-specific OTLP scope validation
The test_go_otlp_scope test validated that Go metrics arrived in the raw OTLP payload under the 'go.runtime' instrumentation scope. This is a Go-specific special case that doesn't exist for other languages and is redundant with test_otel_metrics_are_present_and_attributed, which already validates the metric names are present. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 10a2c32 commit 99fbf08

1 file changed

Lines changed: 2 additions & 51 deletions

File tree

tests/test_otlp_runtime_metrics.py

Lines changed: 2 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
from __future__ import annotations
1010

11-
from typing import Any, TypedDict
11+
from typing import TypedDict
1212

1313
from utils import context, features, interfaces, scenarios, weblog
1414

@@ -238,10 +238,6 @@ class MetricConstraints(TypedDict, total=False):
238238
"java": "jvm.heap_memory",
239239
}
240240

241-
# OTel instrumentation scope name used by the Go runtime metrics collector
242-
_GO_RUNTIME_SCOPE = "go.runtime"
243-
244-
245241
def get_runtime_metrics_by_name() -> dict[str, list[dict[str, str]]]:
246242
"""Return observed runtime metrics grouped by name.
247243
@@ -256,39 +252,10 @@ def get_runtime_metrics_by_name() -> dict[str, list[dict[str, str]]]:
256252
return result
257253

258254

259-
def _collect_go_otlp_metrics() -> dict[str, list[dict[str, Any]]]:
260-
"""Collect Go runtime metrics from raw OTLP payloads captured at the proxy.
261-
262-
Returns metric_name -> list of OTLP data points for scope 'go.runtime'.
263-
"""
264-
metrics: dict[str, list[dict[str, Any]]] = {}
265-
for data in interfaces.open_telemetry.get_data(path_filters=["/v1/metrics"]):
266-
content: dict[str, Any] = data["request"]["content"]
267-
for resource_metric in content.get("resourceMetrics", []):
268-
for scope_metric in resource_metric.get("scopeMetrics", []):
269-
scope_name: str = scope_metric.get("scope", {}).get("name", "")
270-
if scope_name != _GO_RUNTIME_SCOPE:
271-
continue
272-
for metric in scope_metric.get("metrics", []):
273-
name: str = metric["name"]
274-
data_points: list[dict[str, Any]] = metric.get("sum", {}).get("dataPoints", []) or metric.get(
275-
"gauge", {}
276-
).get("dataPoints", [])
277-
if name not in metrics:
278-
metrics[name] = []
279-
metrics[name].extend(data_points)
280-
return metrics
281-
282-
283255
@scenarios.otlp_runtime_metrics
284256
@features.runtime_metrics
285257
class Test_OtlpRuntimeMetrics:
286-
"""Verify runtime metrics are sent via OTLP with OTel names, not DD-proprietary names.
287-
288-
For Go: also validates metrics appear in the raw OTLP payload from the correct
289-
instrumentation scope ('go.runtime'), and that go.memory.used carries both
290-
memory-type dimensions.
291-
"""
258+
"""Verify runtime metrics are sent via OTLP with OTel names, not DD-proprietary names."""
292259

293260
def setup_otel_metrics_are_present_and_attributed(self) -> None:
294261
self.req = weblog.get("/")
@@ -364,19 +331,3 @@ def test_dd_metrics_are_absent(self) -> None:
364331
f"Found DD-proprietary metric names for {library}: {dd_named_metrics}. Expected OTel-native names only."
365332
)
366333

367-
def setup_go_otlp_scope(self) -> None:
368-
self.req = weblog.get("/")
369-
370-
def test_go_otlp_scope(self) -> None:
371-
"""For Go: validate metrics arrive in the raw OTLP payload under the 'go.runtime' scope."""
372-
assert self.req.status_code == 200
373-
374-
if context.library.name != "golang":
375-
return
376-
377-
otlp_metrics = _collect_go_otlp_metrics()
378-
for name in EXPECTED_METRICS["golang"]:
379-
assert name in otlp_metrics, (
380-
f"OTel metric '{name}' not found in OTLP payload from scope '{_GO_RUNTIME_SCOPE}'. "
381-
f"Found: {sorted(otlp_metrics.keys())}"
382-
)

0 commit comments

Comments
 (0)