Azure / azure-sdk-for-net

This repository is for active development of the Azure SDK for .NET. For consumers of the SDK we recommend visiting our public developer docs at https://learn.microsoft.com/dotnet/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-net.
MIT License
5.47k stars 4.8k forks source link

[FEATURE REQ] Get Session Information for a Queue/Subscription - Azure.Messaging.ServiceBus #20569

Closed davidallyoung closed 1 year ago

davidallyoung commented 3 years ago

Library or service name. What library or service is this request related to? [e.g. Azure.Storage.Blobs] Azure.Messaging.ServiceBus

Is your feature request related to a problem? Please describe. What feature would you like to get added? What problem is it solving? Hi! My team is working with Sessions and having a pretty good experience leveraging them for distributing multi-tenant workloads. One of the challenges we're running into is being a bit more proactive about our scaling vs using CPU/memory. What we'd really like to be able to build around are metrics about how many sessions are on the entity. My ask here if it would be possible for the client SDK to procure theses statistics? I use ServiceBusExplorer quite a lot and it seems to have a way to grab the Sessions on an entity, but it seems like that is on one of the older revisions of the SDK.

If it isn't a good touch point for the client SDK to pull these stats, has the ASB service team considered exposing a metric for this? We could then hook up with KEDA via the Azure Monitor scaler and let it rip.

Thank you for your consideration and the great work on the new SDK!

ghost commented 3 years ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @axisc.

Issue Details
**Library or service name.** What library or service is this request related to? [e.g. Azure.Storage.Blobs] Azure.Messaging.ServiceBus **Is your feature request related to a problem? Please describe.** What feature would you like to get added? What problem is it solving? Hi! My team is working with Sessions and having a pretty good experience leveraging them for distributing multi-tenant workloads. One of the challenges we're running into is being a bit more proactive about our scaling vs using CPU/memory. What we'd really like to be able to build around are metrics about how many sessions are on the entity. My ask here if it would be possible for the client SDK to procure theses statistics? I use ServiceBusExplorer quite a lot and it seems to have a way to grab the Sessions on an entity, but it seems like that is on one of the older revisions of the SDK. If it isn't a good touch point for the client SDK to pull these stats, has the ASB service team considered exposing a metric for this? We could then hook up with KEDA via the Azure Monitor scaler and let it rip. Thank you for your consideration and the great work on the new SDK!
Author: davidallyoung
Assignees: -
Labels: `Service`, `Service Attention`, `Service Bus`, `customer-reported`, `needs-team-attention`, `needs-triage`, `question`
Milestone: -
jsquire commented 3 years ago

Hi @davidallyoung. Thank you for your feedback. To my knowledge, the client library is exposing all of the information that the Service Bus service makes available, in the form of the QueueRuntimeProperties accessible from the ServiceBusAdministrationClient.

Unless we've overlooked something, to return session information, we'll need to ask the Service Bus team to make that available. I've routed this to the Service Bus team for their thoughts.

JoshLove-msft commented 3 years ago

Related - https://github.com/Azure/azure-sdk-for-net/issues/7380

davidallyoung commented 3 years ago

To add some more context on some other use-cases that I think are really interesting/useful for folks using sessions and run their workload in kubernetes.

https://github.com/kedacore/keda/issues/1479

Also, @JoshLove-msft thank you for pulling out that issue reference, I had forgotten that I had commented on that already 😅 .

worldspawn commented 3 years ago

Is there any issue open publicly with the service bus team for this?

Also how is service bus explorer able to produce a list of sessions active on a queue?

image

edit:

Apparently doable via AQMP - https://docs.microsoft.com/en-us/azure/service-bus-messaging/service-bus-amqp-request-response#enumerate-sessions

and whatever is going on here in the legacy library:

return this.messageCreator.CreateWcfMessage("http://schemas.microsoft.com/netservices/2011/06/servicebus/SbmpMessageReceiver/GetMessageSessions", (object) messageSessionsCommand, (string) null, this.retryPolicy, (TrackingContext) null, requestInfo);
JoshLove-msft commented 3 years ago

It does look like there is service support, but my understanding is that there were reliability concerns when we attempted to implement this in the JS SDK. /cc @ramya-rao-a

ramya-rao-a commented 3 years ago

Yes, when we tried to implement enumerate-sessions in the JS SDK 2 years ago, we did see the API behave unpredictably. Not sure if anything has changed since then, but we will sync with the service team and get back

JoshLove-msft commented 3 years ago

This feature would be useful when tuning the concurrency of a ServiceBusSessionProcessor.

JoshLove-msft commented 3 years ago

/cc @mathewc

JoshLove-msft commented 2 years ago

The API requires passing in a last-updated-time. If the value is not supplied the server returns an error response. After supplying this value, we only get back sessionIds that have session state set on them after this time. So if someone is not setting session state, they get back 0 sessions.

For sessions where session state is set, the session appears to always be returned even after all messages are completed. Perhaps this makes sense considering that this API appears to be designed to work based on the session state modified time.

JoshLove-msft commented 1 year ago

Because this only works based on the session state update time, and it doesn't even filter sessions that no longer have active messages, the available service feature doesn't address the user ask which is to get access to session counts for scaling purposes.

jsquire commented 1 year ago

At present, there is no way to implement this on the client, as service support does not exist. The Service Bus team has indicated that this is not on their roadmap currently. I'm going to close this issue out; should the service offer an API for this information, the client will support it.

If you would like to advocate for service support, consider opening a feature request in the Service Bus forum of the Azure feedback site.