question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Include docs retrieved, docs output, and server time in FeedResponse diagnostics

See original GitHub issue

Is your feature request related to a problem? Please describe.

Our application would like to be able to log and emit metrics about the Cosmos DB queries it executes. We want to log/emit

  • the client observed latency,
  • the service observed latency,
  • the number of documents the query retrieved, and
  • the number of documents the query output.

We want to log/emit these per “page” of the query that we read (each call to FeedIterator.ReadNextAsync). We will aggregate them ourselves per account, per database, per container, and per query spec.

We can get the client observed latency using a Stopwatch or CosmosDiagnostics.GetClientElapsedTime. None of the other values are exposed in the v3 SDK.

We want docs retrieved and docs output details so that we can monitor and alert on how well we are using our indices.

We do not use Azure Monitor and it is not particularly easy for us to integrate with it. I also do not believe that Azure Monitor tracks these metrics per query spec.

Describe the solution you’d like

A well-typed, possibly lazily-parsed, possibly opt-in QueryMetrics property on FeedResponse or something that FeedResponse refers to. E.g., FeedResponse.Diagnostics.QueryMetrics.OutputDocumentCount would be fine.

Describe alternatives you’ve considered

We have looked at parsing the “QueryMetric” property from FeedResponse.Diagnostics.ToString() and extract the “totalExecutionTimeInMs”, “retrievedDocumentCount”, and “outputDocumentCount” properties. However, the format of the diagnostics string is non-contractual, as far as we are aware.

Additional context

The v2 SDK exposed this via the FeedResponse<T>.QueryMetrics property.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

0reactions
chwarrcommented, Feb 4, 2021

@timsander1, skimming #2097, I came to a similar conclusion as @bchong95.

Without the strongly-typed objects exposed, it looks like the “structured” way to consume metrics after #2097 would be to serialize them to JSON and then parse that. If the JSON is specified somewhere, that’s better than the unspecified key-value pairs that exist today.

Read more comments on GitHub >

github_iconTop Results From Across the Web

SQL query metrics for Azure Cosmos DB for NoSQL
Enables detailed logging of statistics of time spent in various phases of query execution like compilation time, index loop time, and document ......
Read more >
Index (Azure SDK for Java Reference ... - javadoc.io
Gets the diagnostics information for the current request to Azure Cosmos DB service. getDocumentCountUsage() - Method in class com.azure.cosmos.models.
Read more >
FeedResponse (Azure SDK for Java Reference Documentation)
Gets the correlation activity ID for the responses of a query operation or null if no correlation activity id is present. CosmosDiagnostics.
Read more >
Introduction to Azure Cosmos DB | Microsoft Docs
Azure Cosmos DB contains a write optimized, resource governed, schema-agnostic database engine that natively supports multiple data models: key-value, documents ...
Read more >
FAQ library
Find documentation, API & SDK references, tutorials, FAQs, and more resources for IBM Cloud products and services.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found