I can see in the logs/traces the Entity Framework Cosmos DB provider displays the request units after each operation. Is there an easy way to get to that RU number programmatically? Can be pretty useful in integration, and benchmark tests, CI/CD gates, etc. It should be easy, right? It is in the header of the response to the HttpClient.
This might not be the easiest method possibly, but with the lack of other responses I thought it was worth mentioning.
You could add a custom HttpClientFactory
using the CosmosDbContextOptionsBuilder
class. Then let your factory yield you an instance of an HttpClient
with a custom DelegatingHandler
. In the handler you can override the SendAsync
and obtain the response which should include the RU charge in the headers if applicable.