Skip to content

Commit 34f60c2

Browse files
committed
Migrate metrics to coordinator types
1 parent 047e5b7 commit 34f60c2

File tree

2 files changed

+51
-125
lines changed

2 files changed

+51
-125
lines changed

ui/src/metrics.rs

Lines changed: 51 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use lazy_static::lazy_static;
2-
use orchestrator::coordinator;
2+
use orchestrator::coordinator::{self, Channel, CompileTarget, CrateType, Edition, Mode};
33
use prometheus::{
44
self, register_histogram, register_histogram_vec, register_int_counter,
55
register_int_counter_vec, register_int_gauge, Histogram, HistogramVec, IntCounter,
@@ -10,7 +10,7 @@ use std::{
1010
time::{Duration, Instant},
1111
};
1212

13-
use crate::sandbox::{self, Channel, CompileTarget, CrateType, Edition, Mode};
13+
use crate::sandbox;
1414

1515
lazy_static! {
1616
pub(crate) static ref REQUESTS: HistogramVec = register_histogram_vec!(
@@ -132,15 +132,38 @@ impl Labels {
132132
v.map_or("", |v| if v { "true" } else { "false" })
133133
}
134134

135-
let target = target.map_or("", Into::into);
136-
let channel = channel.map_or("", Into::into);
137-
let mode = mode.map_or("", Into::into);
135+
let target = match target {
136+
Some(CompileTarget::Assembly(_, _, _)) => "Assembly",
137+
Some(CompileTarget::Hir) => "Hir",
138+
Some(CompileTarget::LlvmIr) => "LlvmIr",
139+
Some(CompileTarget::Mir) => "Mir",
140+
Some(CompileTarget::Wasm) => "Wasm",
141+
None => "",
142+
};
143+
let channel = match channel {
144+
Some(Channel::Stable) => "Stable",
145+
Some(Channel::Beta) => "Beta",
146+
Some(Channel::Nightly) => "Nightly",
147+
None => "",
148+
};
149+
let mode = match mode {
150+
Some(Mode::Debug) => "Debug",
151+
Some(Mode::Release) => "Release",
152+
None => "",
153+
};
138154
let edition = match edition {
139155
None => "",
140156
Some(None) => "Unspecified",
141-
Some(Some(v)) => v.into(),
157+
Some(Some(Edition::Rust2015)) => "Rust2015",
158+
Some(Some(Edition::Rust2018)) => "Rust2018",
159+
Some(Some(Edition::Rust2021)) => "Rust2021",
160+
Some(Some(Edition::Rust2024)) => "Rust2024",
161+
};
162+
let crate_type = match crate_type {
163+
Some(CrateType::Binary) => "Binary",
164+
Some(CrateType::Library(_)) => "Library",
165+
None => "",
142166
};
143-
let crate_type = crate_type.map_or("", Into::into);
144167
let tests = b(tests);
145168
let backtrace = b(backtrace);
146169

@@ -262,11 +285,11 @@ impl HasLabelsCore for coordinator::CompileRequest {
262285
} = *self;
263286

264287
LabelsCore {
265-
target: Some(target.into()),
266-
channel: Some(channel.into()),
267-
mode: Some(mode.into()),
268-
edition: Some(Some(edition.into())),
269-
crate_type: Some(crate_type.into()),
288+
target: Some(target),
289+
channel: Some(channel),
290+
mode: Some(mode),
291+
edition: Some(Some(edition)),
292+
crate_type: Some(crate_type),
270293
tests: Some(tests),
271294
backtrace: Some(backtrace),
272295
}
@@ -287,10 +310,10 @@ impl HasLabelsCore for coordinator::ExecuteRequest {
287310

288311
LabelsCore {
289312
target: None,
290-
channel: Some(channel.into()),
291-
mode: Some(mode.into()),
292-
edition: Some(Some(edition.into())),
293-
crate_type: Some(crate_type.into()),
313+
channel: Some(channel),
314+
mode: Some(mode),
315+
edition: Some(Some(edition)),
316+
crate_type: Some(crate_type),
294317
tests: Some(tests),
295318
backtrace: Some(backtrace),
296319
}
@@ -308,10 +331,10 @@ impl HasLabelsCore for coordinator::FormatRequest {
308331

309332
LabelsCore {
310333
target: None,
311-
channel: Some(channel.into()),
334+
channel: Some(channel),
312335
mode: None,
313-
edition: Some(Some(edition.into())),
314-
crate_type: Some(crate_type.into()),
336+
edition: Some(Some(edition)),
337+
crate_type: Some(crate_type),
315338
tests: None,
316339
backtrace: None,
317340
}
@@ -329,10 +352,10 @@ impl HasLabelsCore for coordinator::ClippyRequest {
329352

330353
LabelsCore {
331354
target: None,
332-
channel: Some(channel.into()),
355+
channel: Some(channel),
333356
mode: None,
334-
edition: Some(Some(edition.into())),
335-
crate_type: Some(crate_type.into()),
357+
edition: Some(Some(edition)),
358+
crate_type: Some(crate_type),
336359
tests: None,
337360
backtrace: None,
338361
}
@@ -350,10 +373,10 @@ impl HasLabelsCore for coordinator::MiriRequest {
350373

351374
LabelsCore {
352375
target: None,
353-
channel: Some(channel.into()),
376+
channel: Some(channel),
354377
mode: None,
355-
edition: Some(Some(edition.into())),
356-
crate_type: Some(crate_type.into()),
378+
edition: Some(Some(edition)),
379+
crate_type: Some(crate_type),
357380
tests: None,
358381
backtrace: None,
359382
}
@@ -371,10 +394,10 @@ impl HasLabelsCore for coordinator::MacroExpansionRequest {
371394

372395
LabelsCore {
373396
target: None,
374-
channel: Some(channel.into()),
397+
channel: Some(channel),
375398
mode: None,
376-
edition: Some(Some(edition.into())),
377-
crate_type: Some(crate_type.into()),
399+
edition: Some(Some(edition)),
400+
crate_type: Some(crate_type),
378401
tests: None,
379402
backtrace: None,
380403
}

ui/src/sandbox.rs

Lines changed: 0 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -473,100 +473,3 @@ impl<R: BacktraceRequest> BacktraceRequest for &'_ R {
473473
(*self).backtrace()
474474
}
475475
}
476-
477-
mod sandbox_orchestrator_integration_impls {
478-
use orchestrator::coordinator;
479-
480-
impl From<coordinator::CompileTarget> for super::CompileTarget {
481-
fn from(value: coordinator::CompileTarget) -> Self {
482-
match value {
483-
coordinator::CompileTarget::Assembly(a, b, c) => {
484-
super::CompileTarget::Assembly(a.into(), b.into(), c.into())
485-
}
486-
coordinator::CompileTarget::Hir => super::CompileTarget::Hir,
487-
coordinator::CompileTarget::LlvmIr => super::CompileTarget::LlvmIr,
488-
coordinator::CompileTarget::Mir => super::CompileTarget::Mir,
489-
coordinator::CompileTarget::Wasm => super::CompileTarget::Wasm,
490-
}
491-
}
492-
}
493-
494-
impl From<coordinator::Mode> for super::Mode {
495-
fn from(value: coordinator::Mode) -> Self {
496-
match value {
497-
coordinator::Mode::Debug => super::Mode::Debug,
498-
coordinator::Mode::Release => super::Mode::Release,
499-
}
500-
}
501-
}
502-
503-
impl From<coordinator::Edition> for super::Edition {
504-
fn from(value: coordinator::Edition) -> Self {
505-
match value {
506-
coordinator::Edition::Rust2015 => super::Edition::Rust2015,
507-
coordinator::Edition::Rust2018 => super::Edition::Rust2018,
508-
coordinator::Edition::Rust2021 => super::Edition::Rust2021,
509-
coordinator::Edition::Rust2024 => super::Edition::Rust2024,
510-
}
511-
}
512-
}
513-
514-
impl From<coordinator::Channel> for super::Channel {
515-
fn from(value: coordinator::Channel) -> Self {
516-
match value {
517-
coordinator::Channel::Stable => super::Channel::Stable,
518-
coordinator::Channel::Beta => super::Channel::Beta,
519-
coordinator::Channel::Nightly => super::Channel::Nightly,
520-
}
521-
}
522-
}
523-
524-
impl From<coordinator::AssemblyFlavor> for super::AssemblyFlavor {
525-
fn from(value: coordinator::AssemblyFlavor) -> Self {
526-
match value {
527-
coordinator::AssemblyFlavor::Att => super::AssemblyFlavor::Att,
528-
coordinator::AssemblyFlavor::Intel => super::AssemblyFlavor::Intel,
529-
}
530-
}
531-
}
532-
533-
impl From<coordinator::CrateType> for super::CrateType {
534-
fn from(value: coordinator::CrateType) -> Self {
535-
match value {
536-
coordinator::CrateType::Binary => super::CrateType::Binary,
537-
coordinator::CrateType::Library(a) => super::CrateType::Library(a.into()),
538-
}
539-
}
540-
}
541-
542-
impl From<coordinator::DemangleAssembly> for super::DemangleAssembly {
543-
fn from(value: coordinator::DemangleAssembly) -> Self {
544-
match value {
545-
coordinator::DemangleAssembly::Demangle => super::DemangleAssembly::Demangle,
546-
coordinator::DemangleAssembly::Mangle => super::DemangleAssembly::Mangle,
547-
}
548-
}
549-
}
550-
551-
impl From<coordinator::ProcessAssembly> for super::ProcessAssembly {
552-
fn from(value: coordinator::ProcessAssembly) -> Self {
553-
match value {
554-
coordinator::ProcessAssembly::Filter => super::ProcessAssembly::Filter,
555-
coordinator::ProcessAssembly::Raw => super::ProcessAssembly::Raw,
556-
}
557-
}
558-
}
559-
560-
impl From<coordinator::LibraryType> for super::LibraryType {
561-
fn from(value: coordinator::LibraryType) -> Self {
562-
match value {
563-
coordinator::LibraryType::Lib => super::LibraryType::Lib,
564-
coordinator::LibraryType::Dylib => super::LibraryType::Dylib,
565-
coordinator::LibraryType::Rlib => super::LibraryType::Rlib,
566-
coordinator::LibraryType::Staticlib => super::LibraryType::Staticlib,
567-
coordinator::LibraryType::Cdylib => super::LibraryType::Cdylib,
568-
coordinator::LibraryType::ProcMacro => super::LibraryType::ProcMacro,
569-
}
570-
}
571-
}
572-
}

0 commit comments

Comments
 (0)