Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 4 additions & 0 deletions common/metrics/defs.go
Original file line number Diff line number Diff line change
Expand Up @@ -2930,6 +2930,8 @@ const (
ShardDistributorAssignLoopSuccess
ShardDistributorAssignLoopFail

ShardDistributorActiveShards

ShardDistributorStoreExecutorNotFound
ShardDistributorStoreFailuresPerNamespace
ShardDistributorStoreRequestsPerNamespace
Expand Down Expand Up @@ -3702,6 +3704,8 @@ var MetricDefs = map[ServiceIdx]map[MetricIdx]metricDefinition{
ShardDistributorAssignLoopSuccess: {metricName: "shard_distrubutor_shard_assign_success", metricType: Counter},
ShardDistributorAssignLoopFail: {metricName: "shard_distrubutor_shard_assign_fail", metricType: Counter},

ShardDistributorActiveShards: {metricName: "shard_distributor_active_shards", metricType: Gauge},

ShardDistributorStoreExecutorNotFound: {metricName: "shard_distributor_store_executor_not_found", metricType: Counter},
ShardDistributorStoreFailuresPerNamespace: {metricName: "shard_distributor_store_failures_per_namespace", metricType: Counter},
ShardDistributorStoreRequestsPerNamespace: {metricName: "shard_distributor_store_requests_per_namespace", metricType: Counter},
Expand Down
4 changes: 4 additions & 0 deletions common/metrics/tags.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,10 @@ func NamespaceTag(namespace string) Tag {
return metricWithUnknown("namespace", namespace)
}

func NamespaceTypeTag(namespaceType string) Tag {
return metricWithUnknown("namespace_type", namespaceType)
}

func TaskCategoryTag(category string) Tag {
return metricWithUnknown("task_category", category)
}
Expand Down
9 changes: 9 additions & 0 deletions service/sharddistributor/leader/process/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,15 @@ func (p *namespaceProcessor) rebalanceShardsImpl(ctx context.Context, metricsLoo
return fmt.Errorf("assign shards: %w", err)
}

totalActiveShards := 0
for _, assignedState := range namespaceState.ShardAssignments {
totalActiveShards += len(assignedState.AssignedShards)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

As discussed offline, this is the best metric we can extract from the rebalance loop.
We can consider to emit metrics per executor in the heartbeat function.

metricsLoopScope.Tagged(
metrics.NamespaceTag(p.namespaceCfg.Name),
metrics.NamespaceTypeTag(p.namespaceCfg.Type),
).UpdateGauge(metrics.ShardDistributorActiveShards, float64(totalActiveShards))

return nil
}

Expand Down
Loading