fn base_event<B, I: Inspect>(req: &http::Request<B>, inspect: &I) -> api::TapEvent {
    api::TapEvent {
        proxy_direction: if inspect.is_outbound(req) {
            api::tap_event::ProxyDirection::Outbound.into()
        } else {
            api::tap_event::ProxyDirection::Inbound.into()
        },
        source: inspect.src_addr(req).map(|a| a.into()),
        source_meta: {
            let mut m = api::tap_event::EndpointMeta::default();
            match inspect.src_tls(req) {
                Conditional::None(reason) => {
                    m.labels.insert("tls".to_owned(), reason.to_string());
                }
                Conditional::Some(tls::ServerTls::Established { client_id, .. }) => {
                    m.labels.insert("tls".to_owned(), "true".to_owned());
                    m.labels.insert(
                        "client_id".to_owned(),
                        client_id.map(|id| id.to_string()).unwrap_or_default(),
                    );
                }
                Conditional::Some(tls::ServerTls::Passthru { sni }) => {
                    m.labels.insert("tls".to_owned(), "passthru".to_owned());
                    m.labels.insert("sni".to_owned(), sni.to_string());
                }
            }
            Some(m)
        },
        destination: inspect.dst_addr(req).map(|a| a.into()),
        destination_meta: inspect.dst_labels(req).map(|labels| {
            let mut m = api::tap_event::EndpointMeta::default();
            m.labels
                .extend(labels.iter().map(|(k, v)| (k.clone(), v.clone())));
            match inspect.dst_tls(req) {
                Conditional::None(reason) => {
                    m.labels.insert("tls".to_owned(), reason.to_string());
                }
                Conditional::Some(tls::ClientTls { server_id, .. }) => {
                    m.labels.insert("tls".to_owned(), "true".to_owned());
                    m.labels
                        .insert("server_id".to_owned(), server_id.to_string());
                }
            }
            m
        }),
        route_meta: inspect.route_labels(req).map(|labels| {
            let mut m = api::tap_event::RouteMeta::default();
            m.labels
                .extend(labels.as_ref().iter().map(|(k, v)| (k.clone(), v.clone())));
            m
        }),
        event: None,
    }
}
// All of the events emitted from tap have a common set of metadata.
// Build this once, without an `event`, so that it can be used to build
// each HTTP event.
All of the events emitted from tap have a common set of metadata.
Build this once, without an `event`, so that it can be used to build
each HTTP event.
All of the events emitted from tap have a common set of metadata . Build this once without an ` event ` so that it can be used to build each HTTP event .
fn base_event<B, I: Inspect>(req: &http::Request<B>, inspect: &I) -> api::TapEvent {
    api::TapEvent {
        proxy_direction: if inspect.is_outbound(req) {
            api::tap_event::ProxyDirection::Outbound.into()
        } else {
            api::tap_event::ProxyDirection::Inbound.into()
        },
        source: inspect.src_addr(req).map(|a| a.into()),
        source_meta: {
            let mut m = api::tap_event::EndpointMeta::default();
            match inspect.src_tls(req) {
                Conditional::None(reason) => {
                    m.labels.insert("tls".to_owned(), reason.to_string());
                }
                Conditional::Some(tls::ServerTls::Established { client_id, .. }) => {
                    m.labels.insert("tls".to_owned(), "true".to_owned());
                    m.labels.insert(
                        "client_id".to_owned(),
                        client_id.map(|id| id.to_string()).unwrap_or_default(),
                    );
                }
                Conditional::Some(tls::ServerTls::Passthru { sni }) => {
                    m.labels.insert("tls".to_owned(), "passthru".to_owned());
                    m.labels.insert("sni".to_owned(), sni.to_string());
                }
            }
            Some(m)
        },
        destination: inspect.dst_addr(req).map(|a| a.into()),
        destination_meta: inspect.dst_labels(req).map(|labels| {
            let mut m = api::tap_event::EndpointMeta::default();
            m.labels
                .extend(labels.iter().map(|(k, v)| (k.clone(), v.clone())));
            match inspect.dst_tls(req) {
                Conditional::None(reason) => {
                    m.labels.insert("tls".to_owned(), reason.to_string());
                }
                Conditional::Some(tls::ClientTls { server_id, .. }) => {
                    m.labels.insert("tls".to_owned(), "true".to_owned());
                    m.labels
                        .insert("server_id".to_owned(), server_id.to_string());
                }
            }
            m
        }),
        route_meta: inspect.route_labels(req).map(|labels| {
            let mut m = api::tap_event::RouteMeta::default();
            m.labels
                .extend(labels.as_ref().iter().map(|(k, v)| (k.clone(), v.clone())));
            m
        }),
        event: None,
    }
}
fn base_event < B , I : Inspect > ( req : & http :: Request < B > , inspect : & I ) -> api :: TapEvent { api :: TapEvent { proxy_direction : if inspect . is_outbound ( req ) { api :: tap_event :: ProxyDirection :: Outbound . into ( ) } else { api :: tap_event :: ProxyDirection :: Inbound . into ( ) } , source : inspect . src_addr ( req ) . map ( | a | a . into ( ) ) , source_meta : { let mut m = api :: tap_event :: EndpointMeta :: default ( ) ; match inspect . src_tls ( req ) { Conditional :: None ( reason ) => { m . labels . insert ( " " . to_owned ( ) , reason . to_string ( ) ) ; } Conditional :: Some ( tls :: ServerTls :: Established { client_id , .. } ) => { m . labels . insert ( " " . to_owned ( ) , " " . to_owned ( ) ) ; m . labels . insert ( " " . to_owned ( ) , client_id . map ( | id | id . to_string ( ) ) . unwrap_or_default ( ) , ) ; } Conditional :: Some ( tls :: ServerTls :: Passthru { sni } ) => { m . labels . insert ( " " . to_owned ( ) , " " . to_owned ( ) ) ; m . labels . insert ( " " . to_owned ( ) , sni . to_string ( ) ) ; } } Some ( m ) } , destination : inspect . dst_addr ( req ) . map ( | a | a . into ( ) ) , destination_meta : inspect . dst_labels ( req ) . map ( | labels | { let mut m = api :: tap_event :: EndpointMeta :: default ( ) ; m . labels . extend ( labels . iter ( ) . map ( | ( k , v ) | ( k . clone ( ) , v . clone ( ) ) ) ) ; match inspect . dst_tls ( req ) { Conditional :: None ( reason ) => { m . labels . insert ( " " . to_owned ( ) , reason . to_string ( ) ) ; } Conditional :: Some ( tls :: ClientTls { server_id , .. } ) => { m . labels . insert ( " " . to_owned ( ) , " " . to_owned ( ) ) ; m . labels . insert ( " " . to_owned ( ) , server_id . to_string ( ) ) ; } } m } ) , route_meta : inspect . route_labels ( req ) . map ( | labels | { let mut m = api :: tap_event :: RouteMeta :: default ( ) ; m . labels . extend ( labels . as_ref ( ) . iter ( ) . map ( | ( k , v ) | ( k . clone ( ) , v . clone ( ) ) ) ) ; m } ) , event : None , } }
All of the events emitted from tap have a common set of metadata.
All of the events emitted from tap have a common set of metadata .
req
&http::Request<B>
inspect
&I
req
&http::Request<B>
inspect
&I