From 98b23b42d68c30335dd0607e981bd9256a568202 Mon Sep 17 00:00:00 2001 From: Yu Ning <78631860+Chillax-0v0@users.noreply.github.com> Date: Fri, 30 Aug 2024 10:46:05 +0800 Subject: [PATCH] fix(s3stream/wal): record metrics on WAL full (#1968) Signed-off-by: Ning Yu --- .../com/automq/stream/s3/wal/impl/block/BlockWALService.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/s3stream/src/main/java/com/automq/stream/s3/wal/impl/block/BlockWALService.java b/s3stream/src/main/java/com/automq/stream/s3/wal/impl/block/BlockWALService.java index 96d178087a..667f22bf88 100644 --- a/s3stream/src/main/java/com/automq/stream/s3/wal/impl/block/BlockWALService.java +++ b/s3stream/src/main/java/com/automq/stream/s3/wal/impl/block/BlockWALService.java @@ -417,11 +417,15 @@ public WALMetadata metadata() { public AppendResult append(TraceContext context, ByteBuf buf, int crc) throws OverCapacityException { // get current method name TraceContext.Scope scope = TraceUtils.createAndStartSpan(context, "BlockWALService::append"); + final long startTime = System.nanoTime(); try { AppendResult result = append0(buf, crc); result.future().whenComplete((nil, ex) -> TraceUtils.endSpan(scope, ex)); return result; } catch (Throwable t) { + if (t instanceof OverCapacityException) { + StorageOperationStats.getInstance().appendWALFullStats.record(TimerUtil.timeElapsedSince(startTime, TimeUnit.NANOSECONDS)); + } buf.release(); TraceUtils.endSpan(scope, t); throw t;