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
use std::net::SocketAddr;

use metrics::counter;
use vector_lib::internal_event::InternalEvent;

#[derive(Debug)]
pub struct ApiStarted {
    pub addr: SocketAddr,
    pub playground: bool,
    pub graphql: bool,
}

impl InternalEvent for ApiStarted {
    fn emit(self) {
        let playground = &*format!("http://{}:{}/playground", self.addr.ip(), self.addr.port());
        let graphql = &*format!("http://{}:{}/graphql", self.addr.ip(), self.addr.port());
        info!(
            message="API server running.",
            address = ?self.addr,
            playground = %if self.playground { playground } else { "off" },
            graphql = %if self.graphql { graphql } else { "off" }

        );
        counter!("api_started_total").increment(1);
    }
}