Skip to content

Use LoadScope to list services where a monitor should be loaded#18321

Merged
kfaraz merged 4 commits intoapache:masterfrom
kfaraz:use_load_scope_on_monitors
Jul 25, 2025
Merged

Use LoadScope to list services where a monitor should be loaded#18321
kfaraz merged 4 commits intoapache:masterfrom
kfaraz:use_load_scope_on_monitors

Conversation

@kfaraz
Copy link
Copy Markdown
Contributor

@kfaraz kfaraz commented Jul 24, 2025

Description

Defining a load scope safeguards against loading monitors on services where they are not supported.
It also simplifies configuration so that druid.monitoring.monitors can always be defined in
common.runtime.properties without requiring to override in service-specific runtime.properties.

Changes

  • Use LoadScope with monitors, same as with DruidModule
  • Add test in MetricsModuleTest
  • Use service-specific monitor in EmbeddedKafkaClusterMetricsTest

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 or updated version, license, or notice information in licenses.yaml
  • 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.
  • added integration tests.
  • been tested in a test Druid cluster.

Copy link
Copy Markdown
Contributor

@gianm gianm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main change LGTM. Can you please also update docs/configuration/index.md? The section "Metrics monitors" makes various references to needing service-specific configuration, which shouldn't be necessary anymore. It could be simplified to say that all monitors should be specified in common.runtime.properties, and they will only be active on the services that support them.

*/
private boolean shouldLoadMonitor(Class<?> monitorClass, Set<NodeRole> nodeRoles)
{
final LoadScope loadScope = monitorClass.getAnnotation(LoadScope.class);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any desire to get fancy here and check superclass annotations too? Probably not necessary but just something that came to mind.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, that can be done.

I guess we would need to check the superclass recursively if there is no annotation defined at the current class level. Would that make sense?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that's what I was imagining.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Updated to handle annotations on super-class and added tests.

@kfaraz
Copy link
Copy Markdown
Contributor Author

kfaraz commented Jul 24, 2025

Thanks for the review, @gianm ! I have updated the docs as suggested.

@Akshat-Jain Akshat-Jain reopened this Jul 25, 2025
@kfaraz kfaraz merged commit 87d6bf1 into apache:master Jul 25, 2025
77 checks passed
@kfaraz kfaraz deleted the use_load_scope_on_monitors branch July 25, 2025 06:25
@cecemei cecemei added this to the 35.0.0 milestone Oct 21, 2025
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.

4 participants