Skip to content

Commit

Permalink
test: test dst_labels
Browse files Browse the repository at this point in the history
  • Loading branch information
bruce-personio committed Sep 14, 2023
1 parent f8be66a commit 2b2e63c
Show file tree
Hide file tree
Showing 5 changed files with 147 additions and 5 deletions.
12 changes: 12 additions & 0 deletions .idea/php.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

106 changes: 106 additions & 0 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 14 additions & 2 deletions linkerd/app/integration/src/tests/telemetry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -622,11 +622,11 @@ mod outbound_dst_labels {
let (
Fixture {
client,
metrics: _metrics,
metrics,
proxy: _proxy,
_profile,
dst_tx,
labels: _labels,
labels,
..
},
addr,
Expand All @@ -647,6 +647,18 @@ mod outbound_dst_labels {

info!("client.get(/)");
assert_eq!(client.get("/").await, "hello");

let labels = labels
.label("dst_addr_label", "foo")
.label("dst_set_label", "bar");

for &metric in &[
"request_total",
"response_total",
"response_latency_ms_count",
] {
labels.metric(metric).assert_in(&metrics).await;
}
}
}

Expand Down
12 changes: 9 additions & 3 deletions linkerd/app/outbound/src/http/concrete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,18 +342,24 @@ where
T: svc::Param<Option<http::uri::Authority>>,
{
fn param(&self) -> OutboundEndpointLabels {
let original_labels = self.metadata.labels().clone();
// self.metadata.labels() could return Err in some cases
// if that case the dst_labels won't carry any value
let mut dst_labels = match Arc::try_unwrap(self.metadata.labels()) {
Ok(result) => result,
Err(_e) => BTreeMap::new(),
};

dst_labels.remove("pod");
dst_labels.remove("pod_template_hash");
// dst_labels.remove("pod");
// dst_labels.remove("pod_template_hash");

let label_iterator = match dst_labels.is_empty() {
true => dst_labels.iter(),
false => original_labels.iter()
};

OutboundEndpointLabels {
labels: prefix_labels("dst", dst_labels.iter()),
labels: prefix_labels("dst", label_iterator),
server_id: self.param(),
}
}
Expand Down

0 comments on commit 2b2e63c

Please sign in to comment.