From a97d650037f4ffe7e6287fbf810728a84f7b7ed1 Mon Sep 17 00:00:00 2001 From: Bruce Chen Date: Thu, 14 Sep 2023 13:18:22 +0200 Subject: [PATCH] test: test dst_labels --- .idea/php.xml | 12 ++ .idea/vcs.xml | 6 + .idea/workspace.xml | 106 ++++++++++++++++++ .../app/integration/src/tests/telemetry.rs | 16 ++- linkerd/app/outbound/src/http/concrete.rs | 10 +- 5 files changed, 146 insertions(+), 4 deletions(-) create mode 100644 .idea/php.xml create mode 100644 .idea/vcs.xml create mode 100644 .idea/workspace.xml diff --git a/.idea/php.xml b/.idea/php.xml new file mode 100644 index 0000000000..f5f27444bd --- /dev/null +++ b/.idea/php.xml @@ -0,0 +1,12 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000000..35eb1ddfbb --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 0000000000..747c859d9c --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,106 @@ + + + + + + + + + + + + + + + + + + + + { + "keyToString": { + "RunOnceActivity.OpenProjectViewOnStart": "true", + "RunOnceActivity.ShowReadmeOnStart": "true", + "RunOnceActivity.go.formatter.settings.were.checked": "true", + "RunOnceActivity.go.migrated.go.modules.settings": "true", + "WebServerToolWindowFactoryState": "false", + "go.import.settings.migrated": "true", + "node.js.detected.package.eslint": "true", + "node.js.detected.package.tslint": "true", + "node.js.selected.package.eslint": "(autodetect)", + "node.js.selected.package.tslint": "(autodetect)", + "nodejs_package_manager_path": "npm", + "org.rust.cargo.project.model.PROJECT_DISCOVERY": "true", + "vue.rearranger.settings.migration": "true" + } +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1694590988621 + + + + + + + true + + \ No newline at end of file diff --git a/linkerd/app/integration/src/tests/telemetry.rs b/linkerd/app/integration/src/tests/telemetry.rs index 407786b159..ca8a46cd58 100644 --- a/linkerd/app/integration/src/tests/telemetry.rs +++ b/linkerd/app/integration/src/tests/telemetry.rs @@ -622,11 +622,11 @@ mod outbound_dst_labels { let ( Fixture { client, - metrics: _metrics, + metrics, proxy: _proxy, _profile, dst_tx, - labels: _labels, + labels, .. }, addr, @@ -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; + } } } diff --git a/linkerd/app/outbound/src/http/concrete.rs b/linkerd/app/outbound/src/http/concrete.rs index c85a48bc65..56e7c4c4a7 100644 --- a/linkerd/app/outbound/src/http/concrete.rs +++ b/linkerd/app/outbound/src/http/concrete.rs @@ -342,9 +342,10 @@ where T: svc::Param>, { fn param(&self) -> OutboundEndpointLabels { + let arc_labels = self.metadata.labels(); // 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()) { + let mut dst_labels = match Arc::try_unwrap(arc_labels) { Ok(result) => result, Err(_e) => BTreeMap::new(), }; @@ -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 => arc_labels.iter() + }; + OutboundEndpointLabels { - labels: prefix_labels("dst", dst_labels.iter()), + labels: prefix_labels("dst", label_iterator), server_id: self.param(), } }