-
Notifications
You must be signed in to change notification settings - Fork 987
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Micrometer integration #795
Comments
I've implemented one It exposes the following metrics:
|
@madgnome how use |
mycode is define change default eventbus time from
create
and implement
i want to know this method to report redis metrics is ok? |
This approach uses Lettuce's latency collector and the publication mechanism to push metrics to Micrometer. I would rather suggest providing a |
thanks! @mp911de |
@madgnome Late to the party, but would you have a chance to show us the |
FWIW, on a slightly related note, I looked into adding metrics for our connection-pool usage of Lettuce. This works, and produces metrics which can be visualized in e.g. VisualVM with the MBeans plugin. diff --git a/src/foo/bar/managers/caching/RedisClientManager.java b/src/foo/bar/managers/caching/RedisClientManager.java
index 1ce97a7a89..eab511ac66 100644
--- a/src/foo/bar/managers/caching/RedisClientManager.java
+++ b/src/foo/bar/managers/caching/RedisClientManager.java
@@ -218,6 +218,9 @@ public class RedisClientManager {
GenericObjectPoolConfig<Object> poolConfig = new GenericObjectPoolConfig<>();
poolConfig.setMaxTotal( redisServer.getConnectionPoolSize() );
poolConfig.setMinIdle( redisServer.getConnectionPoolSize() );
+ poolConfig.setJmxEnabled( true );
+ poolConfig.setJmxNameBase( "foo.bar.redis.pool:name=" );
+ poolConfig.setJmxNamePrefix( "RedisClientManager.pool" );
return ConnectionPoolSupport
.createGenericObjectPool( () -> { However, I'd much rather see that these metrics are propagated to our custom metric registry (which be Micrometer, Dropwizard, etc, based on how our software is configured). Right now, the code is quite tightly coupled to JMX which is unfortunate. I looked a while yesterday into overriding this, by making a local copy of the @mp911de Do you have any ideas on how to use |
What do you mean with custom metrics provider? There's a metrics integration via I hadn't the chance yet to wrap my head around a Micrometer integration. Happy to support anyone who's working on a Lettuce/Micrometer integration. |
We have our own
Thanks, that's a good suggestion which could be useful! For our specific use case, this might not be so bad since we want to publish it to our custom |
Is this available in a useable form at the moment? @madgnome is your code open sourced anywhere? Looking at integrating Lettuce with Micrometer in my application and exploring right now. |
@rajki We ended up wrapping together something like this. (note: not directly usable as-is, needs to be tweaked a bit for reasons described after the snippet): ClientResources clientResources = DefaultClientResources.builder()
.commandLatencyPublisherOptions( DefaultEventPublisherOptions.builder()
.eventEmitInterval( Duration.ofSeconds( 10 ) )
.build()
)
.commandLatencyCollector( new CustomCommandLatencyCollector() )
.build();
// Create the client something like this
RedisClient client = RedisClient.create( clientResources, redisUri ) The private static class CustomCommandLatencyCollector implements CommandLatencyCollector {
@Override
public void recordCommandLatency( SocketAddress local, SocketAddress remote, ProtocolKeyword commandType, long firstResponseLatency, long completionLatency ) {
// Note: replace with a Micrometer Timer call, calling
// record(duration, TimeUnit.NANOSECONDS) on a timer which is preferably cached
// between calls. (Map.computeIfAbsent() is useful for this)
metricRegistry.addTimerEvent( "method", commandType.name(), completionLatency, TimeUnit.NANOSECONDS );
}
@Override
public void shutdown() {
}
@Override
public Map<CommandLatencyId, CommandMetrics> retrieveMetrics() {
return ImmutableMap.of();
}
@Override
public boolean isEnabled() {
return true;
}
} Our particular use case does not use Micrometer directly, which is because we have a wrapper layer which redirects calls to the configured metric provider (Micrometer, Dropwizard, etc...) which is why the example is not exactly usable as-is. I am posting it anyway, in the hope that it will help others who, like me, find it frustrating to not know in which direction to start... 🙂 |
Thanks @perlun, this is very useful. I'll explore and see if I can come up with something that builds off of this suggestion. |
While using it, I get nullpointerexception for redisConnectionFactory at RedisMetricsBinder:bindTo. Listing my whole redis configuration class below.
|
Signed-off-by: Steven Sheehy <[email protected]> Original pull request: #1495.
Like me, if you came here looking for OOTB Micrometer support, and wondering what the conclusion is for this ticket, Micrometer support seems to be available in the 6.0.x release. |
It's actually in 6.1 despite what the docs say. |
See https://github.com/micrometer-metrics/micrometer
The text was updated successfully, but these errors were encountered: