-
Notifications
You must be signed in to change notification settings - Fork 16
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
Extend MetricsFacade with createSimpleTimer() factory #265
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #265 +/- ##
============================================
- Coverage 71.53% 71.35% -0.19%
- Complexity 1085 1098 +13
============================================
Files 299 301 +2
Lines 12148 12343 +195
Branches 1084 1103 +19
============================================
+ Hits 8690 8807 +117
- Misses 2968 3043 +75
- Partials 490 493 +3
*This pull request uses carry forward flags. Click here to find out more.
|
@@ -27,6 +29,11 @@ interface Histogram { | |||
fun record(data: Double) | |||
} | |||
|
|||
interface TimerCapture<T> { | |||
fun captureTime(f: CompletableFuture<T>): CompletableFuture<T> | |||
fun captureTime(f: Callable<T>): T |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: call it action
@@ -50,4 +57,10 @@ interface MetricsFacade { | |||
tags: List<Tag> = emptyList(), | |||
baseUnit: String | |||
): Histogram | |||
|
|||
fun <T> createSimpleTimer( | |||
name: String, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why doesn't this have a category?
Tag("endpoint", endpoint.host), | ||
Tag("method", request.method) | ||
) | ||
).captureTime { requestFuture } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why a lambda instead of just passing the function reference?
Every unnecessary lamba is extra memory consumption
import java.util.function.Supplier | ||
import io.micrometer.core.instrument.Counter as MicrometerCounter | ||
import io.micrometer.core.instrument.Timer as MicrometerTimer | ||
|
||
class MicrometerMetricsFacade(private val registry: MeterRegistry, private val metricsPrefix: String) : MetricsFacade { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am ware that it's part of your PR, but maybe we should make metricsPrefix
and optional field and add only when defined.
@@ -57,9 +57,10 @@ class CoordinatorApp(private val configs: CoordinatorConfig) { | |||
Vertx.vertx(vertxConfig) | |||
} | |||
private val meterRegistry: MeterRegistry = BackendRegistries.getDefaultNow() | |||
private val micrometerMetricsFacade = MicrometerMetricsFacade(meterRegistry, "linea") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use named arguments.
Why linea
and not linea.coordinator
or just empty?
@@ -69,29 +73,43 @@ class GoBackedBlobCompressor private constructor( | |||
} | |||
} | |||
|
|||
private val canAppendBlockTimer: TimerCapture<Boolean> = metricsFacade.createSimpleTimer( | |||
name = "go.backed.blob.compressor.can.append.block", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
name = "go.backed.blob.compressor.can.append.block", | |
name = "blob.compressor.canappendblock", |
@@ -69,29 +73,43 @@ class GoBackedBlobCompressor private constructor( | |||
} | |||
} | |||
|
|||
private val canAppendBlockTimer: TimerCapture<Boolean> = metricsFacade.createSimpleTimer( | |||
name = "go.backed.blob.compressor.can.append.block", | |||
description = "Time taken to run CanWrite method" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
description = "Time taken to run CanWrite method" | |
description = "Time taken to check if block fits in current blob or shall be moved to new one" |
description = "Time taken to run CanWrite method" | ||
) | ||
private val appendBlockTimer: TimerCapture<BlobCompressor.AppendResult> = metricsFacade.createSimpleTimer( | ||
name = "go.backed.blob.compressor.append.block", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
name = "go.backed.blob.compressor.append.block", | |
name = "blob.compressor.apppendblock", |
) | ||
private val appendBlockTimer: TimerCapture<BlobCompressor.AppendResult> = metricsFacade.createSimpleTimer( | ||
name = "go.backed.blob.compressor.append.block", | ||
description = "Time taken to run AppendResult method" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
description = "Time taken to run AppendResult method" | |
description = "Time taken to compress block into the blob" |
@@ -352,7 +356,7 @@ class VertxHttpJsonRpcClientTest { | |||
|
|||
val timer = | |||
meterRegistry.timer( | |||
"jsonrpc.request", | |||
"linea.jsonrpc.request", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the value of linea
prefix here? This JSON rpc client is agnostic an could be used outside linea apps. Furthermore, adding the prefix now is a breaking change, so all the dashboards using this will break.
We need to carefully access these changes.
IIRC, The metrics are already under a component/cluster which shall provide enough scope, I don't see the need for linea
here.
This PR implements issue(s) #
Adds:
Checklist