{"record":{"id":"4a9dcc4f830d5105","repo":"apache/druid","slug":"unsupported-method-in-default-query-metrics-implem","errorCode":null,"errorMessage":"Unsupported method in default query metrics implementation.","messagePattern":"Unsupported method in default query metrics implementation\\.","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"processing/src/main/java/org/apache/druid/query/search/DefaultSearchQueryMetrics.java","lineNumber":121,"sourceCode":"    throw new ISE(\"Unsupported method in default query metrics implementation.\");\n  }\n\n  @Override\n  public void sqlQueryId(String sqlQueryId)\n  {\n    throw new ISE(\"Unsupported method in default query metrics implementation.\");\n  }\n\n  @Override\n  public void granularity(SearchQuery query)\n  {\n    // Don't emit by default\n  }\n\n  @Override\n  public void context(SearchQuery query)\n  {\n    throw new ISE(\"Unsupported method in default query metrics implementation.\");\n  }\n\n  @Override\n  public void server(String host)\n  {\n    delegateQueryMetrics.server(host);\n  }\n\n  @Override\n  public void remoteAddress(String remoteAddress)\n  {\n    delegateQueryMetrics.remoteAddress(remoteAddress);\n  }\n\n  @Override\n  public void status(String status)\n  {\n    delegateQueryMetrics.status(status);","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/query/search/DefaultSearchQueryMetrics.java#L103-L139","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Provide a real SearchQueryMetrics implementation/factory instead of DefaultSearchQueryMetrics","Remove or guard calls to context(query) when using the default implementation","Use SearchQueryMetricsFactory.okFactory() or a custom factory that populates all dimensions"],"exampleFix":"// before\nSearchQueryMetricsFactory factory = (q, c) -> new DefaultSearchQueryMetrics(c);\n// after\nSearchQueryMetricsFactory factory = SearchQueryMetricsFactory.okFactory(); // or a full custom implementation","handlingStrategy":"validation","validationCode":"if (metrics instanceof DefaultSearchQueryMetrics) { throw new IllegalStateException(\"Default metrics do not support context dimension; configure a full factory\"); }","typeGuard":"boolean supportsFullMetrics(SearchQueryMetrics m) { return !(m instanceof DefaultSearchQueryMetrics); }","tryCatchPattern":"try { metrics.context(query); } catch (ISE e) { log.warn(\"context metric unsupported on default implementation\"); }","preventionTips":["Register SearchQueryMetricsFactory.okFactory() or a full custom implementation","Do not call dimension methods documented 'Don't emit by default' on the default implementation","Wrap custom metric recording behind the factory interface, not the default class"],"tags":["metrics","search-query","configuration","unsupported-operation"],"backgroundTag":"method-not-implemented","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}