-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Jedis pool metrics binder (#756)
Signed-off-by: Paolo Di Tommaso <[email protected]> Signed-off-by: munishchouhan <[email protected]> Co-authored-by: Munish Chouhan <[email protected]> Co-authored-by: munishchouhan <[email protected]>
- Loading branch information
1 parent
3fd5643
commit a6b2833
Showing
4 changed files
with
74 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
src/main/groovy/io/seqera/wave/redis/JedisPoolMetricsBinder.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Wave, containers provisioning service | ||
* Copyright (c) 2023-2024, Seqera Labs | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package io.seqera.wave.redis | ||
|
||
import groovy.transform.CompileStatic; | ||
import io.micrometer.core.instrument.MeterRegistry; | ||
import io.micrometer.core.instrument.binder.MeterBinder; | ||
import redis.clients.jedis.JedisPool; | ||
|
||
/** | ||
* Implements {@link MeterBinder} for {@link redis.clients.jedis.JedisPool} | ||
* | ||
* @author Paolo Di Tommaso <[email protected]> | ||
*/ | ||
@CompileStatic | ||
class JedisPoolMetricsBinder implements MeterBinder { | ||
|
||
private final JedisPool pool | ||
|
||
JedisPoolMetricsBinder(JedisPool pool) { | ||
this.pool = pool; | ||
} | ||
|
||
@Override | ||
void bindTo(MeterRegistry registry) { | ||
registry.gauge("jedis.pool.active", pool, JedisPool::getNumActive); | ||
registry.gauge("jedis.pool.idle", pool, JedisPool::getNumIdle); | ||
registry.gauge("jedis.pool.waiters", pool, JedisPool::getNumWaiters); | ||
|
||
// Connection lifecycle metrics | ||
registry.gauge("jedis.pool.created", pool, JedisPool::getCreatedCount); | ||
registry.gauge("jedis.pool.destroyed", pool, JedisPool::getDestroyedCount); | ||
|
||
// Borrow/Return statistics | ||
registry.gauge("jedis.pool.borrowed", pool, JedisPool::getBorrowedCount); | ||
registry.gauge("jedis.pool.returned", pool, JedisPool::getReturnedCount); | ||
|
||
// Additional metrics (resets, evictions, etc.) | ||
registry.gauge("jedis.pool.max.borrow.wait.millis", pool, (p)-> p.maxBorrowWaitDuration.toMillis() as double) | ||
registry.gauge("jedis.pool.mean.borrow.wait.millis", pool, (p)-> p.meanBorrowWaitDuration.toMillis() as double) | ||
registry.gauge("jedis.pool.mean.active.millis", pool, (p)-> p.meanActiveDuration.toMillis() as double) | ||
registry.gauge("jedis.pool.mean.idle.millis", pool, (p)-> p.meanIdleDuration.toMillis() as double) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters