forked from pantsbuild/pants
/
metrics.rs
104 lines (97 loc) · 3.74 KB
/
metrics.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
// Copyright 2020 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
#![deny(warnings)]
// Enable all clippy lints except for many of the pedantic ones. It's a shame this needs to be copied and pasted across crates, but there doesn't appear to be a way to include inner attributes from a common source.
#![deny(
clippy::all,
clippy::default_trait_access,
clippy::expl_impl_clone_on_copy,
clippy::if_not_else,
clippy::needless_continue,
clippy::unseparated_literal_suffix,
// TODO: Falsely triggers for async/await:
// see https://github.com/rust-lang/rust-clippy/issues/5360
// clippy::used_underscore_binding
)]
// It is often more clear to show that nothing is being moved.
#![allow(clippy::match_ref_pats)]
// Subjective style.
#![allow(
clippy::len_without_is_empty,
clippy::redundant_field_names,
clippy::too_many_arguments
)]
// Default isn't as big a deal as people seem to think it is.
#![allow(clippy::new_without_default, clippy::new_ret_no_self)]
// Arc<Mutex> can be more clear than needing to grok Orderings:
#![allow(clippy::mutex_atomic)]
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
pub enum Metric {
LocalCacheRequests,
LocalCacheRequestsCached,
LocalCacheRequestsUncached,
LocalCacheReadErrors,
LocalCacheWriteErrors,
LocalExecutionRequests,
RemoteCacheRequests,
RemoteCacheRequestsCached,
RemoteCacheRequestsUncached,
RemoteCacheReadErrors,
RemoteCacheWriteErrors,
RemoteCacheSpeculationLocalCompletedFirst,
RemoteCacheSpeculationRemoteCompletedFirst,
RemoteExecutionErrors,
RemoteExecutionRequests,
RemoteExecutionRPCErrors,
RemoteExecutionRPCExecute,
RemoteExecutionRPCRetries,
RemoteExecutionRPCWaitExecution,
RemoteExecutionSuccess,
RemoteExecutionTimeouts,
}
impl Metric {
pub fn as_str(&self) -> &'static str {
use Metric::*;
match *self {
LocalCacheRequests => "local_cache_requests",
LocalCacheRequestsCached => "local_cache_requests_cached",
LocalCacheRequestsUncached => "local_cache_requests_uncached",
LocalCacheReadErrors => "local_cache_read_errors",
LocalCacheWriteErrors => "local_cache_write_errors",
LocalExecutionRequests => "local_execution_requests",
RemoteCacheRequests => "remote_cache_requests",
RemoteCacheRequestsCached => "remote_cache_requests_cached",
RemoteCacheRequestsUncached => "remote_cache_requests_uncached",
RemoteCacheReadErrors => "remote_cache_read_errors",
RemoteCacheWriteErrors => "remote_cache_write_errors",
RemoteCacheSpeculationLocalCompletedFirst => "remote_cache_speculation_local_completed_first",
RemoteCacheSpeculationRemoteCompletedFirst => {
"remote_cache_speculation_remote_completed_first"
}
RemoteExecutionErrors => "remote_execution_errors",
RemoteExecutionRequests => "remote_execution_requests",
RemoteExecutionRPCRetries => "remote_execution_rpc_retries",
RemoteExecutionRPCErrors => "remote_execution_rpc_errors",
RemoteExecutionRPCExecute => "remote_execution_rpc_execute",
RemoteExecutionRPCWaitExecution => "remote_execution_rpc_wait_execution",
RemoteExecutionSuccess => "remote_execution_success",
RemoteExecutionTimeouts => "remote_execution_timeouts",
}
}
}
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
pub enum ObservationMetric {
TestObservation,
RemoteExecutionRPCFirstResponseTime,
RemoteStoreTimeToFirstByte,
}
impl ObservationMetric {
pub fn as_str(&self) -> &'static str {
use ObservationMetric::*;
match *self {
TestObservation => "test_observation",
RemoteExecutionRPCFirstResponseTime => "remote_execution_rpc_first_response_time",
RemoteStoreTimeToFirstByte => "remote_store_time_to_first_byte",
}
}
}