|
| 1 | +// Copyright (c) 2023 - 2026 Restate Software, Inc., Restate GmbH. |
| 2 | +// All rights reserved. |
| 3 | +// |
| 4 | +// Use of this software is governed by the Business Source License |
| 5 | +// included in the LICENSE file. |
| 6 | +// |
| 7 | +// As of the Change Date specified in that file, in accordance with |
| 8 | +// the Business Source License, use of this software will be governed |
| 9 | +// by the Apache License, Version 2.0. |
| 10 | + |
| 11 | +use crate::table_macro::*; |
| 12 | + |
| 13 | +use datafusion::arrow::datatypes::DataType; |
| 14 | + |
| 15 | +define_sort_order!(sys_vqueue_stats(partition_key, scope, lock_name)); |
| 16 | + |
| 17 | +define_table!(sys_vqueue_stats( |
| 18 | + /// Internal column that is used for partitioning. Can be ignored. |
| 19 | + partition_key: DataType::UInt64, |
| 20 | + |
| 21 | + /// The VQueue Identifier (vq_...) |
| 22 | + id: DataType::LargeUtf8, |
| 23 | + |
| 24 | + /// Whether this vqueue is active or not. An active vqueue |
| 25 | + /// is a vqueue that is not paused, and has non-finished |
| 26 | + /// items. |
| 27 | + is_active: DataType::Boolean, |
| 28 | + |
| 29 | + /// Whether this vqueue is paused. |
| 30 | + queue_is_paused: DataType::Boolean, |
| 31 | + |
| 32 | + /// Service name linked to this vqueue |
| 33 | + service_name: DataType::LargeUtf8, |
| 34 | + |
| 35 | + /// The scope of this vqueue. |
| 36 | + scope: DataType::LargeUtf8, |
| 37 | + |
| 38 | + /// The name of the limit-key assigned to this vqueue |
| 39 | + limit_key: DataType::LargeUtf8, |
| 40 | + |
| 41 | + /// The name of the lock (in the format of `service/key`) |
| 42 | + /// |
| 43 | + /// This is only set if this is a vqueue for a virtual object. |
| 44 | + lock_name: DataType::LargeUtf8, |
| 45 | + |
| 46 | + /// When was this vqueue first created |
| 47 | + created_at: TimestampMillisecond, |
| 48 | + |
| 49 | + /// Last timestamp an entry moved into Inbox. |
| 50 | + /// |
| 51 | + /// This covers items enqueued for the first time only. |
| 52 | + last_enqueued_at: TimestampMillisecond, |
| 53 | + |
| 54 | + /// Last timestamp an entry first transitioned to Run. |
| 55 | + last_start_at: TimestampMillisecond, |
| 56 | + |
| 57 | + /// Last timestamp an entry transitioned to Run. |
| 58 | + last_attempt_at: TimestampMillisecond, |
| 59 | + |
| 60 | + /// Last timestamp an entry transitioned to Finished. |
| 61 | + last_finish_at: TimestampMillisecond, |
| 62 | + |
| 63 | + /// Exponential moving average (EMA) of first-attempt queue wait time. |
| 64 | + avg_queue_duration: DataType::Duration, |
| 65 | + |
| 66 | + /// Exponential moving average (EMA) of how long entries stayed in inbox. |
| 67 | + avg_inbox_duration: DataType::Duration, |
| 68 | + |
| 69 | + /// Exponential moving average (EMA) of how long entries stayed running. |
| 70 | + avg_run_duration: DataType::Duration, |
| 71 | + |
| 72 | + /// Exponential moving average (EMA) of how long entries stayed suspended. |
| 73 | + avg_suspension_duration: DataType::Duration, |
| 74 | + |
| 75 | + /// Exponential moving average (EMA) of end-to-end entry lifetime from first-runnable time to completion. |
| 76 | + /// Note that this only tracks entries that were not killed/cancelled or failed/paused. |
| 77 | + avg_end_to_end_duration: DataType::Duration, |
| 78 | + |
| 79 | + /// The number of entries that are in the inbox. The inbox is the priority |
| 80 | + /// queue that the scheduler uses to choose which entries to run next. |
| 81 | + num_inbox: DataType::UInt64, |
| 82 | + |
| 83 | + /// The number of entries that are currently running. |
| 84 | + num_running: DataType::UInt64, |
| 85 | + |
| 86 | + /// The number of entries that are suspended. |
| 87 | + num_suspended: DataType::UInt64, |
| 88 | + |
| 89 | + /// The number of entries that are paused. |
| 90 | + num_paused: DataType::UInt64, |
| 91 | + |
| 92 | + /// The number of entries that have finished processing and are pending |
| 93 | + /// deletion or archival. |
| 94 | + num_finished: DataType::UInt64, |
| 95 | + |
| 96 | +)); |
0 commit comments