close
Skip to content

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

Open
sameerank wants to merge 3 commits into
masterfrom
sameerank/fix-flag-eval-metrics-service-name
Open

fix(openfeature): read OTEL_SERVICE_NAME for metrics resource#11424
sameerank wants to merge 3 commits into
masterfrom
sameerank/fix-flag-eval-metrics-service-name

Conversation

@sameerank
Copy link
Copy Markdown

@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
Copy link
Copy Markdown
Contributor

datadog-official Bot commented May 20, 2026

Pipelines

Fix all issues with BitsAI

⚠️ Warnings

🚦 53 Pipeline jobs failed

DataDog/apm-reliability/dd-trace-java | Amazon_Linux_2023_amd64.SI94: [test-app-java-alpine]   View in Datadog   GitLab

🔧 Fix in code (Fix with Cursor). AssertionError: ❌ There are previous errors in the virtual machine provisioning steps. Check this file in the logs scenario folder: Amazon_Linux_2023_amd64.log

DataDog/apm-reliability/dd-trace-java | Amazon_Linux_2023_amd64.SIM: [test-app-java-alpine]   View in Datadog   GitLab

🔧 Fix in code (Fix with Cursor). Exception launching aws provision step remote command. Assertion error during virtual machine provisioning steps.

DataDog/apm-reliability/dd-trace-java | Amazon_Linux_2023_amd64.SIM: [test-app-java]   View in Datadog   GitLab

🔧 Fix in code (Fix with Cursor). Error provisioning virtual machine. AssertionError: There are previous errors in the virtual machine provisioning steps. Check the log file: Amazon_Linux_2023_amd64.log

View all 53 failed jobs.

Useful? React with 👍 / 👎

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

@sameerank sameerank added the comp: metrics Metrics label May 20, 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