Skip to content

Commit 8e923da

Browse files
author
Steve Flinchbaugh
committed
reduces latency metric buckets
1 parent d924b5a commit 8e923da

File tree

9 files changed

+40
-40
lines changed

9 files changed

+40
-40
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ env:
4949
CARGO_INCREMENTAL: 0
5050
CARGO_NET_RETRY: 10
5151
RUSTFLAGS: "-D warnings -A deprecated --cfg tokio_unstable"
52-
RUSTUP_MAX_RETRIES: 11
52+
RUSTUP_MAX_RETRIES: 12
5353

5454
concurrency:
5555
group: ${{ github.workflow }}-${{ inputs.ref || github.head_ref }}

linkerd/app/core/src/metrics.rs

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,6 @@ pub enum Direction {
142142
Out,
143143
}
144144

145-
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
146-
struct Authority<'a>(&'a http::uri::Authority);
147-
148145
pub fn prefix_labels<'i, I>(prefix: &str, mut labels_iter: I) -> Option<String>
149146
where
150147
I: Iterator<Item = (&'i String, &'i String)>,
@@ -158,6 +155,23 @@ where
158155
Some(out)
159156
}
160157

158+
pub fn prefix_outbound_endpoint_labels<'i, I>(prefix: &str, mut labels_iter: I) -> Option<String>
159+
where
160+
I: Iterator<Item = (&'i String, &'i String)>,
161+
{
162+
let (k0, v0) = labels_iter.next()?;
163+
let mut out = format!("{}_{}=\"{}\"", prefix, k0, v0);
164+
165+
for (k, v) in labels_iter {
166+
if k == "pod" || k == "pod_template_hash" {
167+
continue;
168+
}
169+
170+
write!(out, ",{}_{}=\"{}\"", prefix, k, v).expect("label concat must succeed");
171+
}
172+
Some(out)
173+
}
174+
161175
// === impl Metrics ===
162176

163177
impl Metrics {
@@ -420,12 +434,6 @@ impl FmtLabels for Direction {
420434
}
421435
}
422436

423-
impl FmtLabels for Authority<'_> {
424-
fn fmt_labels(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
425-
write!(f, "authority=\"{}\"", self.0)
426-
}
427-
}
428-
429437
impl FmtLabels for Class {
430438
fn fmt_labels(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
431439
let class = |ok: bool| if ok { "success" } else { "failure" };

linkerd/app/inbound/src/http/router.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ impl Param<transport::labels::Key> for Logical {
391391
}
392392

393393
fn endpoint_labels(
394-
unsafe_authority_labels: bool,
394+
_unsafe_authority_labels: bool,
395395
) -> impl svc::ExtractParam<metrics::EndpointLabels, Logical> + Clone {
396396
move |t: &Logical| -> metrics::EndpointLabels {
397397
metrics::InboundEndpointLabels {

linkerd/app/inbound/src/http/tests.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -665,8 +665,6 @@ async fn grpc_response_class() {
665665
.get_response_total(
666666
&metrics::EndpointLabels::Inbound(metrics::InboundEndpointLabels {
667667
tls: Target::meshed_h2().1,
668-
authority: None,
669-
target_addr: "127.0.0.1:80".parse().unwrap(),
670668
policy: metrics::RouteAuthzLabels {
671669
route: metrics::RouteLabels {
672670
server: metrics::ServerLabel(
@@ -714,7 +712,7 @@ async fn unsafe_authority_labels_false() {
714712

715713
async fn test_unsafe_authority_labels(
716714
cfg: Config,
717-
expected_authority: Option<http::uri::Authority>,
715+
_expected_authority: Option<http::uri::Authority>,
718716
) {
719717
let connect = {
720718
let mut server = hyper::server::conn::http1::Builder::new();
@@ -763,8 +761,6 @@ async fn test_unsafe_authority_labels(
763761
.get_response_total(
764762
&metrics::EndpointLabels::Inbound(metrics::InboundEndpointLabels {
765763
tls: Target::meshed_http1().1,
766-
authority: expected_authority,
767-
target_addr: "127.0.0.1:80".parse().unwrap(),
768764
policy: metrics::RouteAuthzLabels {
769765
route: metrics::RouteLabels {
770766
server: metrics::ServerLabel(

linkerd/app/integration/src/tests/telemetry.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ impl Fixture {
9494
let metrics = client::http1(proxy.admin, "localhost");
9595

9696
let client = client::new(proxy.outbound, "tele.test.svc.cluster.local");
97-
let tcp_labels = metrics::labels().label("direction", "outbound")
97+
let tcp_labels = metrics::labels().label("direction", "outbound");
9898
let labels = tcp_labels.clone();
9999
let tcp_src_labels = tcp_labels.clone().label("peer", "src");
100100
let tcp_dst_labels = tcp_labels.label("peer", "dst");
@@ -299,14 +299,24 @@ async fn test_http_count(metric_name: &str, fixture: impl Future<Output = Fixtur
299299
..
300300
} = fixture.await;
301301

302-
let metric = labels.metric(metric_name);
302+
// Instead of checking that the metric doesn't exist at all, check that the
303+
// specific metric with service name matching the test doesn't exist.
304+
// This avoids the issue with the admin metrics endpoint counting its own calls.
305+
let test_specific_metric = labels
306+
.metric(metric_name)
307+
.label("srv_name", "tele.test.svc.cluster.local");
308+
303309
let scrape = metrics.get("/metrics").await;
310+
assert!(
311+
test_specific_metric.is_not_in(scrape),
312+
"{test_specific_metric:?} should not be in /metrics"
313+
);
304314

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

308318
// after seeing a request, the request carry the correct labels
309-
metric.assert_in(&metrics).await;
319+
test_specific_metric.assert_in(&metrics).await;
310320
}
311321

312322
mod response_classification {
@@ -1187,7 +1197,7 @@ async fn metrics_compression() {
11871197
info!("client.get(/)");
11881198
assert_eq!(client.get("/").await, "hello");
11891199

1190-
let mut metric = labels
1200+
let metric = labels
11911201
.metric("response_latency_ms_count")
11921202
.label("status_code", 200);
11931203

linkerd/app/integration/src/tests/telemetry/tcp_errors.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,7 @@ async fn inbound_invalid_ip() {
292292
.await;
293293

294294
let client = crate::tcp::client(proxy.inbound);
295-
let metric = metric(&proxy)
296-
.label("error", "unexpected");
295+
let metric = metric(&proxy).label("error", "unexpected");
297296

298297
let tcp_client = client.connect().await;
299298
tcp_client.write(TcpFixture::HELLO_MSG).await;

linkerd/app/outbound/src/http/concrete.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ use crate::{
99
};
1010
use linkerd_app_core::{
1111
config::{ConnectConfig, QueueConfig},
12-
metrics::{prefix_outbound_endpoint_labels, EndpointLabels, OutboundEndpointLabels, OutboundZoneLocality},
12+
metrics::{
13+
prefix_outbound_endpoint_labels, EndpointLabels, OutboundEndpointLabels,
14+
OutboundZoneLocality,
15+
},
1316
profiles,
1417
proxy::{
1518
api_resolve::{ConcreteAddr, Metadata, ProtocolHint},
@@ -219,7 +222,7 @@ where
219222
{
220223
fn param(&self) -> OutboundEndpointLabels {
221224
OutboundEndpointLabels {
222-
labels: prefix_outbound_endpoint_labels(self.metadata.labels().iter()),
225+
labels: prefix_outbound_endpoint_labels("dst", self.metadata.labels().iter()),
223226
zone_locality: self.param(),
224227
server_id: self.param(),
225228
}

linkerd/app/outbound/src/tls/concrete.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,11 +326,9 @@ where
326326
{
327327
fn param(&self) -> metrics::OutboundEndpointLabels {
328328
metrics::OutboundEndpointLabels {
329-
authority: None,
330329
labels: metrics::prefix_labels("dst", self.metadata.labels().iter()),
331330
zone_locality: self.param(),
332331
server_id: self.param(),
333-
target_addr: self.addr.into(),
334332
}
335333
}
336334
}

linkerd/metrics/src/latency.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,16 @@ use super::histogram::{Bounds, Bucket, Histogram};
66
/// milliseconds.
77
pub const BOUNDS: &Bounds = &Bounds(&[
88
Bucket::Le(1.0),
9-
Bucket::Le(2.0),
10-
Bucket::Le(3.0),
11-
Bucket::Le(4.0),
12-
Bucket::Le(5.0),
139
Bucket::Le(10.0),
14-
Bucket::Le(20.0),
15-
Bucket::Le(30.0),
16-
Bucket::Le(40.0),
1710
Bucket::Le(50.0),
1811
Bucket::Le(100.0),
1912
Bucket::Le(200.0),
2013
Bucket::Le(300.0),
2114
Bucket::Le(400.0),
2215
Bucket::Le(500.0),
2316
Bucket::Le(1_000.0),
24-
Bucket::Le(2_000.0),
25-
Bucket::Le(3_000.0),
26-
Bucket::Le(4_000.0),
2717
Bucket::Le(5_000.0),
2818
Bucket::Le(10_000.0),
29-
Bucket::Le(20_000.0),
30-
Bucket::Le(30_000.0),
31-
Bucket::Le(40_000.0),
32-
Bucket::Le(50_000.0),
3319
// A final upper bound.
3420
Bucket::Inf,
3521
]);

0 commit comments

Comments
 (0)