-
Notifications
You must be signed in to change notification settings - Fork 636
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
Add a resource detector for populating service.instance.id
#4061
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note to self: need to run a gunicorn app with this to understand how it will behaves regarding Resources lifetimes
Tried:
where app is the flask dice app from the opentelemetry.io documentation and out of the box without a post_fork hook configured, gunicorn is reporting the same service.instance.id for both workers. Same problem with the process resource detector, we get the same pid on the traces but response is from different workers. |
# pylint: disable=no-self-use | ||
_instance_id_cache = {} | ||
|
||
def detect(self) -> "Resource": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason not to simply wait until service.instance.id
get added as stable
and include them in OtelResourceDetector
? Are there plans to include them as part of "Semantic Attributes with SDK-provided Default Value"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are there plans to include them as part of "Semantic Attributes with SDK-provided Default Value"
Yes, see open-telemetry/semantic-conventions#311.
Any reason not to simply wait until
service.instance.id
get added as stable and include them inOtelResourceDetector
?
One prerequisite for adding service.instance.id
as stable are working prototypes and implementation in several languages. Having such an implementation (or at least prototype) in Python would be beneficial for those stabilization efforts, especially as the description of service.instance.id
explicitly mentions application servers like gunicorn.
Showing that service.instance.id
can be populated according to the conventions for all major usage scenarios in Python would be a prerequisite for declaring it stable and making it a default attribute.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, see open-telemetry/semantic-conventions#311.
Having such an implementation (or at least prototype) in Python would be beneficial for those stabilization efforts
If there are plans to make them default doesn't that mean they would move into OtelResourceDetector
eventually? If we create a new resource detector (even though it might remain experimental) it sounds like we would have to support this forever. Maybe I might be misunderstanding what "prototype" is, will this just be temporary to get the specs to move along?
I'll give this a try myself. |
See #4061 (comment), the Resources are instantiated in the gunicorn process manager during distro bootstrap so they would be the same for every worker. So to make this less miserable for users we could find a safe way to redo part of the bootstrap after fork, currently we don't permit this, with:
You'll get:
Removing the set once check will make it work fine though:
|
Description
This adds a resource detector for populating
service.instance.id
in accordance with semantic conventions.Currently this resource detector is not enabled by default, however, once semantic conventions demand this attribute to be present by default (which is planned), then this detector can easily be added as a default (similar to the
otel
detector).Fixes #2113
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
This is tested via unit tests
Checklist: