Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate a service.instance.id if it is not present? #5103

Closed
srikanthccv opened this issue Jan 9, 2023 · 4 comments
Closed

Generate a service.instance.id if it is not present? #5103

srikanthccv opened this issue Jan 9, 2023 · 4 comments

Comments

@srikanthccv
Copy link
Member

Spec says https://github.com/open-telemetry/opentelemetry-specification/tree/v1.6.1/specification/resource/semantic_conventions#service

MUST be unique for each instance of the same service.namespace,service.name pair (in other words service.namespace,service.name,service.instance.id triplet MUST be globally unique). The ID helps to distinguish instances of the same service that exist at the same time (e.g. instances of a horizontally scaled service). It is preferable for the ID to be persistent and stay the same for the lifetime of the service instance, however it is acceptable that the ID is ephemeral and changes during important lifetime events for the service (e.g. service restarts). If the service has no inherent unique ID that can be used as the value of this attribute it is recommended to generate a random Version 1 or Version 4 RFC 4122 UUID (services aiming for reproducible UUIDs may also use Version 5, see RFC 4122 for more recommendations).

The built-in default Resource doesn't appear to do this. While it is not mandatory by specification, it is important when scaling a service horizontally.

https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/data-model.md#single-writer

https://github.com/open-telemetry/opentelemetry-specification/blob/7e9ba1683995c34846b942fbc23c3290610e9347/specification/compatibility/prometheus_and_openmetrics.md#resource-attributes

@jack-berg
Copy link
Member

I'm in favor of adding this to the default resource, and I think this specific sentence from the semantic conventions makes it reasonable to do:

If the service has no inherent unique ID that can be used as the value of this attribute it is recommended to generate a random Version 1 or Version 4 RFC 4122 UUID (services aiming for reproducible UUIDs may also use Version 5, see RFC 4122 for more recommendations).

@srikanthccv do you know if any other language SDKs include it by default?

@srikanthccv
Copy link
Member Author

I know erlang does it by default, and Python and JS have planned to include it by default, but it hasn't been implemented yet.

@jack-berg
Copy link
Member

FYI I opened spec issue #3136 to request clarity on whether SDKs should generate a value for service.instance.id.

@jack-berg
Copy link
Member

Resolved in #6226.

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

No branches or pull requests

2 participants