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.17k stars 4.53k forks source link

[FEATURE REQ] Azure SDK emit metrics about AAD token acquisition cache hit/miss #41056

Open hoarfrostm opened 6 months ago

hoarfrostm commented 6 months ago

Library name

Azure.Identity

Please describe the feature.

Please add a feature to let Azure SDK emit a counter for attempts to get a token with a dimension indicating if it was a hit or miss

jsquire commented 6 months ago

Thank you for your feedback. Tagging and routing to the team member best able to assist.

christothes commented 6 months ago

Because the SDK generally delegates interaction with token cache to other components, such as MSAL, I don't believe there is a reliable way to create a token cache hit/miss metric. This would need to be calculated after the fact based on event aggregation of resource requests vs token requests to the authority. And even in that case, it may not be representative of blocking cache misses, because often times an authentication policy would be refreshing the cache in the background.

Could you clarify what specific questions you would be looking to answer with a metric like this?

github-actions[bot] commented 6 months ago

Hi @hoarfrostm. Thank you for opening this issue and giving us the opportunity to assist. To help our team better understand your issue and the details of your scenario please provide a response to the question asked above or the information requested above. This will help us more accurately address your issue.

hoarfrostm commented 5 months ago

Recently, we are trying to migrate from connection string authentication to AAD authentication for Azure non-computing resources (Storage, EventHub, ServiceBus, CosmosDB, SQL service, Cognitive service). We'd like to build some metrics to help monitor the performance of AAD authentications. Token cache hit/miss is one of them.