@@ -25,8 +25,7 @@ use mz_ore::instrument;
2525use mz_ore:: metric;
2626use mz_ore:: metrics:: {
2727 ComputedGauge , ComputedIntGauge , ComputedUIntGauge , Counter , DeleteOnDropCounter ,
28- DeleteOnDropGauge , IntCounter , MakeCollector , MetricVecExt , MetricsRegistry , UIntGauge ,
29- UIntGaugeVec , raw,
28+ DeleteOnDropGauge , IntCounter , MakeCollector , MetricsRegistry , UIntGauge , UIntGaugeVec , raw,
3029} ;
3130use mz_ore:: stats:: histogram_seconds_buckets;
3231use mz_persist:: location:: {
@@ -107,6 +106,8 @@ pub struct Metrics {
107106
108107 /// Metrics for the persist sink.
109108 pub sink : SinkMetrics ,
109+ /// Metrics for the persist_source backpressure operator.
110+ pub backpressure : BackpressureMetrics ,
110111
111112 /// Metrics for S3-backed blob implementation
112113 pub s3_blob : S3BlobMetrics ,
@@ -169,6 +170,7 @@ impl Metrics {
169170 inline : InlineMetrics :: new ( registry) ,
170171 semaphore : SemaphoreMetrics :: new ( cfg. clone ( ) , registry. clone ( ) ) ,
171172 sink : SinkMetrics :: new ( registry) ,
173+ backpressure : BackpressureMetrics :: new ( registry) ,
172174 s3_blob,
173175 blob_hedge : BlobHedgeMetrics :: new ( registry) ,
174176 postgres_consensus : PostgresClientMetrics :: new ( registry, "mz_persist" ) ,
@@ -1283,16 +1285,10 @@ pub struct ShardsMetrics {
12831285 usage_referenced_not_current_state_bytes : mz_ore:: metrics:: UIntGaugeVec ,
12841286 usage_not_leaked_not_referenced_bytes : mz_ore:: metrics:: UIntGaugeVec ,
12851287 usage_leaked_bytes : mz_ore:: metrics:: UIntGaugeVec ,
1286- pubsub_push_diff_applied : mz_ore:: metrics:: IntCounterVec ,
1287- pubsub_push_diff_not_applied_stale : mz_ore:: metrics:: IntCounterVec ,
1288- pubsub_push_diff_not_applied_out_of_order : mz_ore:: metrics:: IntCounterVec ,
12891288 stale_version : mz_ore:: metrics:: UIntGaugeVec ,
12901289 blob_gets : mz_ore:: metrics:: IntCounterVec ,
12911290 blob_sets : mz_ore:: metrics:: IntCounterVec ,
12921291 unconsolidated_snapshot : mz_ore:: metrics:: IntCounterVec ,
1293- backpressure_emitted_bytes : IntCounterVec ,
1294- backpressure_last_backpressured_bytes : UIntGaugeVec ,
1295- backpressure_retired_bytes : IntCounterVec ,
12961292 inline_part_count : UIntGaugeVec ,
12971293 inline_part_bytes : UIntGaugeVec ,
12981294 compact_batches : UIntGaugeVec ,
@@ -1441,21 +1437,6 @@ impl ShardsMetrics {
14411437 help: "data reclaimable by a leaked blob detector" ,
14421438 var_labels: [ "shard" , "name" ] ,
14431439 ) ) ,
1444- pubsub_push_diff_applied : registry. register ( metric ! (
1445- name: "mz_persist_shard_pubsub_diff_applied" ,
1446- help: "number of diffs received via pubsub that applied" ,
1447- var_labels: [ "shard" , "name" ] ,
1448- ) ) ,
1449- pubsub_push_diff_not_applied_stale : registry. register ( metric ! (
1450- name: "mz_persist_shard_pubsub_diff_not_applied_stale" ,
1451- help: "number of diffs received via pubsub that did not apply due to staleness" ,
1452- var_labels: [ "shard" , "name" ] ,
1453- ) ) ,
1454- pubsub_push_diff_not_applied_out_of_order : registry. register ( metric ! (
1455- name: "mz_persist_shard_pubsub_diff_not_applied_out_of_order" ,
1456- help: "number of diffs received via pubsub that did not apply due to out-of-order delivery" ,
1457- var_labels: [ "shard" , "name" ] ,
1458- ) ) ,
14591440 stale_version : registry. register ( metric ! (
14601441 name: "mz_persist_shard_stale_version" ,
14611442 help: "indicates whether the current version of the shard is less than the current version of the code" ,
@@ -1476,23 +1457,6 @@ impl ShardsMetrics {
14761457 help: "in snapshot_and_read, the number of times consolidating the raw data wasn't enough to produce consolidated output" ,
14771458 var_labels: [ "shard" , "name" ] ,
14781459 ) ) ,
1479- backpressure_emitted_bytes : registry. register ( metric ! (
1480- name: "mz_persist_backpressure_emitted_bytes" ,
1481- help: "A counter with the number of emitted bytes." ,
1482- var_labels: [ "shard" , "name" ] ,
1483- ) ) ,
1484- backpressure_last_backpressured_bytes : registry. register ( metric ! (
1485- name: "mz_persist_backpressure_last_backpressured_bytes" ,
1486- help: "The last count of bytes we are waiting to be retired in \
1487- the operator. This cannot be directly compared to \
1488- `retired_bytes`, but CAN indicate that backpressure is happening.",
1489- var_labels: [ "shard" , "name" ] ,
1490- ) ) ,
1491- backpressure_retired_bytes : registry. register ( metric ! (
1492- name: "mz_persist_backpressure_retired_bytes" ,
1493- help: "A counter with the number of bytes retired by downstream processing." ,
1494- var_labels: [ "shard" , "name" ] ,
1495- ) ) ,
14961460 inline_part_count : registry. register ( metric ! (
14971461 name: "mz_persist_shard_inline_part_count" ,
14981462 help: "count of parts inline in shard metadata" ,
@@ -1593,16 +1557,10 @@ pub struct ShardMetrics {
15931557 pub gc_finished : DeleteOnDropCounter < AtomicU64 , Vec < String > > ,
15941558 pub compaction_applied : DeleteOnDropCounter < AtomicU64 , Vec < String > > ,
15951559 pub cmd_succeeded : DeleteOnDropCounter < AtomicU64 , Vec < String > > ,
1596- pub pubsub_push_diff_applied : DeleteOnDropCounter < AtomicU64 , Vec < String > > ,
1597- pub pubsub_push_diff_not_applied_stale : DeleteOnDropCounter < AtomicU64 , Vec < String > > ,
1598- pub pubsub_push_diff_not_applied_out_of_order : DeleteOnDropCounter < AtomicU64 , Vec < String > > ,
15991560 pub stale_version : DeleteOnDropGauge < AtomicU64 , Vec < String > > ,
16001561 pub blob_gets : DeleteOnDropCounter < AtomicU64 , Vec < String > > ,
16011562 pub blob_sets : DeleteOnDropCounter < AtomicU64 , Vec < String > > ,
16021563 pub unconsolidated_snapshot : DeleteOnDropCounter < AtomicU64 , Vec < String > > ,
1603- pub backpressure_emitted_bytes : Arc < DeleteOnDropCounter < AtomicU64 , Vec < String > > > ,
1604- pub backpressure_last_backpressured_bytes : Arc < DeleteOnDropGauge < AtomicU64 , Vec < String > > > ,
1605- pub backpressure_retired_bytes : Arc < DeleteOnDropCounter < AtomicU64 , Vec < String > > > ,
16061564 pub inline_part_count : DeleteOnDropGauge < AtomicU64 , Vec < String > > ,
16071565 pub inline_part_bytes : DeleteOnDropGauge < AtomicU64 , Vec < String > > ,
16081566 pub compact_batches : DeleteOnDropGauge < AtomicU64 , Vec < String > > ,
@@ -1686,15 +1644,6 @@ impl ShardMetrics {
16861644 usage_leaked_bytes : shards_metrics
16871645 . usage_leaked_bytes
16881646 . get_delete_on_drop_metric ( vec ! [ shard. clone( ) , name. to_string( ) ] ) ,
1689- pubsub_push_diff_applied : shards_metrics
1690- . pubsub_push_diff_applied
1691- . get_delete_on_drop_metric ( vec ! [ shard. clone( ) , name. to_string( ) ] ) ,
1692- pubsub_push_diff_not_applied_stale : shards_metrics
1693- . pubsub_push_diff_not_applied_stale
1694- . get_delete_on_drop_metric ( vec ! [ shard. clone( ) , name. to_string( ) ] ) ,
1695- pubsub_push_diff_not_applied_out_of_order : shards_metrics
1696- . pubsub_push_diff_not_applied_out_of_order
1697- . get_delete_on_drop_metric ( vec ! [ shard. clone( ) , name. to_string( ) ] ) ,
16981647 stale_version : shards_metrics
16991648 . stale_version
17001649 . get_delete_on_drop_metric ( vec ! [ shard. clone( ) , name. to_string( ) ] ) ,
@@ -1707,21 +1656,6 @@ impl ShardMetrics {
17071656 unconsolidated_snapshot : shards_metrics
17081657 . unconsolidated_snapshot
17091658 . get_delete_on_drop_metric ( vec ! [ shard. clone( ) , name. to_string( ) ] ) ,
1710- backpressure_emitted_bytes : Arc :: new (
1711- shards_metrics
1712- . backpressure_emitted_bytes
1713- . get_delete_on_drop_metric ( vec ! [ shard. clone( ) , name. to_string( ) ] ) ,
1714- ) ,
1715- backpressure_last_backpressured_bytes : Arc :: new (
1716- shards_metrics
1717- . backpressure_last_backpressured_bytes
1718- . get_delete_on_drop_metric ( vec ! [ shard. clone( ) , name. to_string( ) ] ) ,
1719- ) ,
1720- backpressure_retired_bytes : Arc :: new (
1721- shards_metrics
1722- . backpressure_retired_bytes
1723- . get_delete_on_drop_metric ( vec ! [ shard. clone( ) , name. to_string( ) ] ) ,
1724- ) ,
17251659 inline_part_count : shards_metrics
17261660 . inline_part_count
17271661 . get_delete_on_drop_metric ( vec ! [ shard. clone( ) , name. to_string( ) ] ) ,
@@ -2017,6 +1951,43 @@ impl SinkWorkerMetrics {
20171951 }
20181952}
20191953
1954+ /// Metrics for the `persist_source` backpressure operator, summed over every
1955+ /// instance of the operator in the process. Like [SinkMetrics], these belong
1956+ /// to a dataflow operator rather than the client, but the client owns the only
1957+ /// registry the operator can reach.
1958+ #[ derive( Debug ) ]
1959+ pub struct BackpressureMetrics {
1960+ /// Bytes emitted by backpressure operators.
1961+ pub emitted_bytes : IntCounter ,
1962+ /// Sum over live operator instances of the inflight bytes each one most
1963+ /// recently stalled on. Instances contribute deltas, so the sum stays exact
1964+ /// as operators start and stop.
1965+ pub last_backpressured_bytes : UIntGauge ,
1966+ /// Bytes retired by processing downstream of backpressure operators.
1967+ pub retired_bytes : IntCounter ,
1968+ }
1969+
1970+ impl BackpressureMetrics {
1971+ fn new ( registry : & MetricsRegistry ) -> Self {
1972+ BackpressureMetrics {
1973+ emitted_bytes : registry. register ( metric ! (
1974+ name: "mz_persist_backpressure_emitted_bytes" ,
1975+ help: "bytes emitted by backpressure operators" ,
1976+ ) ) ,
1977+ last_backpressured_bytes : registry. register ( metric ! (
1978+ name: "mz_persist_backpressure_last_backpressured_bytes" ,
1979+ help: "sum over backpressure operators of the inflight bytes each last \
1980+ stalled on; not comparable to retired bytes, but nonzero growth \
1981+ indicates backpressure is happening",
1982+ ) ) ,
1983+ retired_bytes : registry. register ( metric ! (
1984+ name: "mz_persist_backpressure_retired_bytes" ,
1985+ help: "bytes retired by processing downstream of backpressure operators" ,
1986+ ) ) ,
1987+ }
1988+ }
1989+ }
1990+
20201991/// A minimal set of metrics imported into honeycomb for alerting.
20211992#[ derive( Debug ) ]
20221993pub struct AlertsMetrics {
@@ -2165,6 +2136,10 @@ pub struct PubSubClientReceiverMetrics {
21652136 pub ( crate ) state_pushed_diff_fast_path : IntCounter ,
21662137 pub ( crate ) state_pushed_diff_slow_path_succeeded : IntCounter ,
21672138 pub ( crate ) state_pushed_diff_slow_path_failed : IntCounter ,
2139+
2140+ pub ( crate ) diff_applied : IntCounter ,
2141+ pub ( crate ) diff_not_applied_stale : IntCounter ,
2142+ pub ( crate ) diff_not_applied_out_of_order : IntCounter ,
21682143}
21692144
21702145impl PubSubClientReceiverMetrics {
@@ -2196,6 +2171,18 @@ impl PubSubClientReceiverMetrics {
21962171 name: "mz_persist_pubsub_client_receiver_state_push_diff_slow_path_failed" ,
21972172 help: "count of unsuccessful slow-path state push_diff calls" ,
21982173 ) ) ,
2174+ diff_applied : registry. register ( metric ! (
2175+ name: "mz_persist_pubsub_client_receiver_diff_applied" ,
2176+ help: "number of diffs received via pubsub that applied" ,
2177+ ) ) ,
2178+ diff_not_applied_stale : registry. register ( metric ! (
2179+ name: "mz_persist_pubsub_client_receiver_diff_not_applied_stale" ,
2180+ help: "number of diffs received via pubsub that did not apply due to staleness" ,
2181+ ) ) ,
2182+ diff_not_applied_out_of_order : registry. register ( metric ! (
2183+ name: "mz_persist_pubsub_client_receiver_diff_not_applied_out_of_order" ,
2184+ help: "number of diffs received via pubsub that did not apply due to out-of-order delivery" ,
2185+ ) ) ,
21992186 }
22002187 }
22012188}
0 commit comments