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 5395783
Show file tree
Hide file tree
Showing 5 changed files with 145 additions and 3 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
8 changes: 7 additions & 1 deletion linkerd/app/outbound/src/http/concrete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ where
T: svc::Param<Option<http::uri::Authority>>,
{
fn param(&self) -> OutboundEndpointLabels {
let original_labels = self.metadata.labels().clone();

Check failure on line 345 in linkerd/app/outbound/src/http/concrete.rs

View workflow job for this annotation

GitHub Actions / clippy

error: redundant clone --> linkerd/app/outbound/src/http/concrete.rs:345:53 | 345 | let original_labels = self.metadata.labels().clone(); | ^^^^^^^^ help: remove this | note: this value is dropped without further use --> linkerd/app/outbound/src/http/concrete.rs:345:31 | 345 | let original_labels = self.metadata.labels().clone(); | ^^^^^^^^^^^^^^^^^^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_clone = note: `-D clippy::redundant-clone` implied by `-D warnings`
// 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()) {
Expand All @@ -352,8 +353,13 @@ where
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 5395783

Please sign in to comment.