Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions sentry_sdk/integrations/cloud_resource_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import urllib3

import sentry_sdk
from sentry_sdk.api import set_context
from sentry_sdk.integrations import Integration
from sentry_sdk.utils import logger
Expand Down Expand Up @@ -262,6 +263,8 @@ def setup_once() -> None:
context = CloudResourceContextIntegration._get_cloud_resource_context()
if context != {}:
set_context(CONTEXT_TYPE, context)
for k, v in context.items():
sentry_sdk.get_isolation_scope().set_attribute(k, v)

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.

This will set the attributes on all spans. Given that they're not in the common attrs list, they should probably be set on the segment of the current span instead?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, the attributes should be on the segment span.
Now I look at this, I'm not sure how that would work because the context is set in setup_once().
I guess we would need some mechanism to set attributes on a scope that are then only applied on the segment span.
Alternatively, we consider not migrating the integration to span first.

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.

Right, missed that we're in setup_once here.

I would leave this integration out for now. I believe it'd make sense for this to live in the aws/gcp integrations eventually, but as is, I'd not migrate. Errors will still get the context and that's probably where it's most useful.



# Map with the currently supported cloud providers
Expand Down
Loading