Cosmos: Be able to access response headers
As far as I'm aware there is no way to access cosmos API response headers when using the cosmos db provider for EF. I'd like to be able to know the document size for each of my entities, which when using cosmos API directly, is in the response headers, however there is no way to access these response headers via EF.
This kind of thing generally isn't very compatible with LINQ querying, where you get back your own .NET types as output. I'll leave this open in the backlog to see if other users have this request.
Out of curiosity, why do you need to know the document size?
We want to know the document size as we need to split our documents before they get to the cosmos 2MB limit, at the moment we have set this limit to a count of the amount of things in a document, which we have calculated to be getting close to this limit. This works, however a more elegant solution would be to split the document based on the actual size rather an an approximation.
Thanks for the context @riley211. Isn't this something that would better belong in the logs that EF emits, rather than a programmatic means which you'd then need to access around each and every query, and make sure to manually report/log somehow?
@ajcvickers this also smells to me like possible potential for an interceptor...
Agreed.
@roji in our case it's something that we want to respond to in code rather than just report/log. When we are adding things to an array in a cosmos document, it is at that point we split to another document if the addition of new things into the document will hit our precalculated limit.
I'm not too familiar with interceptors but after some quick reading, this could be something suitable.