Skip to content

Commit 8e0b8fa

Browse files
committed
feat: add candlestick for monitor tx latency
1 parent ab330f1 commit 8e0b8fa

File tree

3 files changed

+25
-10
lines changed

3 files changed

+25
-10
lines changed

metrics/exports.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,15 @@ var (
1919
ProbesSentCount otelapi.Int64Counter
2020
ProbesFailedCount otelapi.Int64Counter
2121
ProbesLandedCount otelapi.Int64Counter
22-
ProbesLatency otelapi.Int64Histogram
23-
24-
TxPerBlock_Old otelapi.Int64Histogram
25-
GasPerBlock_Old otelapi.Int64Histogram
26-
GasPrice_Old otelapi.Int64Histogram
22+
ProbesLatency *Int64Candlestick
2723

2824
TxPerBlock *Int64Candlestick
2925
GasPerBlock *Int64Candlestick
3026
GasPrice *Int64Candlestick
27+
28+
// TODO: get rid of this
29+
ProbesLatency_Old otelapi.Int64Histogram
30+
TxPerBlock_Old otelapi.Int64Histogram
31+
GasPerBlock_Old otelapi.Int64Histogram
32+
GasPrice_Old otelapi.Int64Histogram
3133
)

metrics/metrics.go

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -191,15 +191,27 @@ func setupProbesLanded(ctx context.Context, _ *config.Monitor) error {
191191
}
192192

193193
func setupProbesLatency(ctx context.Context, _ *config.Monitor) error {
194-
m, err := meter.Int64Histogram("probes_latency",
195-
otelapi.WithDescription("latency of landed probe transactions"),
196-
otelapi.WithUnit("s"),
197-
otelapi.WithExplicitBucketBoundaries(0, 1, 4, 16, 64, 256),
198-
)
194+
{ // TODO: remove in the future
195+
m, err := meter.Int64Histogram("probes_latency",
196+
otelapi.WithDescription("latency of landed probe transactions"),
197+
otelapi.WithUnit("s"),
198+
otelapi.WithExplicitBucketBoundaries(0, 1, 4, 16, 64, 256),
199+
)
200+
if err != nil {
201+
return err
202+
}
203+
ProbesLatency_Old = m
204+
}
205+
206+
m, err := NewInt64Candlestick("probes_latency_ohlc", "latency of landed probe transactions", "s")
199207
if err != nil {
200208
return err
201209
}
210+
if _, err := m.registerCallback(meter); err != nil {
211+
return err
212+
}
202213
ProbesLatency = m
214+
203215
return nil
204216
}
205217

server/l2.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,7 @@ func (l2 *L2) processBlock(ctx context.Context, blockNumber uint64) error {
372372
zap.Uint64("landed", block.Time()),
373373
)
374374
metrics.ProbesLatency.Record(ctx, int64(latency))
375+
metrics.ProbesLatency_Old.Record(ctx, int64(latency))
375376
}
376377
}
377378

0 commit comments

Comments
 (0)