Skip to content
Open
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
12 changes: 12 additions & 0 deletions common/metrics/defs.go
Original file line number Diff line number Diff line change
Expand Up @@ -1479,6 +1479,7 @@ const (
ShardDistributorStoreAssignShardScope
ShardDistributorStoreAssignShardsScope
ShardDistributorStoreDeleteExecutorsScope
ShardDistributorStoreGetShardStatsScope
ShardDistributorStoreDeleteShardStatsScope
ShardDistributorStoreGetHeartbeatScope
ShardDistributorStoreGetStateScope
Expand Down Expand Up @@ -2167,6 +2168,7 @@ var ScopeDefs = map[ServiceIdx]map[ScopeIdx]scopeDefinition{
ShardDistributorStoreAssignShardScope: {operation: "StoreAssignShard"},
ShardDistributorStoreAssignShardsScope: {operation: "StoreAssignShards"},
ShardDistributorStoreDeleteExecutorsScope: {operation: "StoreDeleteExecutors"},
ShardDistributorStoreGetShardStatsScope: {operation: "StoreGetShardStats"},
ShardDistributorStoreDeleteShardStatsScope: {operation: "StoreDeleteShardStats"},
ShardDistributorStoreGetHeartbeatScope: {operation: "StoreGetHeartbeat"},
ShardDistributorStoreGetStateScope: {operation: "StoreGetState"},
Expand Down Expand Up @@ -2968,6 +2970,13 @@ const (
ShardDistributorStoreRequestsPerNamespace
ShardDistributorStoreLatencyHistogramPerNamespace

// ShardDistributorShardAssignmentDistributionLatency measures the time taken between assignment of a shard
// and the time it is fully distributed to executors
ShardDistributorShardAssignmentDistributionLatency

// ShardDistributorShardHandoverLatency measures the time taken to hand over a shard from one executor to another
ShardDistributorShardHandoverLatency

NumShardDistributorMetrics
)

Expand Down Expand Up @@ -3753,6 +3762,9 @@ var MetricDefs = map[ServiceIdx]map[MetricIdx]metricDefinition{
ShardDistributorStoreFailuresPerNamespace: {metricName: "shard_distributor_store_failures_per_namespace", metricType: Counter},
ShardDistributorStoreRequestsPerNamespace: {metricName: "shard_distributor_store_requests_per_namespace", metricType: Counter},
ShardDistributorStoreLatencyHistogramPerNamespace: {metricName: "shard_distributor_store_latency_histogram_per_namespace", metricType: Histogram, buckets: ShardDistributorExecutorStoreLatencyBuckets},

ShardDistributorShardAssignmentDistributionLatency: {metricName: "shard_distributor_shard_assignment_distribution_latency", metricType: Histogram, buckets: Default1ms100s.buckets()},
ShardDistributorShardHandoverLatency: {metricName: "shard_distributor_shard_handover_latency", metricType: Histogram, buckets: Default1ms100s.buckets()},
},
}

Expand Down
4 changes: 4 additions & 0 deletions common/metrics/tags.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,10 @@ func NamespaceTypeTag(namespaceType string) Tag {
return metricWithUnknown("namespace_type", namespaceType)
}

func HandoverTypeTag(handoverType string) Tag {
return metricWithUnknown("handover_type", handoverType)
}

func TaskCategoryTag(category string) Tag {
return metricWithUnknown("task_category", category)
}
Expand Down
6 changes: 6 additions & 0 deletions common/ptr/ptr.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package ptr

// ToPtr returns a pointer to the given value.
func ToPtr[T any](v T) *T {
return &v
}
30 changes: 28 additions & 2 deletions common/types/sharddistributor.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@

package types

import "fmt"
import (
"fmt"
)

//go:generate enumer -type=ExecutorStatus,ShardStatus,AssignmentStatus,MigrationMode -trimprefix=ExecutorStatus,ShardStatus,AssignmentStatus,MigrationMode -json -output sharddistributor_statuses_enumer_generated.go
//go:generate enumer -type=ExecutorStatus,ShardStatus,AssignmentStatus,MigrationMode,HandoverType -trimprefix=ExecutorStatus,ShardStatus,AssignmentStatus,MigrationMode,HandoverType -json -output sharddistributor_statuses_enumer_generated.go

type GetShardOwnerRequest struct {
ShardKey string
Expand Down Expand Up @@ -217,6 +219,30 @@ const (
AssignmentStatusREADY AssignmentStatus = 1
)

// HandoverType is used to indicate the type of handover that occurred during shard reassignment.
// Type is persisted to the DB with a string value mapping.
// Beware - if we want to change the name - it should be backward compatible and should be done in two steps.
type HandoverType int32

const (
HandoverTypeINVALID HandoverType = 0

// HandoverTypeGRACEFUL
// Graceful handover indicates that the shard was transferred in a way that allowed
// the previous owner had a chance to finish processing before the shard was reassigned.
HandoverTypeGRACEFUL HandoverType = 1

// HandoverTypeEMERGENCY
// Emergency handover indicates that the shard was transferred abruptly without
// allowing the previous owner to finish processing.
HandoverTypeEMERGENCY HandoverType = 2
)

// Ptr returns a pointer to the HandoverType value.
func (t HandoverType) Ptr() *HandoverType {
return &t
}

type MigrationMode int32

const (
Expand Down
93 changes: 92 additions & 1 deletion common/types/sharddistributor_statuses_enumer_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading