druid icon indicating copy to clipboard operation
druid copied to clipboard

Groupby Metrics

Open GWphua opened this issue 2 months ago • 0 comments

Attempt at #18781 .

Description

Metrics Reporting via GroupByQueryMetrics

  • Remove method signatures in codebase which rely on using PerQueryStats to retrieve metrics, and retrieve query stats via the GroupByQueryMetrics instead.
  • Wrap a FinalizingResultsQueryRunner in a MetricsEmittingQueryRunner to emit the reported GroupByQueryMetrics.
  • Update all method signatures in the codebase which rely on GroupByStatsProvider or PerQueryStats.
  • Update GroupByStatsProvider Test.

Pass metrics via ResponseContext among the runners

  • Passing groupBy metrics via ResponseContext, which collates and stores the information in the Sequence objects.

Why Response Context?

  • In consideration of concurrency, QueryPlus may not have metrics, for example see GroupByMergingQueryRunner.
  • It is also hard to create QueryMetrics objects in classes working on layers lower than the GroupByQueryQueryToolChest such as GroupByMergingQueryRunner, as creating the query metrics in a QueryPlus requires the toolChest.

Future Tasks

  • Come up with new metric names, current metrics names clash with GroupByStatsMonitor. To be continued after agreeing about the logic of this PR with reviewers.
  • Documentations on new metrics names.
  • Documentation differentiating the use of GroupByStatsMonitor vs GroupByQueryMetrics.

Release note

Druid emits per-query GroupBy metrics by default.


Key changed/added classes in this PR

Metrics-related classes

  • GroupByQueryMetrics
  • GroupByStatsProvider

Segment Walkers

  • SinkQuerySegmentWalker
  • ClientQuerySegmentWalker
  • LocalQuerySegmentWalker
  • ServerManager

Query Runner Level

  • GroupByQueryQueryToolChest
  • GroupByMergingQueryRunner
  • GroupByRowProcessor
  • GroupByResponseContextKeys
  • ConcurrentGrouper
  • SpillingGrouper
  • LimitedTemporaryStorage

Others

  • Test files
  • Classes affected by method signature changes

This PR has:

  • [x] been self-reviewed.
  • [ ] added documentation for new or modified features or behaviors.
  • [x] a release note entry in the PR description.
  • [x] added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.
  • [x] 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.

GWphua avatar Nov 28 '25 03:11 GWphua