vector/api/schema/metrics/source/
generic.rs

1use async_graphql::Object;
2
3use crate::{
4    api::schema::metrics::{self, MetricsFilter},
5    event::Metric,
6};
7
8#[derive(Debug, Clone)]
9pub struct GenericSourceMetrics(Vec<Metric>);
10
11impl GenericSourceMetrics {
12    pub const fn new(metrics: Vec<Metric>) -> Self {
13        Self(metrics)
14    }
15}
16
17#[Object]
18impl GenericSourceMetrics {
19    /// Total received bytes for the current source
20    pub async fn received_bytes_total(&self) -> Option<metrics::ReceivedBytesTotal> {
21        self.0.received_bytes_total()
22    }
23
24    /// Total received events for the current source
25    pub async fn received_events_total(&self) -> Option<metrics::ReceivedEventsTotal> {
26        self.0.received_events_total()
27    }
28
29    /// Total sent events for the current source
30    pub async fn sent_events_total(&self) -> Option<metrics::SentEventsTotal> {
31        self.0.sent_events_total()
32    }
33}