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

celery: use python dict instead of string as attribute value to enable parsing #3170

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

shivanshuraj1333
Copy link
Member

Fixes: #3169

@@ -95,8 +95,6 @@ def set_attributes_from_context(span, context):
SpanAttributes.MESSAGING_DESTINATION, routing_key
)

value = str(value)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this does match with the value an attributes can have https://opentelemetry.io/docs/concepts/signals/traces/#attributes

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I opened this and realized that it is intentional.

Right now, since we do value = str(value) the map becomes tricky to parse (filtering based on key).

How about if I flatten the map and then stringily (or convert to corresponding datatype) the values?

celery.delivery_info`{'exchange': '', 'routing_key': 'distilled-guidance-dpo-25-10k-v1', 'priority': 0, 'redelivered': False}`

would become

celery.delivery_info.exchange: "routing_key"
celery.delivery_info.routing_key: "distilled-guidance-dpo-25-10k-v1"
celery.delivery_info.priority: 0
celery.delivery_info.redelivered: false

Copy link
Contributor

Choose a reason for hiding this comment

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

Flattening the map would indeed be better I think than going out of spec :)

Copy link
Member Author

Choose a reason for hiding this comment

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

I have updated the changes to add span attributes with flattened map. PTAL, thanks!

@shivanshuraj1333 shivanshuraj1333 force-pushed the fix/issues/3169 branch 2 times, most recently from d66fd13 to 49a86ba Compare February 13, 2025 11:12
@shivanshuraj1333 shivanshuraj1333 requested a review from a team as a code owner February 13, 2025 11:30
@xrmx xrmx changed the title Use python dict instead of string as attribute value to enable parsing celery: use python dict instead of string as attribute value to enable parsing Feb 20, 2025
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

Successfully merging this pull request may close these issues.

Make span attributes json parseable for celery
2 participants