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

Add metric when history replication message is too large #6558

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions common/metrics/defs.go
Original file line number Diff line number Diff line change
Expand Up @@ -2523,6 +2523,7 @@ const (
ReplicationDLQProbeFailed
ReplicationDLQSize
ReplicationDLQValidationFailed
ReplicationMessageTooLargePerShard
GetReplicationMessagesForShardLatency
GetDLQReplicationMessagesLatency
EventReapplySkippedCount
Expand Down Expand Up @@ -3217,6 +3218,7 @@ var MetricDefs = map[ServiceIdx]map[int]metricDefinition{
ReplicationDLQProbeFailed: {metricName: "replication_dlq_probe_failed", metricType: Counter},
ReplicationDLQSize: {metricName: "replication_dlq_size", metricType: Gauge},
ReplicationDLQValidationFailed: {metricName: "replication_dlq_validation_failed", metricType: Counter},
ReplicationMessageTooLargePerShard: {metricName: "replication_message_too_large_per_shard", metricType: Counter},
GetReplicationMessagesForShardLatency: {metricName: "get_replication_messages_for_shard", metricType: Timer},
GetDLQReplicationMessagesLatency: {metricName: "get_dlq_replication_messages", metricType: Timer},
EventReapplySkippedCount: {metricName: "event_reapply_skipped_count", metricType: Counter},
Expand Down
5 changes: 4 additions & 1 deletion service/history/handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -1555,7 +1555,7 @@ func (h *handlerImpl) GetReplicationMessages(

h.GetLogger().Debug("Received GetReplicationMessages call.")

_, sw := h.startRequestProfile(ctx, metrics.HistoryGetReplicationMessagesScope)
metricsScope, sw := h.startRequestProfile(ctx, metrics.HistoryGetReplicationMessagesScope)
defer sw.Stop()

if h.isShuttingDown() {
Expand Down Expand Up @@ -1601,6 +1601,9 @@ func (h *handlerImpl) GetReplicationMessages(

size := proto.FromReplicationMessages(tasks).Size()
if (responseSize + size) >= maxResponseSize {
metricsScope.Tagged(metrics.ShardIDTag(int(shardID)))
Copy link
Member

Choose a reason for hiding this comment

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

it would be better to have a gauge metric instead of counter which would have value responseSize + size

Copy link
Member Author

Choose a reason for hiding this comment

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

I thought about that but:

  1. Our purpose was to make an alert that can catch things when there are a lot of "replication message too large" warnings, so I think adding a counter could be a more straightforward way.
  2. The maxResponseSize is not a fixed value, so that it would be harder to find a threshold to trigger the alert.

Copy link
Member

Choose a reason for hiding this comment

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

I see. If we are more interested in the number of occurrences then counter makes sense.

metricsScope.IncCounter(metrics.ReplicationMessageTooLargePerShard)

// Log shards that did not fit for debugging purposes
h.GetLogger().Warn("Replication messages did not fit in the response (history host)",
tag.ShardID(int(shardID)),
Expand Down
Loading