You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Include service.instance.id Resource attribute #5257
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.
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.
@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?
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?
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.
@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.
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
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
Activity
[-]Include service.instance.id Resource attribute by default[/-][+]Include service.instance.id Resource attribute[/+]aabmass commentedon Jun 4, 2026
From the SIG call
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.
herin049 commentedon Jun 4, 2026
@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
ProcessResourceDetectorwith forking because theprocess.pidwill not be correctly reflected post-fork.One solution would be to expose a mechanism to modify the
Resourceobject at runtime on theTracerProviderand perform an update for the resource object for each registeredTracer(and analogously for metrics/logs) by using a function registered usingos.register_at_fork(). Wdyt?aabmass commentedon Jun 5, 2026
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?
herin049 commentedon Jun 6, 2026
@aabmass I've opened #5279 and #5280 to add the ability to refresh process sensitive
Resourceattributes. I did decide to add one public API function to allow users to update theResourceon a provider post-initialization by callingprovider.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.emdneto commentedon Jun 9, 2026
There's also #5000 @herin049. wdyt?
herin049 commentedon Jun 9, 2026
@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.
sterchelen commentedon Jun 11, 2026
@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. Forprocess.pidthat's fine — it's deterministic within a process. But a randomservice.instance.idwould 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
herin049 commentedon Jun 11, 2026
@sterchelen This is already accounted for in #5259