Skip to content

Fix logging emitter resource packaging and rename to avoid classpath collision#19358

Closed
sarangv wants to merge 5 commits intoapache:masterfrom
sarangv:logging-emitter-allowlist
Closed

Fix logging emitter resource packaging and rename to avoid classpath collision#19358
sarangv wants to merge 5 commits intoapache:masterfrom
sarangv:logging-emitter-allowlist

Conversation

@sarangv
Copy link
Copy Markdown
Contributor

@sarangv sarangv commented Apr 21, 2026

Fixes #19030 (follow-up).

Description

Follow-up fix for PR #19030 (add defaultMetrics for logging emitter), which introduced metric filtering for the LoggingEmitter. Two issues were discovered during deployment testing in a real Druid cluster:

Fixed resource packaging in processing/pom.xml

The processing/pom.xml already had a <resources> block that only included the Sigar native library directory. When Maven sees any explicit <resources> section, it stops automatically including the default src/main/resources directory. This meant defaultMetrics.json was never packaged into the processing JAR, causing a DruidException (NOT_FOUND) at runtime when LoggingEmitter attempted to load it via getResourceAsStream().

The fix adds <resource><directory>src/main/resources</directory></resource> explicitly alongside the existing Sigar entry.

Renamed defaultMetrics.json to loggingEmitterAllowedMetrics.json

Both the processing module and the extensions-contrib/prometheus-emitter module ship a classpath resource called defaultMetrics.json, but they have completely different schemas:

  • Prometheus emitter: objects with dimensions, type, conversionFactor, help fields
  • Logging emitter: flat object with metric name keys and empty [] values

Depending on classloader ordering at runtime, LoggingEmitter.class.getClassLoader().getResourceAsStream("defaultMetrics.json") could resolve to the Prometheus emitter's file instead, causing a silent misconfiguration or parse failure. Renaming to loggingEmitterAllowedMetrics.json gives the logging emitter a unique resource name with no collision risk.

Release note

Operators using the logging emitter metric filtering feature introduced in #19030 should note that the bundled default allowlist resource has been renamed from defaultMetrics.json to loggingEmitterAllowedMetrics.json. No configuration changes are needed -- the emitter automatically loads the correct resource. The druid.emitter.logging.allowedMetricsPath property continues to work as documented for custom allowlist files.


Key changed/added classes in this PR
  • LoggingEmitter -- updated resource constant and Javadoc to reference loggingEmitterAllowedMetrics.json
  • LoggingEmitterConfig -- updated Javadoc to reference loggingEmitterAllowedMetrics.json
  • processing/pom.xml -- added explicit src/main/resources to <resources> block
  • processing/src/main/resources/loggingEmitterAllowedMetrics.json -- renamed from defaultMetrics.json
  • processing/src/test/resources/loggingEmitterAllowedMetrics.json -- renamed from defaultMetrics.json

This PR has:

  • been self-reviewed.
  • added documentation for new or modified features or behaviors.
  • a release note entry in the PR description.
  • added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.
  • added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
  • added unit tests or modified existing tests to cover new code paths, ensuring the threshold for code coverage is met.
  • been tested in a test Druid cluster.

Sarang Vadali and others added 5 commits February 18, 2026 09:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants