spring-projects / spring-projects/spring-boot

Support for OpenTelemetry resource detectors

Open
#50,861 12 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status: waiting-for-triage
Dominant language
Java
Stars
81.5k
Forks
42.7k
Avg merge
2d 4h
Merged PRs (30d)
65

Description

Context

Spring Boot today builds OpenTelemetry resource attributes only from static sources:

  • OTEL_RESOURCE_ATTRIBUTES / OTEL_SERVICE_NAME environment variables
  • management.opentelemetry.resource-attributes.* properties
  • spring.application.* defaults

There is no extension point for detecting resource information from the runtime environment like host name, OS, process ID, container metadata, cloud provider, etc. — which the OpenTelemetry spec calls resource detectors..

Use case

The motivating use case is Micrometer's OTLP metrics export. Resource attributes are currently built independently at two call sites:

  1. OpenTelemetrySdkAutoConfiguration → io.opentelemetry.sdk.resources.Resource bean (traces & logs)
  2. OtlpMetricsPropertiesConfigAdapter.resourceAttributes()Map<String,String> for Micrometer's OtlpMeterRegistry

Because Micrometer's OTLP registry is its own implementation (not the OTel SDK), it can't consume an OTel Resource directly. This means dynamically detected attributes need to flow into both consumers consistently, or signals will disagree on resource identity.

Question for the community

Is this something Spring Boot would want to support? If so, what would be the preferred approach? A few directions come to mind:

  • A Spring-native callback interface (similar to how Boot exposes other extension points), collected as beans and merged into
    OpenTelemetryResourceAttributes
  • Adopting the OTel ResourceProvider SPI (`opentelemetry-sdk-extension-autoconfigure) — brings ecosystem compatibility but adds a heavier dependency and requires a lossy bridge for the Micrometer Map path
  • Something else entirely

Happy to put together a more detailed proposal or a proof of concept if the team thinks this is worth pursuing.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading OpenTelemetrySdkAutoConfiguration and OtlpMetricsPropertiesConfigAdapter.resourceAttributes(), then compare how resource attributes reach the OTel Resource bean and Micrometer's OtlpMeterRegistry. Review the OpenTelemetry resource-detector specification and the issue's proposed extension points. Done means an agreed approach or a detailed proposal/POC that keeps detected attributes consistent across both consumers.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring-boot
Domain
observability
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.