Skip to content

Commit

Permalink
[Enhancement]Added a metric for geo replication for tracking replicat…
Browse files Browse the repository at this point in the history
…ed subscriptions snapshot timeouts (#22381)

Co-authored-by: Lari Hotari <lhotari@apache.org>
  • Loading branch information
nikam14 and lhotari authored Oct 10, 2024
1 parent b334c4f commit 667904c
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import static org.apache.pulsar.common.util.Runnables.catchingAndLoggingThrowables;
import io.netty.buffer.ByteBuf;
import io.prometheus.client.Counter;
import io.prometheus.client.Gauge;
import java.io.IOException;
import java.time.Clock;
Expand Down Expand Up @@ -80,6 +81,14 @@ public class ReplicatedSubscriptionsController implements AutoCloseable, Topic.P
"Counter of currently pending snapshots")
.register();

// timeouts use SnapshotOperationResult.TIMEOUT.attributes on the same metric
@PulsarDeprecatedMetric(
newMetricName = OpenTelemetryReplicatedSubscriptionStats.SNAPSHOT_OPERATION_COUNT_METRIC_NAME)
@Deprecated
private static final Counter timedoutSnapshotsMetric = Counter
.build().name("pulsar_replicated_subscriptions_timedout_snapshots")
.help("Counter of timed out snapshots").register();

private final OpenTelemetryReplicatedSubscriptionStats stats;

public ReplicatedSubscriptionsController(PersistentTopic topic, String localCluster) {
Expand Down Expand Up @@ -263,6 +272,7 @@ private void cleanupTimedOutSnapshots() {
}

pendingSnapshotsMetric.dec();
timedoutSnapshotsMetric.inc();
var latencyMillis = entry.getValue().getDurationMillis();
stats.recordSnapshotTimedOut(latencyMillis);
it.remove();
Expand Down

0 comments on commit 667904c

Please sign in to comment.