Skip to content

Conversation

wangzlei
Copy link
Contributor

@wangzlei wangzlei commented Oct 17, 2025

Description of changes:
Celery, Pika, and Aio-Pika all support consumer callbacks. The consumer spans represent not only the message retrieval action, but also the execution of the callback function that processes the message.

This change adds code information about the callback function to the consumer span attributes.

{
    "kind": "SpanKind.CONSUMER",
    "attributes": {
        "code.function.name": "tasks.add_numbers",
        "code.file.path": "/Volumes/workplace/extension/aws-otel-python-instrumentation/samples/celery/tasks.py",
        "code.line.number": 14,
        "celery.action": "run",
        "celery.state": "SUCCESS",
        "messaging.destination": "celery",
        "celery.delivery_info": "{'exchange': '', 'routing_key': 'celery', 'priority': 0, 'redelivered': False}",
        "messaging.message.id": "8aaec4dc-31b0-4705-9c90-6f8eb1a9a0a9",
        "celery.reply_to": "40d7205e-2128-3d9e-afcf-07607c40f3ef",
        "celery.hostname": "gen88041@7cf34de1a5ba",
        "celery.task_name": "tasks.add_numbers"
    },

For Producer span, the code attributes can be achieved by stacktrace-based solution

For Confluent-Kafka, Kafka-Python, and AioKafka, these three libraries do not support consumer callbacks. Their consumer spans therefore represent only the message retrieval action, and accordingly use the same stacktrace-based solution.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@wangzlei wangzlei requested a review from a team as a code owner October 17, 2025 18:57
@wangzlei wangzlei added the skip changelog doesn't need a CHANGELOG entry label Oct 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip changelog doesn't need a CHANGELOG entry

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant