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).as_ref().map(|a| a.into()),
        source_meta: {
            let mut m = api::tap_event::EndpointMeta::default();
            let tls = inspect.src_tls(req);
            let tls_status = tls::Status::from(tls.as_ref());
            m.labels.insert("tls".to_owned(), tls_status.to_string());
            if let Conditional::Some(id) = tls {
                m.labels
                    .insert("client_id".to_owned(), id.as_ref().to_owned());
            }
            Some(m)
        },
        destination: inspect.dst_addr(req).as_ref().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())));
            let tls = inspect.dst_tls(req);
            let tls_status = tls::Status::from(tls.as_ref());
            m.labels.insert("tls".to_owned(), tls_status.to_string());
            if let Conditional::Some(id) = tls {
                m.labels
                    .insert("server_id".to_owned(), id.as_ref().to_owned());
            }
            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).as_ref().map(|a| a.into()),
        source_meta: {
            let mut m = api::tap_event::EndpointMeta::default();
            let tls = inspect.src_tls(req);
            let tls_status = tls::Status::from(tls.as_ref());
            m.labels.insert("tls".to_owned(), tls_status.to_string());
            if let Conditional::Some(id) = tls {
                m.labels
                    .insert("client_id".to_owned(), id.as_ref().to_owned());
            }
            Some(m)
        },
        destination: inspect.dst_addr(req).as_ref().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())));
            let tls = inspect.dst_tls(req);
            let tls_status = tls::Status::from(tls.as_ref());
            m.labels.insert("tls".to_owned(), tls_status.to_string());
            if let Conditional::Some(id) = tls {
                m.labels
                    .insert("server_id".to_owned(), id.as_ref().to_owned());
            }
            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 ) . as_ref ( ) . map ( | a | a . into ( ) ) , source_meta : { let mut m = api :: tap_event :: EndpointMeta :: default ( ) ; let tls = inspect . src_tls ( req ) ; let tls_status = tls :: Status :: from ( tls . as_ref ( ) ) ; m . labels . insert ( " " . to_owned ( ) , tls_status . to_string ( ) ) ; if let Conditional :: Some ( id ) = tls { m . labels . insert ( " " . to_owned ( ) , id . as_ref ( ) . to_owned ( ) ) ; } Some ( m ) } , destination : inspect . dst_addr ( req ) . as_ref ( ) . 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 ( ) ) ) ) ; let tls = inspect . dst_tls ( req ) ; let tls_status = tls :: Status :: from ( tls . as_ref ( ) ) ; m . labels . insert ( " " . to_owned ( ) , tls_status . to_string ( ) ) ; if let Conditional :: Some ( id ) = tls { m . labels . insert ( " " . to_owned ( ) , id . as_ref ( ) . to_owned ( ) ) ; } 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