Skip to content

feat(golang): add OTLP runtime metrics system tests#6857

Merged
anna-git merged 10 commits into
mainfrom
anna.yafi/go-otel-runtime-metrics-tests
Jul 2, 2026
Merged

feat(golang): add OTLP runtime metrics system tests#6857
anna-git merged 10 commits into
mainfrom
anna.yafi/go-otel-runtime-metrics-tests

Conversation

@anna-git

@anna-git anna-git commented May 5, 2026

Copy link
Copy Markdown
Contributor

Motivation

Add system tests for the new OTel semantic-convention Go runtime metrics feature in dd-trace-go (PR #4803 — now merged to main as well as in dd-trace-go (PR #4962

When `DD_METRICS_OTEL_ENABLED=true`, dd-trace-go emits Go runtime metrics via OTLP using OTel semconv naming (`go.memory.used`, `go.goroutine.count`, etc.) instead of DD-proprietary naming (`runtime.go.*`).

Changes

  • `tests/test_otlp_runtime_metrics.py`: Extended `Test_OtlpRuntimeMetrics` with Go support:
    • Removed `missing_feature` marker for Go from the manifest
    • Added `go.memory.used` `present_values` constraint (`go.memory.type`: `other`, `stack`) in `EXPECTED_METRICS`
    • Added `test_go_otlp_scope` method: validates raw OTLP payloads arrive under instrumentation scope `go.runtime`
    • Reconciled upstream refactor: `MetricConstraints` TypedDict, `EXPECTED_METRIC_ATTRIBUTE_VALUES`, split test methods
  • `utils/_context/_scenarios/init.py`: Added `GOMEMLIMIT=500MiB` to `otlp_runtime_metrics` scenario (required for `go.memory.limit` to emit)
  • `utils/build/docker/golang/app/net-http/main.go`: Added blank import `_ "github.com/DataDog/dd-trace-go/v2/ddtrace/opentelemetry/metric"` to wire OTel metrics in the Go weblog
  • `manifests/golang.yml`: Removed `missing_feature` entry for `test_otlp_runtime_metrics.py::Test_OtlpRuntimeMetrics`

Workflow

  1. ⚠️ Create your PR as draft ⚠️
  2. Work on you PR until the CI passes
  3. Mark it as ready for review
    • Test logic is modified? -> Get a review from RFC owner.
    • Framework is modified, or non obvious usage of it -> get a review from R&P team

Reviewer checklist

  • Anything but `tests/` or `manifests/` is modified ? I have the approval from R&P team
  • A docker base image is modified?
    • the relevant `build-XXX-image` label is present
  • A scenario is added, removed or renamed?

@github-actions

github-actions Bot commented May 5, 2026

Copy link
Copy Markdown
Contributor

CODEOWNERS have been resolved as:

manifests/golang.yml                                                    @DataDog/dd-trace-go-guild
tests/test_otlp_runtime_metrics.py                                      @DataDog/system-tests-core
utils/_context/_scenarios/__init__.py                                   @DataDog/system-tests-core
utils/build/docker/golang/app/chi/main.go                               @DataDog/dd-trace-go-guild @DataDog/system-tests-core
utils/build/docker/golang/app/echo/main.go                              @DataDog/dd-trace-go-guild @DataDog/system-tests-core
utils/build/docker/golang/app/gin/main.go                               @DataDog/dd-trace-go-guild @DataDog/system-tests-core
utils/build/docker/golang/app/net-http-orchestrion/main.go              @DataDog/dd-trace-go-guild @DataDog/system-tests-core
utils/build/docker/golang/app/net-http/main.go                          @DataDog/dd-trace-go-guild @DataDog/system-tests-core

@link04 link04 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@datadog-datadog-prod-us1

datadog-datadog-prod-us1 Bot commented Jun 15, 2026

Copy link
Copy Markdown

Pipelines  Tests

Fix all issues with BitsAI

⚠️ Warnings

🚦 1 Pipeline job failed

Testing the test | all-jobs-are-green   View in Datadog   GitHub Actions

🧪 1 Test failed in 1 job

Testing the test | main   GitHub Actions

tests.appsec.api_security.test_apisec_sampling.Test_API_Security_Sampling_Different_Status.test_sampling_delay[laravel11x] from system_tests_suite   View in Datadog
assert False
 +  where False = all(<generator object Test_API_Security_Sampling_Different_Status.test_sampling_delay.<locals>.<genexpr> at 0x7f3527cd7bc0>)

self = <tests.appsec.api_security.test_apisec_sampling.Test_API_Security_Sampling_Different_Status object at 0x7f35504860f0>

    def test_sampling_delay(self):
        """Can provide request header schema"""
    
        assert self.request1.status_code == 200
        schema1 = get_schema(self.request1, "req.headers")
...

ℹ️ Info

No other issues found (see more)

❄️ No new flaky tests detected

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: c62c616 | Docs | Datadog PR Page | Give us feedback!

@anna-git anna-git force-pushed the anna.yafi/go-otel-runtime-metrics-tests branch from 831bcc0 to 10a2c32 Compare June 15, 2026 13:35
@anna-git anna-git force-pushed the anna.yafi/go-otel-runtime-metrics-tests branch from 139d5ac to 67c89b0 Compare June 29, 2026 11:16
gh-worker-dd-mergequeue-cf854d Bot pushed a commit to DataDog/dd-trace-go that referenced this pull request Jun 30, 2026
…s are enabled (#4962)

Following #4803, fixes dual-emission when both `DD_RUNTIME_METRICS_ENABLED=true` and `DD_METRICS_OTEL_ENABLED=true` are set: the legacy v1 runtime metrics shouldn't start.

**Fix:** Pre-compute `otelRuntimeMetricsShouldBeEnabled` in `config` (`option.go`) and add a `!otelRuntimeMetricsShouldBeEnabled` guard around the legacy goroutine in `newTracer()`.

**Testing:**
- `TestTracerRuntimeMetrics` (all subtests) pass
- Validated against [system-tests PR #6857](DataDog/system-tests#6857) (`OTLP_RUNTIME_METRICS` scenario): `test_otel_metrics_are_present_and_attributed` and `test_dd_metrics_are_absent` both pass

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: maximo.bautista <maximo.bautista@datadoghq.com>
@anna-git anna-git marked this pull request as ready for review July 1, 2026 08:38
@anna-git anna-git requested review from a team as code owners July 1, 2026 08:38

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0cca3a3265

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread manifests/golang.yml
anna-git and others added 9 commits July 1, 2026 17:15
Add tests for the new OTel semantic-convention Go runtime metrics
(DD_METRICS_OTEL_ENABLED=true) from dd-trace-go PR #4716.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Remove Test_GoOtlpRuntimeMetricsExtended and the
  OTLP_RUNTIME_METRICS_EXTENDED scenario — the extended env var
  (DD_OTEL_RUNTIME_METRICS_EXTENDED_ENABLED) no longer exists in the
  tracer implementation
- Add Test_OtlpRuntimeMetrics: missing_feature to golang.yml so the
  base test is tracked (to be activated when the tracer ships)
- Add ddmetric.InstallGlobal() to the net-http weblog before
  tracer.Start() so the DD OTLP MeterProvider is installed and runtime
  metrics are actually exported during the OTLP_RUNTIME_METRICS scenario

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…lGlobal

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ide-effect

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…o.memory.limit

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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>
…ormatting

Replace missing_feature removal with v2.10.0-dev version tag (dd-trace-go#4803
was merged after version was bumped to v2.10.0-dev). Fix ruff formatting: restore
double blank line before module-level function and remove trailing newline.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Explicitly import `_ "github.com/DataDog/dd-trace-go/v2/ddtrace/opentelemetry/metric"`
in chi, echo (covers uds-echo), gin, and net-http-orchestrion so that
`otelmetricsinstall.StartHook` is registered for every weblog, not just
net-http. This guarantees OTel runtime metrics are intentionally enabled
rather than relying on an implicit transitive import.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@anna-git anna-git force-pushed the anna.yafi/go-otel-runtime-metrics-tests branch from f63ec4a to aa37e51 Compare July 1, 2026 15:17
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@anna-git anna-git enabled auto-merge (squash) July 1, 2026 15:23
@anna-git anna-git merged commit 4e52c28 into main Jul 2, 2026
3525 of 3530 checks passed
@anna-git anna-git deleted the anna.yafi/go-otel-runtime-metrics-tests branch July 2, 2026 10:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants