@@ -37,6 +37,7 @@ use crate::catalog::pending::DegradeReason;
3737use crate :: decode:: heap_decoder:: HEAP_OP_LABELS ;
3838use crate :: ops:: bridge:: { OP_COUNT , OP_LABELS } ;
3939use crate :: pos:: { Drain , EmitterAck , FilterDispatched , Floor , Pos , ShadowReplay , SourceReceived } ;
40+ use crate :: source:: shadow_stream:: SocketEvent ;
4041use crate :: source:: transition:: SWITCH_FAILURE_REASONS ;
4142
4243#[ macro_export]
@@ -98,6 +99,18 @@ macro_rules! label_class {
9899 } ;
99100}
100101
102+ label_class ! {
103+ pub enum WalFlow {
104+ WalsenderBackfill => "walsender_backfill" ,
105+ }
106+ }
107+
108+ label_class ! {
109+ pub enum Buffer {
110+ WalsenderSendQueue => "walsender_send_queue" ,
111+ }
112+ }
113+
101114label_class ! {
102115 pub enum WorkerState {
103116 Busy => "busy" ,
@@ -293,6 +306,11 @@ snapshot! {
293306 /// Failures by [`ErrorKind`], rendered
294307 /// `walshadow_errors_total{component,kind}`
295308 errors: [ u64 ; ErrorKind :: COUNT ] ,
309+ /// Postgres data moved, by [`WalFlow`], rendered
310+ /// `walshadow_wal_bytes_total{flow}`
311+ wal_bytes: [ u64 ; WalFlow :: COUNT ] ,
312+ /// Data held, by [`Buffer`], rendered `walshadow_buffer_bytes{buffer}`
313+ buffer_bytes: [ u64 ; Buffer :: COUNT ] ,
296314 /// Refusal a crossing parked on, rendered as `crossing_wedged`. The
297315 /// pump keeps publishing rather than exiting into a restart that
298316 /// re-crosses and re-fails, so this is how the daemon says it is
@@ -598,9 +616,9 @@ snapshot! {
598616 "Estimated seconds shadow trails source, by source byte rate over last 30s." ,
599617 gauge shadow_stream_active_connections: u64 =
600618 "Currently-attached walreceiver connections to walshadow's walsender." ,
601- /// Cumulative connections dropped by `slow_threshold` overflow
602- counter shadow_stream_dropped_connections_total : u64 =
603- "Connections dropped by slow-client cutoff since daemon start ." ,
619+ counter shadow_stream_sockets_by_event : [ u64 ; SocketEvent :: COUNT ]
620+ [ "event" = SocketEvent :: LABELS ] =
621+ "Walsender socket lifecycle events: accepted (entered the handshake, START_REPLICATION or not), closed_slow_client ( dropped at the send queue cap), closed_by_client (clean hangup), closed_error (handshake, I/O, protocol failure or refused START_REPLICATION). accepted minus the closed events is sockets alive ." ,
604622 counter catalog_boundary_holds_total: u64 =
605623 "Publication holds released at catalog-mutating commit boundaries." ,
606624 counter catalog_boundary_hold_failures_total: u64 =
@@ -1102,6 +1120,26 @@ fn encode_snapshot(snap: &MetricsSnapshot, enc: &mut DescriptorEncoder<'_>) -> f
11021120 . map ( |e| ( e. pair ( ) , snap. errors [ e. index ( ) ] ) ) ,
11031121 ) ?;
11041122
1123+ counter_series (
1124+ enc,
1125+ "walshadow_wal_bytes_total" ,
1126+ "Postgres data moved, by flow. walsender_backfill is WAL replayed from the retained wire buffer to a reconnecting shadow walreceiver." ,
1127+ "flow" ,
1128+ WalFlow :: ALL
1129+ . into_iter ( )
1130+ . map ( |f| ( f. label ( ) , snap. wal_bytes [ f. index ( ) ] ) ) ,
1131+ ) ?;
1132+
1133+ gauge_series (
1134+ enc,
1135+ "walshadow_buffer_bytes" ,
1136+ "Data held right now, by buffer. walsender_send_queue is the largest unsent walsender queue across connections, read against the slow-client cap." ,
1137+ "buffer" ,
1138+ Buffer :: ALL
1139+ . into_iter ( )
1140+ . map ( |b| ( b. label ( ) , snap. buffer_bytes [ b. index ( ) ] ) ) ,
1141+ ) ?;
1142+
11051143 counter_pairs (
11061144 enc,
11071145 "walshadow_worker_seconds_total" ,
@@ -1622,7 +1660,9 @@ mod tests {
16221660 shadow_apply_lag_bytes : 12345 ,
16231661 shadow_apply_lag_seconds : 1.23456 ,
16241662 shadow_stream_active_connections : 2 ,
1625- shadow_stream_dropped_connections_total : 5 ,
1663+ shadow_stream_sockets_by_event : [ 9 , 5 , 3 , 1 ] ,
1664+ wal_bytes : [ 4096 ] ,
1665+ buffer_bytes : [ 777 ] ,
16261666 ..MetricsSnapshot :: default ( )
16271667 } ;
16281668 let body = render ( snap) ;
@@ -1635,9 +1675,19 @@ mod tests {
16351675 assert ! ( body. contains( "# HELP walshadow_shadow_stream_active_connections" ) ) ;
16361676 assert ! ( body. contains( "# TYPE walshadow_shadow_stream_active_connections gauge" ) ) ;
16371677 assert ! ( body. contains( "walshadow_shadow_stream_active_connections 2" ) ) ;
1638- assert ! ( body. contains( "# HELP walshadow_shadow_stream_dropped_connections" ) ) ;
1639- assert ! ( body. contains( "# TYPE walshadow_shadow_stream_dropped_connections counter" ) ) ;
1640- assert ! ( body. contains( "walshadow_shadow_stream_dropped_connections_total 5" ) ) ;
1678+ assert ! ( body. contains( "# TYPE walshadow_shadow_stream_sockets counter" ) ) ;
1679+ assert ! ( body. contains( "walshadow_shadow_stream_sockets_total{event=\" accepted\" } 9" ) ) ;
1680+ assert ! (
1681+ body. contains( "walshadow_shadow_stream_sockets_total{event=\" closed_slow_client\" } 5" )
1682+ ) ;
1683+ assert ! (
1684+ body. contains( "walshadow_shadow_stream_sockets_total{event=\" closed_by_client\" } 3" )
1685+ ) ;
1686+ assert ! ( body. contains( "walshadow_shadow_stream_sockets_total{event=\" closed_error\" } 1" ) ) ;
1687+ assert ! ( body. contains( "# TYPE walshadow_wal_bytes counter" ) ) ;
1688+ assert ! ( body. contains( "walshadow_wal_bytes_total{flow=\" walsender_backfill\" } 4096" ) ) ;
1689+ assert ! ( body. contains( "# TYPE walshadow_buffer_bytes gauge" ) ) ;
1690+ assert ! ( body. contains( "walshadow_buffer_bytes{buffer=\" walsender_send_queue\" } 777" ) ) ;
16411691 }
16421692
16431693 /// Unknown rate stays infinite on the wire. prometheus-client spells it
0 commit comments