Skip to content

Commit dacfb90

Browse files
authored
refactor(core/raw)!: Use AccessorInfo instead of seperate fields (#5796)
* refactor: Use AccessorInfo instead of seperate fields Signed-off-by: Xuanwo <[email protected]> * Fix msrv checks Signed-off-by: Xuanwo <[email protected]> --------- Signed-off-by: Xuanwo <[email protected]>
1 parent 11054d6 commit dacfb90

File tree

7 files changed

+184
-370
lines changed

7 files changed

+184
-370
lines changed

core/src/layers/metrics.rs

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -105,17 +105,13 @@ pub struct MetricsInterceptor {
105105
impl observe::MetricsIntercept for MetricsInterceptor {
106106
fn observe_operation_duration_seconds(
107107
&self,
108-
scheme: Scheme,
109-
namespace: Arc<String>,
110-
root: Arc<String>,
108+
info: Arc<AccessorInfo>,
111109
path: &str,
112110
op: Operation,
113111
duration: Duration,
114112
) {
115113
let labels = OperationLabels {
116-
scheme,
117-
namespace,
118-
root,
114+
info,
119115
path,
120116
operation: op,
121117
error: None,
@@ -126,17 +122,13 @@ impl observe::MetricsIntercept for MetricsInterceptor {
126122

127123
fn observe_operation_bytes(
128124
&self,
129-
scheme: Scheme,
130-
namespace: Arc<String>,
131-
root: Arc<String>,
125+
info: Arc<AccessorInfo>,
132126
path: &str,
133127
op: Operation,
134128
bytes: usize,
135129
) {
136130
let labels = OperationLabels {
137-
scheme,
138-
namespace,
139-
root,
131+
info,
140132
path,
141133
operation: op,
142134
error: None,
@@ -147,17 +139,13 @@ impl observe::MetricsIntercept for MetricsInterceptor {
147139

148140
fn observe_operation_errors_total(
149141
&self,
150-
scheme: Scheme,
151-
namespace: Arc<String>,
152-
root: Arc<String>,
142+
info: Arc<AccessorInfo>,
153143
path: &str,
154144
op: Operation,
155145
error: ErrorKind,
156146
) {
157147
let labels = OperationLabels {
158-
scheme,
159-
namespace,
160-
root,
148+
info,
161149
path,
162150
operation: op,
163151
error: Some(error),
@@ -168,9 +156,7 @@ impl observe::MetricsIntercept for MetricsInterceptor {
168156
}
169157

170158
struct OperationLabels<'a> {
171-
scheme: Scheme,
172-
namespace: Arc<String>,
173-
root: Arc<String>,
159+
info: Arc<AccessorInfo>,
174160
path: &'a str,
175161
operation: Operation,
176162
error: Option<ErrorKind>,
@@ -187,9 +173,9 @@ impl OperationLabels<'_> {
187173
let mut labels = Vec::with_capacity(6);
188174

189175
labels.extend([
190-
Label::new(observe::LABEL_SCHEME, self.scheme.into_static()),
191-
Label::new(observe::LABEL_NAMESPACE, (*self.namespace).clone()),
192-
Label::new(observe::LABEL_ROOT, (*self.root).clone()),
176+
Label::new(observe::LABEL_SCHEME, self.info.scheme().into_static()),
177+
Label::new(observe::LABEL_NAMESPACE, self.info.name()),
178+
Label::new(observe::LABEL_ROOT, self.info.root()),
193179
Label::new(observe::LABEL_OPERATION, self.operation.into_static()),
194180
]);
195181

0 commit comments

Comments
 (0)