Skip to content
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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

bradbown
Copy link
Contributor

@bradbown bradbown commented Oct 29, 2024

This PR implements issue(s) #
Adds:

  • Add metrics to capture the time to compress data (time spent in method GoBackedBlobCompressor canAppendBlock and appendBlock)
  • Add metrics to capture the time to perform shnarf calculation (time spent in GoBackedBlobShnarfCalculator calculateShnarf)

Checklist

  • I wrote new tests for my new core changes.
  • I have successfully ran tests, style checker and build against my new changes locally.
  • I have informed the team of any breaking changes if there are any.

@bradbown bradbown temporarily deployed to docker-build-and-e2e October 29, 2024 13:52 — with GitHub Actions Inactive
@codecov-commenter
Copy link

codecov-commenter commented Oct 29, 2024

Codecov Report

Attention: Patch coverage is 92.98246% with 4 lines in your changes missing coverage. Please review.

Project coverage is 71.35%. Comparing base (2f37b73) to head (e8c9bdc).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
.../consensys/zkevm/coordinator/app/CoordinatorApp.kt 0.00% 2 Missing ⚠️
.../consensys/zkevm/coordinator/app/L1DependentApp.kt 0.00% 2 Missing ⚠️
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     
Flag Coverage Δ *Carryforward flag
hardhat 98.67% <ø> (ø) Carriedforward from 712d2d5
kotlin 69.18% <92.98%> (-0.16%) ⬇️

*This pull request uses carry forward flags. Click here to find out more.

Files with missing lines Coverage Δ
...zkevm/ethereum/coordination/blob/BlobCompressor.kt 90.36% <100.00%> (+1.32%) ⬆️
...consensys/linea/jsonrpc/JsonRpcMessageProcessor.kt 90.27% <100.00%> (+0.06%) ⬆️
...sys/linea/jsonrpc/client/VertxHttpJsonRpcClient.kt 97.22% <100.00%> (ø)
...ea/jsonrpc/client/VertxHttpJsonRpcClientFactory.kt 73.42% <100.00%> (ø)
...otlin/net/consensys/linea/metrics/MetricsFacade.kt 87.50% <100.00%> (-12.50%) ⬇️
...inea/metrics/micrometer/MicrometerMetricsFacade.kt 92.98% <100.00%> (-0.13%) ⬇️
...sys/linea/metrics/micrometer/SimpleTimerCapture.kt 100.00% <ø> (+5.88%) ⬆️
.../consensys/zkevm/coordinator/app/CoordinatorApp.kt 0.00% <0.00%> (ø)
.../consensys/zkevm/coordinator/app/L1DependentApp.kt 1.45% <0.00%> (-0.14%) ⬇️

... and 12 files with indirect coverage changes

@bradbown bradbown temporarily deployed to docker-build-and-e2e October 29, 2024 15:37 — with GitHub Actions Inactive
@bradbown bradbown requested a review from a team October 29, 2024 15:43
@@ -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
Copy link
Collaborator

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,
Copy link
Collaborator

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 }
Copy link
Collaborator

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 {
Copy link
Collaborator

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")
Copy link
Collaborator

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",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
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"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
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",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
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"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
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",
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants