Skip to content

fix(openfeature): read OTEL_SERVICE_NAME for metrics resource#11424

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 4 commits into
masterfrom
sameerank/fix-flag-eval-metrics-service-name
May 22, 2026
Merged

fix(openfeature): read OTEL_SERVICE_NAME for metrics resource#11424
gh-worker-dd-mergequeue-cf854d[bot] merged 4 commits into
masterfrom
sameerank/fix-flag-eval-metrics-service-name

Conversation

@sameerank
Copy link
Copy Markdown
Contributor

@sameerank sameerank commented May 20, 2026

What Does This Do

Reads the OTEL_SERVICE_NAME environment variable and sets it as the service.name resource attribute when exporting OTLP metrics from FlagEvalMetrics.

Motivation

The OpenTelemetry SDK's Resource.getDefault() only provides unknown_service:java as the service name. This causes OTLP metrics to be exported with an incorrect service name, making it difficult to identify which service the metrics belong to.

This fix reads OTEL_SERVICE_NAME from the environment (the standard OTel env var) and merges it with the default resource, ensuring metrics are properly attributed to the correct service.

For comparison, the service name in dd-trace-go is set in ddmetric.NewMeterProvider() with priority: DD_SERVICEDD_TAGS[service]OTEL_SERVICE_NAME (https://github.com/DataDog/dd-trace-go/blob/fb5394071eff386cdba3517dc9acb9641bac1d7e/ddtrace/opentelemetry/metric/resource.go#L41). Meanwhile Java created its own SdkMeterProvider with just Resource.getDefault().

Additional Notes

  • Falls back to Resource.getDefault() if OTEL_SERVICE_NAME is not set
  • Uses ConfigHelper.env() for consistent environment variable handling

Contributor Checklist

@sameerank sameerank added the type: bug Bug report and fix label May 20, 2026
@sameerank sameerank marked this pull request as ready for review May 20, 2026 05:13
@sameerank sameerank requested a review from a team as a code owner May 20, 2026 05:13
@sameerank sameerank requested review from dd-oleksii and greghuels and removed request for a team May 20, 2026 05:13
@dd-octo-sts
Copy link
Copy Markdown
Contributor

dd-octo-sts Bot commented May 20, 2026

Hi! 👋 Thanks for your pull request! 🎉

To help us review it, please make sure to:

  • Add at least one type, and one component or instrumentation label to the pull request

If you need help, please check our contributing guidelines.

@datadog-official

This comment has been minimized.

@sameerank sameerank added the comp: metrics Metrics label May 20, 2026
@sameerank sameerank added this pull request to the merge queue May 22, 2026
@dd-octo-sts
Copy link
Copy Markdown
Contributor

dd-octo-sts Bot commented May 22, 2026

/merge

@gh-worker-devflow-routing-ef8351
Copy link
Copy Markdown

gh-worker-devflow-routing-ef8351 Bot commented May 22, 2026

View all feedbacks in Devflow UI.

2026-05-22 07:25:12 UTC ℹ️ Start processing command /merge


2026-05-22 07:25:17 UTC ℹ️ MergeQueue: pull request added to the queue

The expected merge time in master is approximately 1h (p90).


2026-05-22 08:39:39 UTC ℹ️ MergeQueue: This merge request was merged

@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks May 22, 2026
@gh-worker-dd-mergequeue-cf854d gh-worker-dd-mergequeue-cf854d Bot merged commit 7a3ccbf into master May 22, 2026
754 of 756 checks passed
@gh-worker-dd-mergequeue-cf854d gh-worker-dd-mergequeue-cf854d Bot deleted the sameerank/fix-flag-eval-metrics-service-name branch May 22, 2026 08:39
@github-actions github-actions Bot added this to the 1.63.0 milestone May 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp: metrics Metrics type: bug Bug report and fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants