risingwave_stream/common/
metrics.rs

1// Copyright 2025 RisingWave Labs
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15use std::sync::Arc;
16
17use risingwave_common::id::TableId;
18
19use crate::executor::monitor::StreamingMetrics;
20use crate::task::ActorId;
21
22#[derive(Clone)]
23pub struct MetricsInfo {
24    pub metrics: Arc<StreamingMetrics>,
25    pub table_id: String,
26    pub actor_id: String,
27    pub desc: String,
28}
29
30impl MetricsInfo {
31    pub fn new(
32        metrics: Arc<StreamingMetrics>,
33        table_id: TableId,
34        actor_id: ActorId,
35        desc: impl Into<String>,
36    ) -> Self {
37        Self {
38            metrics,
39            table_id: table_id.to_string(),
40            actor_id: actor_id.to_string(),
41            desc: desc.into(),
42        }
43    }
44
45    pub fn for_test() -> Self {
46        Self {
47            metrics: Arc::new(StreamingMetrics::unused()),
48            table_id: "table_id test".to_owned(),
49            actor_id: "actor_id test".to_owned(),
50            desc: "desc test".to_owned(),
51        }
52    }
53}