-
Notifications
You must be signed in to change notification settings - Fork 455
fix(azure_functions): handle consuming a list of service bus messages #14073
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
Merged
duncanpharvey
merged 10 commits into
main
from
duncan-harvey/azure-functions-consume-multiple-messages
Jul 22, 2025
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
bb977bd
handle consumption of multiple messages in azure functions
duncanpharvey 4109b23
only propagate context if all messages have the same context
duncanpharvey d8e7b70
add test for consuming many messages
duncanpharvey bea0294
add release note
duncanpharvey 6a83558
update tests to cover case where context is different between messages
duncanpharvey efb82aa
update release note
duncanpharvey 0f6adf1
Merge branch 'main' into duncan-harvey/azure-functions-consume-multip…
duncanpharvey 470c143
Update ddtrace/contrib/internal/azure_functions/utils.py
duncanpharvey 4c21d7f
check if message_id is not None
duncanpharvey 17f8e50
Merge branch 'main' into duncan-harvey/azure-functions-consume-multip…
duncanpharvey File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
...asenotes/notes/fix-azure-functions-service-bus-consume-message-list-cc30b53dffb18e08.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
fixes: | ||
- | | ||
azure_functions: This fix resolves an issue where a function that consumes a list of service bus messages throws an exception when instrumented. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
111 changes: 111 additions & 0 deletions
111
..._functions.test_azure_functions_snapshot.test_service_bus_consume_diff_context[many].json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
[[ | ||
{ | ||
"name": "azure.functions.invoke", | ||
"service": "test-func", | ||
"resource": "POST /api/httppostrootservicebusmanydiffcontext", | ||
"trace_id": 0, | ||
"span_id": 1, | ||
"parent_id": 0, | ||
"type": "serverless", | ||
"meta": { | ||
"_dd.p.dm": "-0", | ||
"_dd.p.tid": "687ab41600000000", | ||
"aas.function.name": "http_post_root_servicebus_many_diff_context", | ||
"aas.function.trigger": "Http", | ||
"component": "azure_functions", | ||
"http.method": "POST", | ||
"http.route": "/api/httppostrootservicebusmanydiffcontext", | ||
"http.status_code": "200", | ||
"http.url": "http://0.0.0.0:7071/api/httppostrootservicebusmanydiffcontext", | ||
"http.useragent": "python-httpx/x.xx.x", | ||
"language": "python", | ||
"runtime-id": "582a094714874ab1ac856c53c66d13ab", | ||
"span.kind": "server" | ||
}, | ||
"metrics": { | ||
"_dd.top_level": 1, | ||
"_dd.tracer_kr": 1.0, | ||
"_sampling_priority_v1": 1, | ||
"process_id": 31098 | ||
}, | ||
"duration": 1029446917, | ||
"start": 1752871958551887096 | ||
}, | ||
{ | ||
"name": "azure.servicebus.send", | ||
"service": "azure_servicebus", | ||
"resource": "topic.1", | ||
"trace_id": 0, | ||
"span_id": 2, | ||
"parent_id": 1, | ||
"type": "worker", | ||
"meta": { | ||
"_dd.base_service": "test-func", | ||
"component": "azure_servicebus", | ||
"messaging.destination.name": "topic.1", | ||
"messaging.operation": "send", | ||
"messaging.system": "servicebus", | ||
"network.destination.name": "localhost", | ||
"span.kind": "producer" | ||
}, | ||
"metrics": { | ||
"_dd.top_level": 1 | ||
}, | ||
"duration": 10415875, | ||
"start": 1752871959065671596 | ||
}, | ||
{ | ||
"name": "azure.servicebus.send", | ||
"service": "azure_servicebus", | ||
"resource": "topic.1", | ||
"trace_id": 0, | ||
"span_id": 3, | ||
"parent_id": 1, | ||
"type": "worker", | ||
"meta": { | ||
"_dd.base_service": "test-func", | ||
"_dd.p.tid": "687ab41600000000", | ||
"component": "azure_servicebus", | ||
"messaging.destination.name": "topic.1", | ||
"messaging.operation": "send", | ||
"messaging.system": "servicebus", | ||
"network.destination.name": "localhost", | ||
"span.kind": "producer" | ||
}, | ||
"metrics": { | ||
"_dd.top_level": 1 | ||
}, | ||
"duration": 6302958, | ||
"start": 1752871959077427680 | ||
}], | ||
[ | ||
{ | ||
"name": "azure.functions.invoke", | ||
"service": "test-func", | ||
"resource": "ServiceBus servicebustopic", | ||
"trace_id": 1, | ||
"span_id": 1, | ||
"parent_id": 0, | ||
"type": "serverless", | ||
"meta": { | ||
"_dd.p.dm": "-0", | ||
"_dd.p.tid": "687ab41700000000", | ||
"aas.function.name": "servicebustopic", | ||
"aas.function.trigger": "ServiceBus", | ||
"component": "azure_functions", | ||
"language": "python", | ||
"messaging.destination.name": "topic.1", | ||
"messaging.operation": "receive", | ||
"messaging.system": "servicebus", | ||
"runtime-id": "582a094714874ab1ac856c53c66d13ab", | ||
"span.kind": "consumer" | ||
}, | ||
"metrics": { | ||
"_dd.top_level": 1, | ||
"_dd.tracer_kr": 1.0, | ||
"_sampling_priority_v1": 1, | ||
"process_id": 31098 | ||
}, | ||
"duration": 58792, | ||
"start": 1752871959272796763 | ||
}]] |
82 changes: 82 additions & 0 deletions
82
..._functions.test_azure_functions_snapshot.test_service_bus_consume_same_context[many].json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
[[ | ||
{ | ||
"name": "azure.functions.invoke", | ||
"service": "test-func", | ||
"resource": "POST /api/httppostrootservicebusmanysamecontext", | ||
"trace_id": 0, | ||
"span_id": 1, | ||
"parent_id": 0, | ||
"type": "serverless", | ||
"meta": { | ||
"_dd.p.dm": "-0", | ||
"_dd.p.tid": "687ab37a00000000", | ||
"aas.function.name": "http_post_root_servicebus_many_same_context", | ||
"aas.function.trigger": "Http", | ||
"component": "azure_functions", | ||
"http.method": "POST", | ||
"http.route": "/api/httppostrootservicebusmanysamecontext", | ||
"http.status_code": "200", | ||
"http.url": "http://0.0.0.0:7071/api/httppostrootservicebusmanysamecontext", | ||
"http.useragent": "python-httpx/x.xx.x", | ||
"language": "python", | ||
"runtime-id": "7719a316c6f64aecb8ea198a9a951639", | ||
"span.kind": "server" | ||
}, | ||
"metrics": { | ||
"_dd.top_level": 1, | ||
"_dd.tracer_kr": 1.0, | ||
"_sampling_priority_v1": 1, | ||
"process_id": 29901 | ||
}, | ||
"duration": 1027642209, | ||
"start": 1752871802527607218 | ||
}, | ||
{ | ||
"name": "azure.servicebus.send", | ||
"service": "azure_servicebus", | ||
"resource": "topic.1", | ||
"trace_id": 0, | ||
"span_id": 2, | ||
"parent_id": 1, | ||
"type": "worker", | ||
"meta": { | ||
"_dd.base_service": "test-func", | ||
"component": "azure_servicebus", | ||
"messaging.destination.name": "topic.1", | ||
"messaging.operation": "send", | ||
"messaging.system": "servicebus", | ||
"network.destination.name": "localhost", | ||
"span.kind": "producer" | ||
}, | ||
"metrics": { | ||
"_dd.top_level": 1 | ||
}, | ||
"duration": 10803292, | ||
"start": 1752871803035560635 | ||
}, | ||
{ | ||
"name": "azure.functions.invoke", | ||
"service": "test-func", | ||
"resource": "ServiceBus servicebustopic", | ||
"trace_id": 0, | ||
"span_id": 3, | ||
"parent_id": 2, | ||
"type": "serverless", | ||
"meta": { | ||
"_dd.p.tid": "687ab37a00000000", | ||
"aas.function.name": "servicebustopic", | ||
"aas.function.trigger": "ServiceBus", | ||
"component": "azure_functions", | ||
"messaging.destination.name": "topic.1", | ||
"messaging.operation": "receive", | ||
"messaging.system": "servicebus", | ||
"runtime-id": "7719a316c6f64aecb8ea198a9a951639", | ||
"span.kind": "consumer" | ||
}, | ||
"metrics": { | ||
"_dd.top_level": 1, | ||
"process_id": 29901 | ||
}, | ||
"duration": 71209, | ||
"start": 1752871803228843135 | ||
}]] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.