apache/druid · error · IllegalStateException

Unsupported method in default query metrics implementation.

Error message

Unsupported method in default query metrics implementation.

What it means

DefaultSearchQueryMetrics provides a minimal metrics implementation where most dimension-recording methods are intentionally unsupported; context(SearchQuery) is one of the no-op-by-default methods that throws ISE if invoked. Druid throws this to signal that query-metric emission was attempted on the default implementation, which only delegates a subset of methods (e.g. server, status). It indicates a wiring/configuration issue rather than a query failure.

Source

Thrown at processing/src/main/java/org/apache/druid/query/search/DefaultSearchQueryMetrics.java:121

    throw new ISE("Unsupported method in default query metrics implementation.");
  }

  @Override
  public void sqlQueryId(String sqlQueryId)
  {
    throw new ISE("Unsupported method in default query metrics implementation.");
  }

  @Override
  public void granularity(SearchQuery query)
  {
    // Don't emit by default
  }

  @Override
  public void context(SearchQuery query)
  {
    throw new ISE("Unsupported method in default query metrics implementation.");
  }

  @Override
  public void server(String host)
  {
    delegateQueryMetrics.server(host);
  }

  @Override
  public void remoteAddress(String remoteAddress)
  {
    delegateQueryMetrics.remoteAddress(remoteAddress);
  }

  @Override
  public void status(String status)
  {
    delegateQueryMetrics.status(status);

View on GitHub (pinned to 9b90983fd2)

Solutions

  1. Provide a real SearchQueryMetrics implementation/factory instead of DefaultSearchQueryMetrics
  2. Remove or guard calls to context(query) when using the default implementation
  3. Use SearchQueryMetricsFactory.okFactory() or a custom factory that populates all dimensions

Example fix

// before
SearchQueryMetricsFactory factory = (q, c) -> new DefaultSearchQueryMetrics(c);
// after
SearchQueryMetricsFactory factory = SearchQueryMetricsFactory.okFactory(); // or a full custom implementation
Defensive patterns

Strategy: validation

Validate before calling

if (metrics instanceof DefaultSearchQueryMetrics) { throw new IllegalStateException("Default metrics do not support context dimension; configure a full factory"); }

Type guard

boolean supportsFullMetrics(SearchQueryMetrics m) { return !(m instanceof DefaultSearchQueryMetrics); }

Try / catch

try { metrics.context(query); } catch (ISE e) { log.warn("context metric unsupported on default implementation"); }

Prevention

When it happens

Trigger: Installing DefaultSearchQueryMetrics where a full SearchQueryMetricsFactory is expected and code records the 'context' dimension; custom monitoring code calling metrics.context(query) on the default instance.

Common situations: Configuring a search query metrics factory that returns DefaultSearchQueryMetrics while an emitter or monitoring extension expects full dimensions; custom emission code written against the full SearchQueryMetrics interface.

Related errors


AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07). Data as JSON: /api/errors/4a9dcc4f830d5105. Report an issue: GitHub.