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

Eventhub tracing #7153

Merged
merged 26 commits into from
Sep 27, 2019
Merged

Eventhub tracing #7153

merged 26 commits into from
Sep 27, 2019

Conversation

lmazuel
Copy link
Member

@lmazuel lmazuel commented Sep 9, 2019

EventHub part of #6597

@lmazuel lmazuel added Event Hubs Client This issue points to a problem in the data-plane of the library. labels Sep 9, 2019
@AutorestCI
Copy link
Contributor

AutorestCI commented Sep 9, 2019

(message created by the CI based on PR content)

Installation instruction

Package azure-eventhubs

You can install the package azure-eventhubs of this PR using the following command:
pip install "git+https://github.com/Azure/azure-sdk-for-python@eventhub_tracing#egg=azure-eventhubs&subdirectory=azure-eventhubs"

You can build a wheel to distribute for test using the following command:
pip wheel --no-deps "git+https://github.com/Azure/azure-sdk-for-python@eventhub_tracing#egg=azure-eventhubs&subdirectory=azure-eventhubs"

If you have a local clone of this repository, you can also do:

  • git checkout eventhub_tracing
  • pip install -e ./azure-eventhubs

Or build a wheel file to distribute for testing:

  • git checkout eventhub_tracing
  • pip wheel --no-deps ./azure-eventhubs

Package azure-eventhubs-checkpointstoreblob-aio

You can install the package azure-eventhubs-checkpointstoreblob-aio of this PR using the following command:
pip install "git+https://github.com/Azure/azure-sdk-for-python@eventhub_tracing#egg=azure-eventhubs-checkpointstoreblob-aio&subdirectory=azure-eventhubs-checkpointstoreblob-aio"

You can build a wheel to distribute for test using the following command:
pip wheel --no-deps "git+https://github.com/Azure/azure-sdk-for-python@eventhub_tracing#egg=azure-eventhubs-checkpointstoreblob-aio&subdirectory=azure-eventhubs-checkpointstoreblob-aio"

If you have a local clone of this repository, you can also do:

  • git checkout eventhub_tracing
  • pip install -e ./azure-eventhubs-checkpointstoreblob-aio

Or build a wheel file to distribute for testing:

  • git checkout eventhub_tracing
  • pip wheel --no-deps ./azure-eventhubs-checkpointstoreblob-aio

Direct download

Your files can be directly downloaded here:

@joshfree joshfree requested a review from lmolkova September 10, 2019 21:15
@lmazuel lmazuel force-pushed the eventhub_tracing branch 3 times, most recently from 710ecbf to 6a51f46 Compare September 12, 2019 23:21
@lmazuel lmazuel requested a review from johanste September 12, 2019 23:32
@lmazuel lmazuel marked this pull request as ready for review September 12, 2019 23:32
@lmazuel lmazuel changed the base branch from master to tracing_update September 12, 2019 23:32
message_span = child.span(name="Azure.EventHubs.message")
message_span.start()
app_prop = dict(message.application_properties)
app_prop.setdefault(b"Diagnostic-Id", message_span.get_trace_parent().encode('ascii'))
Copy link
Member

Choose a reason for hiding this comment

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

what if message was already instrumented (in previous send try or by user)?

Copy link
Member

Choose a reason for hiding this comment

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

setdefault will not owerwrite the item if it is already set. We could avoid the cost of encoding by doing an in check, however.

Copy link
Member Author

@lmazuel lmazuel Sep 19, 2019

Choose a reason for hiding this comment

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

I don't expect this encode to take a lot, since the string is 0-9A-Z and the encoder is ascii. That will let mostly cast it "as-is" under the hood.
With the in, in case we do need to assign it, we will do another lookup to find the right spot. Without the in, we indeed ascii-encode for nothing sometimes, but if we need to insert we know already where it is.

@lmazuel lmazuel changed the base branch from tracing_update to master September 23, 2019 21:18
… error message, but this will fix the analyze error
Copy link
Contributor

@YijunXieMS YijunXieMS left a comment

Choose a reason for hiding this comment

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

EventHubConsumer of both sync and aio has next / anext. They should also be tracked? Users can receive evetns by:

for event in consumer:  # sync EventHubConsumer 
    pass  #  do something

or

async for event in consumer: # async EventHubConsumer
    pass  #  do something

@lmazuel
Copy link
Member Author

lmazuel commented Sep 25, 2019

@YijunXieMS it has been decided in arch meeting that "receive" should not be traced.

@YijunXieMS
Copy link
Contributor

/azp run python - eventhubs - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

sdk/eventhub/azure-eventhubs/azure/eventhub/producer.py Outdated Show resolved Hide resolved
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)
Copy link
Contributor

Choose a reason for hiding this comment

The 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"?

@YijunXieMS
Copy link
Contributor

/azp run python - eventhubs - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Contributor

@YijunXieMS YijunXieMS left a comment

Choose a reason for hiding this comment

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

LGTM

@YijunXieMS YijunXieMS merged commit dc7dfb0 into master Sep 27, 2019
iscai-msft added a commit to iscai-msft/azure-sdk-for-python that referenced this pull request Sep 28, 2019
…into base_to_properties

* 'master' of https://github.com/Azure/azure-sdk-for-python:
  Eventhub tracing (Azure#7153)
  [devtools-cognitiveservices] temp fix to allow passing cog key in headers for azure-core (Azure#7471)
  adds back create mgmt client (Azure#7470)
  Update SDK Tools Consumption (Azure#7148)
  [AutoPR] peering/resource-manager (Azure#6923)
  Key Vault: making poller return Certificate or CertificateOperation (Azure#7349)
  Patch os.environ in Identity mock tests (Azure#7452)
  Unskip urllib3 related test (Azure#7442)
@lmazuel lmazuel deleted the eventhub_tracing branch October 2, 2019 15:10
YijunXieMS pushed a commit to YijunXieMS/azure-sdk-for-python that referenced this pull request Oct 9, 2019
* Experimentation on tracing and EventHubs

* Continue to let the initial excp raise

* Naive direct tracing implementation

* Update Kind in EventHub to generic one

* Use contextmanager in EventHub

* Remove opencensus specific import

* Fix possible AttributeError

* Remove parent concept

* Remove receive tracing code

* Don't execute tracing on message if no tracing loaded

* Try to re-order dev dep for CI

* Fix EH plugin dev deps

* Add azure-core to azure-eventhub

* Share req

* ChangeLog

* EH extension is ok with b4

* Install blob SDK for EH extension

* pylint

* fix dev req

* dep fix

* the override had <. the setup actually defines <=. need to update the error message, but this will fix the analyze error

* Tracing message from receive iterators as well

* Producer simplification

* Simplify eventprocessor

* Consider batch size
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Client This issue points to a problem in the data-plane of the library. Event Hubs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants