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

[Service Bus] Tracing for send API #11651

Merged
merged 25 commits into from
Oct 8, 2020

Conversation

HarshaNalluru
Copy link
Member

@HarshaNalluru HarshaNalluru commented Oct 5, 2020

Tracing for the send related APIs - inspired from event-hubs support for the same though with minor differences #5207

@ghost ghost added the Service Bus label Oct 5, 2020
@HarshaNalluru
Copy link
Member Author

HarshaNalluru commented Oct 6, 2020

/azp run js - servicebus - tests

@azure-pipelines
Copy link

No pipelines are associated with this pull request.

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@HarshaNalluru
Copy link
Member Author

/azp run js - servicebus - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

* @internal
* @ignore
*/
export function createMessageSpan(
Copy link
Contributor

Choose a reason for hiding this comment

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

Feedback not for this PR, but a note for both Event Hubs & Service Bus for which we can log a generic issue on improvements and make changes for both packages at once in the future:

  • The name createMessageSpan() is slightly misleading as it may indicate that I can use it at any time when a message is involved. In reality, this method is tied to the "producer" kind, so is usable only when sending message.
  • Also, jsdoc for this method would be helpful
  • Why is config optional here? I would imagine that we would always have a ConnectionConfig

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 to the first two!

Why is config optional here? I would imagine that we would always have a ConnectionConfig

parentSpan is not a required parameter but feels primary, I believe that was the reason Chris made the config optional in event-hubs. I can make it the first param in both service-bus and event-hubs and make it required in a later PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

Logged #11687

/**
* The `Span` or `SpanContext` to use as the `parent` of any spans created while calling operations that make a request to the service.
*/
parentSpan?: Span | SpanContext | null;
Copy link
Contributor

Choose a reason for hiding this comment

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

I noticed in Event Hubs that null is not an option for parentSpan. Why do we have this here?

Copy link
Member Author

Choose a reason for hiding this comment

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

There are other places where we allow the span to be "null" which is a valid value and it signifies the rootSpan.

Moreover, I needed to allow this "null" since I'm calling getParentSpan() for the tryAdd over array of messages which may return a null value.

In event-hubs, this tracing for "array of messages" case is duplicated.
"null" is a valid value and event-hubs should also allow this.

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'll log an issue for fixing it in event-hubs.

Copy link
Member Author

Choose a reason for hiding this comment

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

Logged #11687

sdk/servicebus/service-bus/src/sender.ts Outdated Show resolved Hide resolved
sdk/servicebus/service-bus/src/sender.ts Outdated Show resolved Hide resolved
sdk/servicebus/service-bus/src/sender.ts Show resolved Hide resolved
Copy link
Member

@richardpark-msft richardpark-msft left a comment

Choose a reason for hiding this comment

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

Looks good.

@HarshaNalluru
Copy link
Member Author

/azp run js - servicebus - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

// No cleanup:
// "Closing the link" cleanup would step over new link initializations
// and can possibly clear the link once created, hence we do the cleanup
// at the time of new link creation
Copy link
Contributor

Choose a reason for hiding this comment

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

Take the case of a disconnected event firing and user making no more send requests. In that case, the loop to keep renewing the token on the sender link does not get cleared and we will have a rogue loop on our hands

Copy link
Contributor

Choose a reason for hiding this comment

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

I realize that we can argue that in the normal case of user stopping to make any send requests and no disconnected event, our loop will still keep trying to renew the lock. In that case, at some point the service will close the link because it has been idle for too long. That results in an "amqp close" event in which case we should clean up the timers and assets from our end. In this PR, we are removing those as well

Copy link
Member Author

Choose a reason for hiding this comment

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

Upon discussion, reverted this in favour of the proposal for cleanup with detached where onDetached would be called before the refreshConnection() is invoked.

Triggered live tests https://dev.azure.com/azure-sdk/internal/_build/results?buildId=567200&view=results

// For the cases such as connection is disconnected, onAmqpClose and onSessionClose events,
// we don't clear the link for sender. To compensate for the above,
// we are calling close on the link to cleanup before creating the new one.
await this.link.close();
Copy link
Contributor

Choose a reason for hiding this comment

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

Why close() and not closeLink()?
The former sets the _wasClosedPermanently to true and removes the link from the context cache which may have other repercussions

Copy link
Member Author

Choose a reason for hiding this comment

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

.close() is different from .link.close(), we are not calling .close() here.

closeLink would try acquiring a lock but the initialization already has it, leading into a deadlock. Hence closeLink shouldn't be called. Alternatively, closeLinkImpl can be called which is a combination of clear-timeout and link.close(). Timers are handled in ensureTokenRenewal anyway, so link.close() makes sense here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Anyways, reverted this in favour of the proposal for cleanup with detached where onDetached would be called before the refreshConnection() is invoked.

@HarshaNalluru
Copy link
Member Author

/azp run js - servicebus - tests

@azure-pipelines
Copy link

No pipelines are associated with this pull request.

@HarshaNalluru
Copy link
Member Author

/azp run js - servicebus - tests

@azure-pipelines
Copy link

No pipelines are associated with this pull request.

@HarshaNalluru
Copy link
Member Author

/azp run js - servicebus - tests

@azure-pipelines
Copy link

No pipelines are associated with this pull request.

@HarshaNalluru
Copy link
Member Author

/azp run js - servicebus - tests

@azure-pipelines
Copy link

No pipelines are associated with this pull request.

@HarshaNalluru
Copy link
Member Author

/azp run js - servicebus - tests

@azure-pipelines
Copy link

No pipelines are associated with this pull request.

@HarshaNalluru
Copy link
Member Author

Skipped and logged an issue for the flaky test #11718

@HarshaNalluru
Copy link
Member Author

/check-enforcer override

@ramya-rao-a ramya-rao-a merged commit 3448028 into Azure:master Oct 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants