-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Eventhub tracing #7153
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
Merged
Eventhub tracing #7153
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
40c9d8f
Experimentation on tracing and EventHubs
lmazuel 93dc908
Continue to let the initial excp raise
lmazuel b22a944
Naive direct tracing implementation
lmazuel e8724a4
Update Kind in EventHub to generic one
lmazuel c4dee26
Use contextmanager in EventHub
lmazuel e23c6f0
Remove opencensus specific import
lmazuel 8c4bede
Fix possible AttributeError
lmazuel ce59dc0
Remove parent concept
lmazuel 567b2bc
Remove receive tracing code
lmazuel a205ea5
Don't execute tracing on message if no tracing loaded
lmazuel 443cdc8
Try to re-order dev dep for CI
lmazuel 83d7128
Fix EH plugin dev deps
lmazuel 78b78ab
Add azure-core to azure-eventhub
lmazuel 22b78c2
Share req
lmazuel 82a39ef
ChangeLog
lmazuel db31f6b
EH extension is ok with b4
lmazuel d3433c3
Merge branch 'master' into eventhub_tracing
lmazuel 632a8d8
Install blob SDK for EH extension
lmazuel c4c4fd1
pylint
lmazuel 9fb2039
fix dev req
lmazuel 2f4df0a
dep fix
lmazuel af4acd7
the override had <. the setup actually defines <=. need to update the…
scbedd ce2948a
Tracing message from receive iterators as well
lmazuel bd2da67
Producer simplification
lmazuel b025231
Simplify eventprocessor
lmazuel 32ce0e8
Consider batch size
lmazuel 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
2 changes: 2 additions & 0 deletions
2
sdk/eventhub/azure-eventhubs-checkpointstoreblob-aio/dev_requirements.txt
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 |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| -e ../../../tools/azure-sdk-tools | ||
| -e ../../core/azure-core | ||
| -e ../../storage/azure-storage-blob | ||
| ../azure-eventhubs | ||
| pytest-asyncio>=0.8.0; python_version >= '3.5' |
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
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
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
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 |
|---|---|---|
|
|
@@ -12,6 +12,9 @@ | |
| from uamqp import types, constants, errors # type: ignore | ||
| from uamqp import SendClient # type: ignore | ||
|
|
||
| from azure.core.tracing import SpanKind | ||
| from azure.core.settings import settings | ||
|
|
||
| from azure.eventhub.common import EventData, EventDataBatch | ||
| from azure.eventhub.error import _error_handler, OperationTimeoutError, EventDataError | ||
| from ._consumer_producer_mixin import ConsumerProducerMixin | ||
|
|
@@ -32,6 +35,13 @@ def _set_partition_key(event_datas, partition_key): | |
| yield ed | ||
|
|
||
|
|
||
| def _set_trace_message(event_datas, parent_span=None): | ||
| ed_iter = iter(event_datas) | ||
| for ed in ed_iter: | ||
| ed._trace_message(parent_span) # pylint:disable=protected-access | ||
| yield ed | ||
|
|
||
|
|
||
| class EventHubProducer(ConsumerProducerMixin): # pylint:disable=too-many-instance-attributes | ||
| """ | ||
| A producer responsible for transmitting EventData to a specific Event Hub, | ||
|
|
@@ -218,12 +228,19 @@ def send(self, event_data, partition_key=None, timeout=None): | |
| :caption: Sends an event data and blocks until acknowledgement is received or operation times out. | ||
|
|
||
| """ | ||
| # Tracing code | ||
| span_impl_type = settings.tracing_implementation() # type: Type[AbstractSpan] | ||
| child = None | ||
| if span_impl_type is not None: | ||
| child = span_impl_type(name="Azure.EventHubs.send") | ||
| child.kind = SpanKind.CLIENT # Should be PRODUCER | ||
|
|
||
| self._check_closed() | ||
| if isinstance(event_data, EventData): | ||
| if partition_key: | ||
| event_data._set_partition_key(partition_key) # pylint: disable=protected-access | ||
| wrapper_event_data = event_data | ||
| wrapper_event_data._trace_message(child) # pylint: disable=protected-access | ||
| else: | ||
| if isinstance(event_data, EventDataBatch): # The partition_key in the param will be omitted. | ||
| if partition_key and partition_key != event_data._partition_key: # pylint: disable=protected-access | ||
|
|
@@ -232,10 +249,17 @@ def send(self, event_data, partition_key=None, timeout=None): | |
| else: | ||
| if partition_key: | ||
| event_data = _set_partition_key(event_data, partition_key) | ||
| event_data = _set_trace_message(event_data, child) | ||
| wrapper_event_data = EventDataBatch._from_batch(event_data, partition_key) # pylint: disable=protected-access | ||
| wrapper_event_data.message.on_send_complete = self._on_outcome | ||
| self._unsent_events = [wrapper_event_data.message] | ||
| self._send_event_data_with_retry(timeout=timeout) | ||
|
|
||
| if span_impl_type is not None: | ||
| with child: | ||
| self._client._add_span_request_attributes(child) # pylint: disable=protected-access | ||
| self._send_event_data_with_retry(timeout=timeout) | ||
| else: | ||
| self._send_event_data_with_retry(timeout=timeout) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. both if and else has this statement. How about removing the else block and pull the same statement in "if" out of "if"? |
||
|
|
||
| def close(self, exception=None): # pylint:disable=useless-super-delegation | ||
| # type:(Exception) -> None | ||
|
|
||
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
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.