Closed sebader closed 3 years ago
@sebader can you try the latest 3.18.0-preview which contains a new API GetContactedRegions
on the CosmosDiagnostics https://github.com/Azure/azure-cosmos-dotnet-v3/pull/2312? Please let us know if it doesn't solve your issue.
That looks exactly like what I’m looking for :) will give it a try tomorrow
thanks @j82w this works like a charm! :)
Can you maybe explain a bit more background when there would be more than one contacted region in the list? I assume that would that mean it has tried one region (how many times?) before it tried the next one?!
Please take a look at this documentation and make sure you have the client configured properly. By default it will only try the primary region.
https://docs.microsoft.com/en-us/azure/cosmos-db/troubleshoot-sdk-availability https://docs.microsoft.com/en-us/azure/cosmos-db/troubleshoot-dot-net-sdk?tabs=diagnostics-v3#retry-logic-
There is a lot of different scenarios that can cause it to retry on another region. The number of retries varies depending on the exception that is being hit. For example if the SDK gets a 503 when attempting to do a read item it will try going to secondary region assuming the SDK is properly configured. The ClientRetry policy handles most of the cross region failover logic.
Is your feature request related to a problem? Please describe. I'm using DirectMode to connect to a multi-master Cosmos DB and am using
ApplicationRegion
to connect to the closest instance. That works well. However, as DirectMode has very limited automatic tracing with ApplicationInsights, I'm adding my own instrumentation like this:The problem is that
_dbClient.Endpoint.Host
will always return the main endpoint of the database, but not the regional one that was actually used. So instead of e.g.https://mydb-eastus2.documents.azure.com:443/
orhttps://mydb-northeurope.documents.azure.com:443/
this just gives mehttps://mydb.documents.azure.com:443/
This of course then skews my monitoring. Debugging into this I can see that, in the above example,_claimsContainer
has an internal propertyClientContext.DocumentClient
which seems to have the information I'm looking for with ReadEndpoint and WriteEndpoint.Is there anyway to get this at runtime?
Describe the solution you'd like For proper tracing I need to know which endpoints a query actually hit.
Describe alternatives you've considered Using reflection...?!