druid
druid copied to clipboard
Add query/time metric for SQL queries from router
This change adds the query/time metric for SQL queries from router. Currently, the native queries do report that metric whereas the SQL queries don't. The biggest problem in support SQL query metrics is that in router the SQL query doesn't have a native query plan which can be used to send metrics.
So, instead we extract sqlQueryId from the query response header and only set that dimension for query/time metric for SQL queries. Due to the lack of a native translated query, we use a dummy native query to interact with QueryMetrics interface but ensure that no dummy dimensions are set in the metric.
The reasons for not de-serializing the SQL query requests are :
- It can take time on the router which can add to the latencies of the query
- It is not possible to de-serialize the JDBC SQL queries easily (would require same structure as Avatica handlers)
This PR has:
- [x] been self-reviewed.
- [ ] using the concurrency checklist (Remove this item if the PR doesn't have any relation to concurrency.)
- [x] added documentation for new or modified features or behaviors.
- [x] added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.
- [ ] added or updated version, license, or notice information in licenses.yaml
- [x] added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
- [x] added unit tests or modified existing tests to cover new code paths, ensuring the threshold for code coverage is met.
- [ ] added integration tests.
- [x] been tested in a test Druid cluster.