Skip to content

Provide a default metrics implementation using a LoggingProvider#4244

Closed
EdColeman wants to merge 5 commits into
apache:2.1from
EdColeman:add_default_metrics_provider
Closed

Provide a default metrics implementation using a LoggingProvider#4244
EdColeman wants to merge 5 commits into
apache:2.1from
EdColeman:add_default_metrics_provider

Conversation

@EdColeman
Copy link
Copy Markdown
Contributor

  • Adds the MeterRegistryFactory to ..core.spi.metrics and deprecates the one in ..core.metrics
  • Modified the GENERAL_MICROMETER_FACTORY to be a list of class names. This would allow multiple provides to be used. For example, logging and statsd. Primarly this may help track down metrics issues.
  • set the default for mini cluster to log metrics. This should increase the visibility of metrics during development, but may be cluttering the logs.

This replaces #4218

 - Adds the MeterRegistryFactory to .core.spi.metrics and deprecates
the one in core.metrics
 - Modified the GENERAL_MICROMETER_FACTORY to be a list of class names.
This would allow mutiple provides to be used. For example, logging and
statsd. Primarly this may help track down metrics issues.
 - set the default for mini cluster to log metrics. This should increase
the visibility of metrics during development, but may be cluttering the
logs.
logger.39.name = org.apache.accumulo.manager.Manager
logger.39.level = trace

property.metricsFilename = ./target/test-metrics
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.

I'm wondering if we should undo this change now, so that the metrics go to a specific file for the ITs instead of polluting the server logs.

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.

If we leave it, it needs reworked - that specific line you highlighted anyway - the log should be based on the service name (it's already a prop in the file) - hard coding it as test there helped when we tailed the logs so that it was fixed and well known, but maybe not the best example.

I'd prefer keeping it - or having it somewhere discover-able, because it is a pain to get it set up correctly when you are not configuring log4j regularly.

// defines the metrics update period, default is 60 seconds.
private final LoggingRegistryConfig lconf = c -> {
if (c.equals("logging.step")) {
return "60s";
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.

Is there any way to configure this to change the frequency?

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.

It is currently not a property - so no. 60s is actually the default, but specifically setting it here shows how to change it, if so inclined. I'm not sure how far we want to go with supporting this as a default - users should really be using a production solution, so bare-bones impl for this may be okay.

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.

Being able to configure the class but not pass any config seems cumbersome to me. If a user configure their own factory and wants to set a server to pass metrics too are they expected to hard code the server address?

Copy link
Copy Markdown
Contributor

@keith-turner keith-turner Feb 8, 2024

Choose a reason for hiding this comment

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

The config problem is not something to worry about this in PR as its a per-existing pattern. I am just wondering how someone would use actually use this feature and if it it requires recompiling java code for every metrics config change. If the end to end user experience could be improved we could consider that when introducing a new interface though.

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.

FWIW, I used System properties in TestStatsDRegistryFactory. Not sure if that helps or not.

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.

The TestStatsDRegistryFactory example splits config across two places. If a plugin follows this approach (its hard to think of any other approach a plugin could follow) then metrics config would end up being split across accumulo.properties file and accumulo-env.sh files. I will open a follow on issue about potentially improving this.

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.

Opened #4262

GENERAL_MICROMETER_FACTORY("general.micrometer.factory",
"org.apache.accumulo.core.spi.metrics.SimpleLoggingMeterRegistryFactory",
PropertyType.CLASSNAMELIST,
"A comma separated list of one or more class names that implement MeterRegistryFactory.",
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.

Suggested change
"A comma separated list of one or more class names that implement MeterRegistryFactory.",
"A comma separated list of one or more class names that implement MeterRegistryFactory. Prior to 2.1.3 the default value was blank. In 2.1.3 the default value was changed.",

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.

It would be good to explain the change in expected interface class in the docs and what the support for the old interface class is.

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.

Addressed in d8551b5

MeterRegistryFactory factory = clazz.getDeclaredConstructor().newInstance();
for (String factoryName : getTrimmedStrings(factoryClasses)) {
Class<? extends MeterRegistryFactory> clazz =
ClassLoaderUtil.loadClass(factoryName, MeterRegistryFactory.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.

If someone had the old Factory interface configured it seems like this would blow up.

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.

Addressed in d8551b5

 - handle deprecated factory classes
 - update property description.
PropertyType.CLASSNAMELIST,
"A comma separated list of one or more class names that implement MeterRegistryFactory. Prior to"
+ " 2.1.3 this was a single value and the default was an empty string. In 2.1.3 the default "
+ " was changed and it now can accept multiple class names.",
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.

Could also add something about the change in classes. Not sure if I got the packages correct.

In 2.1.3 a new type was introduced o.a.a.core.spi.metrics.MeterRegistryFacory and the existing type o.a.a.core.metrics.MeterRegistryFactory was deprecated.  For now classes that extend either type are accepted as a value to this property.

@EdColeman EdColeman added the blocker This issue blocks any release version labeled on it. label Feb 14, 2024
@EdColeman
Copy link
Copy Markdown
Contributor Author

I marked this as a blocker for 2.1.3. The SPI likely should go in some form into 2.1.3. Rather that merge this now, I working issue #4262 that could have additional improvements. If 2.1.3 release is ready, then what exists can be merged now and changes handled later.

@EdColeman
Copy link
Copy Markdown
Contributor Author

Replaced with #4459

@EdColeman EdColeman closed this Apr 13, 2024
@EdColeman EdColeman deleted the add_default_metrics_provider branch April 24, 2024 15:24
@ctubbsii ctubbsii modified the milestones: 3.1.0, 2.1.3 Jul 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

blocker This issue blocks any release version labeled on it.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants