added metrics + fix code style
This commit is contained in:
@@ -15,14 +15,10 @@
|
|||||||
*/
|
*/
|
||||||
package io.emeraldpay.dshackle.upstream
|
package io.emeraldpay.dshackle.upstream
|
||||||
|
|
||||||
import io.emeraldpay.dshackle.Global
|
|
||||||
import io.emeraldpay.dshackle.data.BlockContainer
|
import io.emeraldpay.dshackle.data.BlockContainer
|
||||||
import io.emeraldpay.dshackle.upstream.forkchoice.ForkChoice
|
import io.emeraldpay.dshackle.upstream.forkchoice.ForkChoice
|
||||||
import io.micrometer.core.instrument.Counter
|
|
||||||
import io.micrometer.core.instrument.Gauge
|
import io.micrometer.core.instrument.Gauge
|
||||||
import io.micrometer.core.instrument.Meter
|
|
||||||
import io.micrometer.core.instrument.Metrics
|
import io.micrometer.core.instrument.Metrics
|
||||||
import io.micrometer.core.instrument.Tag
|
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
import reactor.core.Disposable
|
import reactor.core.Disposable
|
||||||
import reactor.core.publisher.Flux
|
import reactor.core.publisher.Flux
|
||||||
@@ -55,16 +51,14 @@ abstract class AbstractHead @JvmOverloads constructor(
|
|||||||
private var lastHeadUpdated = 0L
|
private var lastHeadUpdated = 0L
|
||||||
private val lock = ReentrantLock()
|
private val lock = ReentrantLock()
|
||||||
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
val state = AtomicBoolean(false)
|
val state = AtomicBoolean(false)
|
||||||
Gauge.builder("stuck_head", state) {
|
Gauge.builder("stuck_head", state) {
|
||||||
if (it.get()) 1.0 else 0.0
|
if (it.get()) 1.0 else 0.0
|
||||||
}
|
}.tag("upstream", upstreamId).tag("class", this.javaClass.simpleName).register(Metrics.globalRegistry)
|
||||||
.tag("upstream", upstreamId)
|
Gauge.builder("current_head", forkChoice) {
|
||||||
.tag("class", this.javaClass.simpleName)
|
it.getHead()?.height?.toDouble() ?: 0.0
|
||||||
.register(Metrics.globalRegistry)
|
}.tag("upstream", upstreamId).tag("class", this.javaClass.simpleName).register(Metrics.globalRegistry)
|
||||||
|
|
||||||
Executors.newSingleThreadScheduledExecutor().scheduleAtFixedRate(
|
Executors.newSingleThreadScheduledExecutor().scheduleAtFixedRate(
|
||||||
{
|
{
|
||||||
val delay = System.currentTimeMillis() - lastHeadUpdated
|
val delay = System.currentTimeMillis() - lastHeadUpdated
|
||||||
|
|||||||
@@ -39,13 +39,10 @@ import reactor.core.publisher.Flux
|
|||||||
import reactor.core.publisher.Mono
|
import reactor.core.publisher.Mono
|
||||||
import java.time.Duration
|
import java.time.Duration
|
||||||
import java.time.Instant
|
import java.time.Instant
|
||||||
import java.util.*
|
import java.util.Locale
|
||||||
import java.util.concurrent.atomic.AtomicReference
|
import java.util.concurrent.atomic.AtomicReference
|
||||||
import java.util.concurrent.locks.ReentrantLock
|
import java.util.concurrent.locks.ReentrantLock
|
||||||
import java.util.function.Predicate
|
import java.util.function.Predicate
|
||||||
import kotlin.collections.ArrayList
|
|
||||||
import kotlin.collections.HashMap
|
|
||||||
import kotlin.collections.HashSet
|
|
||||||
import kotlin.concurrent.withLock
|
import kotlin.concurrent.withLock
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -150,7 +147,6 @@ abstract class Multistream(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a source for direct APIs
|
* Get a source for direct APIs
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user