Skip to content

Include service.instance.id Resource attribute #5257

Closed

Description

@herin049

Is your feature request related to a problem?

The OpenTelemetry semantic conventions currently recommends that SDK implementations populate the service.instance.id Resource attributes using a v1/v4 UUID:

Implementations, such as SDKs, are recommended to generate a random Version 1 or Version 4 RFC 4122 UUID, but are free to use an inherent unique ID as the source of this value if stability is desirable. In that case, the ID SHOULD be used as source of a UUID Version 5 and SHOULD use the following UUID as the namespace: 4d63009a-8d0f-11ee-aad7-4c796ed8e320.

However, currently the SDK does not populate this resource attribute.

Describe the solution you'd like

There are certainly a cardinally concern that we should be weary of when introducing this feature. There is an open question of whether we should add this attribute by default, or if we should have it be opt-in only. I propose that we start by creating a ServiceInstanceIDResourceDetector resource detector, which users can opt in to initially. We can decide later if we want this resource detector enabled by default.

Describe alternatives you've considered

N/A

Additional Context

https://opentelemetry.io/docs/specs/semconv/registry/attributes/service/#service-attributes

Would you like to implement a fix?

Yes

Tip

React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.

Activity

  1. self-assigned this
    on May 30, 2026
  2. changed the title [-]Include service.instance.id Resource attribute by default[/-] [+]Include service.instance.id Resource attribute[/+] on May 30, 2026
  3. aabmass commented on Jun 4, 2026

    @aabmass
    Member

    From the SIG call

    • this is stable in semconv
    • [aaron] awesome thank you for sending this
    • Declarative config has its own impl. We can use this new PR’s impl to consolidate.

    From aaron, does this cover forking cases correctly? We might need to embed this more deeply in the Resource SDK to mutate resource when fork happens.

  4. herin049 commented on Jun 4, 2026

    @herin049
    ContributorAuthor

    @aabmass After thinking about it more, I think the discussion around forking behavior should be treated as an independent issue. For example, there is already an issue when using the ProcessResourceDetector with forking because the process.pid will not be correctly reflected post-fork.

    One solution would be to expose a mechanism to modify the Resource object at runtime on the TracerProvider and perform an update for the resource object for each registered Tracer (and analogously for metrics/logs) by using a function registered using os.register_at_fork(). Wdyt?

  5. aabmass commented on Jun 5, 2026

    @aabmass
    Member

    I agree it's not specific to service.instance.id, but I don't think we should open a public way to mutate Resource now.

    Are you saying we should merge #5259 at first without specific forking logic? I'm ok with that too, and maybe open a new tracking bug for the forking issue with resource?

  6. herin049 commented on Jun 6, 2026

    @herin049
    ContributorAuthor

    I agree it's not specific to service.instance.id, but I don't think we should open a public way to mutate Resource now.

    Are you saying we should merge #5259 at first without specific forking logic? I'm ok with that too, and maybe open a new tracking bug for the forking issue with resource?

    @aabmass I've opened #5279 and #5280 to add the ability to refresh process sensitive Resource attributes. I did decide to add one public API function to allow users to update the Resource on a provider post-initialization by calling provider.update_resource(...) given that there may be fringe use cases where this is needed by users. However, I'm also open to keeping this method private. Let me know what you think.

  7. emdneto commented on Jun 9, 2026

    @emdneto
    Member

    There's also #5000 @herin049. wdyt?

  8. herin049 commented on Jun 9, 2026

    @herin049
    ContributorAuthor

    There's also #5000 @herin049. wdyt?

    @emdneto Although I'm a bit biased here, I would generally prefer #5280 over #5000 since it is a more general solution that allows any resource detector to declare if it is process sensitive. That is, is also solves the issue for the process resource detector which doesn't work with forking. Also, it also appears that #5000 doesn't correctly solve the issue because it doesn't update the resource for already created tracers/loggers.

  9. sterchelen commented on Jun 11, 2026

    @sterchelen

    since it is a more general solution that allows any resource detector to declare if it is process sensitive. That is, is also solves the issue for the process resource detector which doesn't work with forking. Also, it also appears that #5000 doesn't correctly solve the issue because it doesn't update the resource for already created tracers/loggers.

    @herin049 — you're right, and I'd rather we converge than have two competing PRs. A few notes after digging into yours.

    Each provider's _handle_fork() calls _get_process_sensitive_resource() independently. For process.pid that's fine — it's deterministic within a process. But a random service.instance.id would come out different for the meter, tracer and logger providers in the same worker. That cross-signal consistency is exactly why #5000 moved to a single shared UUID.

    So if we want to close #5000 we need to address this in #5280 properly

  10. herin049 commented on Jun 11, 2026

    @herin049
    ContributorAuthor

    since it is a more general solution that allows any resource detector to declare if it is process sensitive. That is, is also solves the issue for the process resource detector which doesn't work with forking. Also, it also appears that #5000 doesn't correctly solve the issue because it doesn't update the resource for already created tracers/loggers.

    @herin049 — you're right, and I'd rather we converge than have two competing PRs. A few notes after digging into yours.

    Each provider's _handle_fork() calls _get_process_sensitive_resource() independently. For process.pid that's fine — it's deterministic within a process. But a random service.instance.id would come out different for the meter, tracer and logger providers in the same worker. That cross-signal consistency is exactly why #5000 moved to a single shared UUID.

    So if we want to close #5000 we need to address this in #5280 properly

    @sterchelen This is already accounted for in #5259

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions