Skip to content

Allow language SDKs to expand the scope of the service resource detector - #5280

Open
mmanciop wants to merge 2 commits into
open-telemetry:mainfrom
mmanciop:service-detector-scope
Open

Allow language SDKs to expand the scope of the service resource detector#5280
mmanciop wants to merge 2 commits into
open-telemetry:mainfrom
mmanciop:service-detector-scope

Conversation

@mmanciop

Copy link
Copy Markdown

Fixes #5276

Changes

Open up the definition of the service resource detector to allow for language-specific fallbacks when the OTEL_SERVICE_NAME environment variable is not set.

@mmanciop
mmanciop requested a review from a team as a code owner August 19, 2026 09:29
@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Aug 19, 2026

Copy link
Copy Markdown

Pull request dashboard status

Waiting on reviewers · refreshed 2026-09-01 14:32 UTC

Review the latest changes.

Status above doesn't look right?
  • Just replied or pushed? Anything around or after the refresh time above may not be picked up yet — give it a few minutes.
  • Anything look wrong? Report it with what you expected; it helps us improve the dashboard.

Comment thread specification/resource/sdk.md Outdated
on [OTEL_SERVICE_NAME](../configuration/sdk-environment-variables.md#general-sdk-configuration)
environment variable; populates `service.instance.id`
* `service`: `service`: Populates `service.name` from the [OTEL_SERVICE_NAME](../configuration/sdk-environment-variables.md#general-sdk-configuration)
environment variable and MAY fall back to language- or platform-specific

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this is under the header "#### Resource detector name", an in-development section. I think you meant a different section, since the intention is to change SDK's default behavior.

https://github.com/open-telemetry/semantic-conventions/blob/main/docs/resource/service.md is the place where the current behavior is defined, so naturally, I think the change belongs there.

(This is one of the rare areas in the SDK Specification, which points to sem-convention.)

@mmanciop mmanciop Aug 20, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

That is also needed as a follow-up (and it is mentioned in the issue: #5276), but IMO first comes opening up the specification

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

That is also needed as a follow-up

I'm not sure about that. Accepting this PR as written wouldn't open anything up; language SDKs would have nothing to change on the basis of it.

The spec defines how service.name is sourced from user configuration (OTEL_SERVICE_NAME , and its precedence over  OTEL_RESOURCE_ATTRIBUTES ), but it defers what happens when the user hasn't provided a value to semantic conventions which says "If the value was not specified, SDKs MUST fallback to  unknown_service:  concatenated with the process executable name."

That's the requirement we need to change to achieve the desired goal. I don't think this unblocks implementations on its own.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

But that is exactly the thing: the behavior I am proposing is not something that I don't think semantic conventions should specify. These behaviors are SDK-, language-specific implementations.

I read the current spec as: doing anything different than OTEL_SERVICE_NAME and unknown_service:... is illegal.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I read the current spec as: doing anything different than OTEL_SERVICE_NAME and unknown_service:... is illegal.

But where does it say so in the spec? "unknown_service" is not something in the spec at all. Its only defined in sem. conv.

Separately: The section this PR edits: its just about Resource detector names, and not about actual behaviors. Its odd that service alone has behavior being specified here, instead of pointing to the behavior specified elsewhere. We should not be introducing normative requirements to a Naming section.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

So this spec controls the behavior of the named service resource detector, which shows up in the declarative config schema at path $.resource.detection/development.detectors[*].service

Usage:

resource:
  detection/development:
    detectors:
      - service:
      - container:
      - host:
      - process:

tracer_provdier: ...
meter_provider: ...
logger_provider: ...

If we change the service detector definition to give the spec blessing to populate service.name for other language / framework specific sources, then an injector user can have a single config like the one above and get reasonable service.name values. Right now, the service detector only does anything to service.name if OTEL_SERVICE_NAME is set, which is impractical to set in the context of injector running on a linux box trying to instrument all processes for supported languages.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If we change the service detector definition to give the spec blessing to populate service.name for other language / framework specific sources, then an injector user can have a single config like the one above and get reasonable service.name values.

mm. If we change the text here, (as in this PR), is that sufficient for all language sdks to modify their service.name detection to match the new behavior (if they chose to)? There are languages which don't support declarative config, and don't use named detectors - they won't change their behavior based on this PR. Is that what this issue is trying to tackle - i.e let sdk populate service name from additional source, if the sdk use declarative config and uses named detectors? My impression is that we are trying to fix the default for all sdks, irrespective of whether they use named detectors or decl. config.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

My understanding is that this PR is only trying to impact named service detectors as used in declarative config (and potentially elsewhere if the language uses these named detectors in a generic capacity). The base SDK's default resource behavior would go unchanged.

Correct me if I misunderstand @mmanciop

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The base SDK's default resource behavior would go unchanged.

Thanks. Yes I'll wait for @mmanciop to confirm if this is scoped to just named service detectors. If that is the case, I'll re-review with that angle in mind (Sorry I was under the impression that we are trying to change defaults for all) Given that is only going to touch in-developemnt parts, this is the perfect time to polish it to make it give better default to all.

@mmanciop mmanciop Aug 24, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

My understanding is that this PR is only trying to impact named service detectors as used in declarative config (and potentially elsewhere if the language uses these named detectors in a generic capacity). The base SDK's default resource behavior would go unchanged.

Correct me if I misunderstand @mmanciop

Update: I think I understand the confusion now @cijothomas, let me try to explain.

This is about the service detector, whether it is triggered by declarative config, or used in the initialization of SDKs. As I said in the maintainer call, as an end-user I put a lot of value in good defaults, and currently our default service.name is everything but. That is, I would allow SDKs to modify their service resource detector to perform opinionated, language-specific behaviors. That, by extension, works also in declarative configuration.

Expand the accepted scope of the built-in `service` resource detector to permit language- and framework-specific discovery of `service.name`.

Closes open-telemetry#5276
@mmanciop
mmanciop force-pushed the service-detector-scope branch from 0b00927 to d41906b Compare August 20, 2026 16:59
environment variable; populates `service.instance.id`
* `service`: Populates `service.name` from the [OTEL_SERVICE_NAME](../configuration/sdk-environment-variables.md#general-sdk-configuration)
environment variable and MAY fall back to language- or platform-specific
sources (for example `spring.application.name`, a JAR manifest, or a

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Somehow we need to make it clear that its up to the maintainers discretion to decide to what degree they want to take on the burden of owning more complexity for the sake of supporting more framework specific patterns.

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.

Would MAY be better here?

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.

at the discretion of the specific SDK tries to convey this I think, although it could get an extra line at the end - something along the lines of Maintainers are responsible for deciding how much complexity the detector can incur into for the sake of better service name detection.

@opentelemetry-pr-dashboard

This comment has been minimized.

@mmanciop

Copy link
Copy Markdown
Author

/dashboard route:reviewers

@opentelemetry-pr-dashboard

Copy link
Copy Markdown

@mmanciop, this pull request was routed to reviewers.

@carlosalberto

Copy link
Copy Markdown
Contributor

@cijothomas is there anything blocking from your side? Other than minor things, we seem fine perhaps?

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.

Allow languages to expand the scope of the service resource detector

6 participants