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
2 changes: 1 addition & 1 deletion pkg/cluster/bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func (c *gossipCluster) demoteFromBridge() {

metrics.ClusterBridgeStatus.Set(0)
metrics.ClusterBridgeTransitionsTotal.WithLabelValues("demoted").Inc()
metrics.ClusterMembersCount.WithLabelValues("wan").Set(0)
metrics.ClusterMembersCount.WithLabelValues("wan", c.config.Region).Set(0)

// Leave and shutdown outside the lock since Leave can trigger callbacks
if wan != nil {
Expand Down
4 changes: 2 additions & 2 deletions pkg/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,10 @@ func New(cfg Config) (Cluster, error) {
c.mu.RUnlock()

if lan != nil {
metrics.ClusterMembersCount.WithLabelValues("lan").Set(float64(lan.NumMembers()))
metrics.ClusterMembersCount.WithLabelValues("lan", c.config.Region).Set(float64(lan.NumMembers()))
}
if wan != nil {
metrics.ClusterMembersCount.WithLabelValues("wan").Set(float64(wan.NumMembers()))
metrics.ClusterMembersCount.WithLabelValues("wan", c.config.Region).Set(float64(wan.NumMembers()))
}
})

Expand Down
2 changes: 1 addition & 1 deletion pkg/cluster/delegate_lan.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (d *lanDelegate) NotifyMsg(data []byte) {
if msg.SentAtMs > 0 {
latency := time.Since(time.UnixMilli(msg.SentAtMs)).Seconds()
if latency >= 0 {
metrics.ClusterMessageLatencySeconds.WithLabelValues(direction, msg.SourceRegion).Observe(latency)
metrics.ClusterMessageLatencySeconds.WithLabelValues(direction, msg.SourceRegion, d.cluster.config.Region).Observe(latency)
}
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/cluster/delegate_wan.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func (d *wanDelegate) NotifyMsg(data []byte) {
if msg.SentAtMs > 0 {
latency := time.Since(time.UnixMilli(msg.SentAtMs)).Seconds()
if latency >= 0 {
metrics.ClusterMessageLatencySeconds.WithLabelValues("wan", msg.SourceRegion).Observe(latency)
metrics.ClusterMessageLatencySeconds.WithLabelValues("wan", msg.SourceRegion, d.cluster.config.Region).Observe(latency)
}
}

Expand Down
5 changes: 3 additions & 2 deletions pkg/cluster/metrics/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ var (
Name: "members_count",
Help: "Current number of members in the cluster pool.",
},
[]string{"pool"},
[]string{"pool", "region"},
)

// ClusterBridgeStatus indicates whether this node is currently the bridge (1) or not (0).
Expand Down Expand Up @@ -91,6 +91,7 @@ var (

// ClusterMessageLatencySeconds measures end-to-end transport latency (sent_at_ms to now).
// direction=lan gives intra-region hop time, direction=wan gives full cross-region delivery time.
// source_region is the originating region, destination_region is the receiving region.
ClusterMessageLatencySeconds = promauto.NewHistogramVec(
prometheus.HistogramOpts{
Namespace: "unkey",
Expand All @@ -99,7 +100,7 @@ var (
Help: "End-to-end message transport latency in seconds.",
Buckets: prometheus.DefBuckets,
},
[]string{"direction", "source_region"},
[]string{"direction", "source_region", "destination_region"},
)

// ClusterMessageUnmarshalErrorsTotal counts proto deserialization failures.
Expand Down
Loading