Add destination labels to all relevant tap events (#840)

The proxy incorrectly only added labels to response events. Destination
labels should be added to all tap events sent by the proxy.
This commit is contained in:
Oliver Gould 2018-04-24 17:15:13 -07:00 committed by GitHub
parent 5d29c270bf
commit 3799debab5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 28 additions and 4 deletions

View File

@ -77,10 +77,16 @@ impl event::StreamResponseFail {
eos: Some(self.error.into()), eos: Some(self.error.into()),
}; };
let destination_meta = ctx.dst_labels()
.and_then(|b| b.borrow().clone())
.map(|d| tap_event::EndpointMeta {
labels: d.as_map().clone(),
});
common::TapEvent { common::TapEvent {
source: Some((&ctx.server.remote).into()), source: Some((&ctx.server.remote).into()),
destination: Some((&ctx.client.remote).into()), destination: Some((&ctx.client.remote).into()),
destination_meta: None, destination_meta,
event: Some(tap_event::Event::Http(tap_event::Http { event: Some(tap_event::Event::Http(tap_event::Http {
event: Some(tap_event::http::Event::ResponseEnd(end)), event: Some(tap_event::http::Event::ResponseEnd(end)),
})), })),
@ -103,10 +109,16 @@ impl event::StreamRequestFail {
eos: Some(self.error.into()), eos: Some(self.error.into()),
}; };
let destination_meta = ctx.dst_labels()
.and_then(|b| b.borrow().clone())
.map(|d| tap_event::EndpointMeta {
labels: d.as_map().clone(),
});
common::TapEvent { common::TapEvent {
source: Some((&ctx.server.remote).into()), source: Some((&ctx.server.remote).into()),
destination: Some((&ctx.client.remote).into()), destination: Some((&ctx.client.remote).into()),
destination_meta: None, destination_meta,
event: Some(tap_event::Event::Http(tap_event::Http { event: Some(tap_event::Event::Http(tap_event::Http {
event: Some(tap_event::http::Event::ResponseEnd(end)), event: Some(tap_event::http::Event::ResponseEnd(end)),
})), })),
@ -137,10 +149,16 @@ impl<'a> TryFrom<&'a Event> for common::TapEvent {
path: ctx.uri.path().into(), path: ctx.uri.path().into(),
}; };
let destination_meta = ctx.dst_labels()
.and_then(|b| b.borrow().clone())
.map(|d| tap_event::EndpointMeta {
labels: d.as_map().clone(),
});
common::TapEvent { common::TapEvent {
source: Some((&ctx.server.remote).into()), source: Some((&ctx.server.remote).into()),
destination: Some((&ctx.client.remote).into()), destination: Some((&ctx.client.remote).into()),
destination_meta: None, destination_meta,
event: Some(tap_event::Event::Http(tap_event::Http { event: Some(tap_event::Event::Http(tap_event::Http {
event: Some(tap_event::http::Event::RequestInit(init)), event: Some(tap_event::http::Event::RequestInit(init)),
})), })),
@ -158,10 +176,16 @@ impl<'a> TryFrom<&'a Event> for common::TapEvent {
http_status: u32::from(ctx.status.as_u16()), http_status: u32::from(ctx.status.as_u16()),
}; };
let destination_meta = ctx.request.dst_labels()
.and_then(|b| b.borrow().clone())
.map(|d| tap_event::EndpointMeta {
labels: d.as_map().clone(),
});
common::TapEvent { common::TapEvent {
source: Some((&ctx.request.server.remote).into()), source: Some((&ctx.request.server.remote).into()),
destination: Some((&ctx.request.client.remote).into()), destination: Some((&ctx.request.client.remote).into()),
destination_meta: None, destination_meta,
event: Some(tap_event::Event::Http(tap_event::Http { event: Some(tap_event::Event::Http(tap_event::Http {
event: Some(tap_event::http::Event::ResponseInit(init)), event: Some(tap_event::http::Event::ResponseInit(init)),
})), })),