1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
mod generic;

use async_graphql::Interface;

use super::{ReceivedEventsTotal, SentBytesTotal, SentEventsTotal};
use crate::event::Metric;

#[derive(Debug, Clone, Interface)]
#[graphql(
    field(name = "received_events_total", ty = "Option<ReceivedEventsTotal>"),
    field(name = "sent_bytes_total", ty = "Option<SentBytesTotal>"),
    field(name = "sent_events_total", ty = "Option<SentEventsTotal>")
)]
pub enum SinkMetrics {
    GenericSinkMetrics(generic::GenericSinkMetrics),
}

pub trait IntoSinkMetrics {
    fn into_sink_metrics(self, component_type: &str) -> SinkMetrics;
}

impl IntoSinkMetrics for Vec<Metric> {
    fn into_sink_metrics(self, _component_type: &str) -> SinkMetrics {
        SinkMetrics::GenericSinkMetrics(generic::GenericSinkMetrics::new(self))
    }
}