Skip to content

Commit 9428766

Browse files
feat: accept simulation as runner mode
1 parent 8a5fdcb commit 9428766

File tree

6 files changed

+35
-8
lines changed

6 files changed

+35
-8
lines changed

src/run/config.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ impl Config {
5050
repository_override: None,
5151
working_directory: None,
5252
command: "".into(),
53-
mode: RunnerMode::Instrumentation,
53+
mode: RunnerMode::Simulation,
5454
instruments: Instruments::test(),
5555
perf_unwinding_mode: None,
5656
enable_perf: false,
@@ -123,7 +123,7 @@ mod tests {
123123
repository: None,
124124
provider: None,
125125
working_directory: None,
126-
mode: RunnerMode::Instrumentation,
126+
mode: RunnerMode::Simulation,
127127
instruments: vec![],
128128
mongo_uri_env_name: None,
129129
message_format: None,
@@ -157,7 +157,7 @@ mod tests {
157157
repository: Some("owner/repo".into()),
158158
provider: Some(RepositoryProvider::GitLab),
159159
working_directory: Some("/tmp".into()),
160-
mode: RunnerMode::Instrumentation,
160+
mode: RunnerMode::Simulation,
161161
instruments: vec!["mongodb".into()],
162162
mongo_uri_env_name: Some("MONGODB_URI".into()),
163163
message_format: Some(crate::run::MessageFormat::Json),

src/run/mod.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,9 @@ pub struct RunArgs {
137137
#[derive(ValueEnum, Clone, Debug, Serialize, PartialEq)]
138138
#[serde(rename_all = "lowercase")]
139139
pub enum RunnerMode {
140+
#[deprecated(note = "Use `RunnerMode::Simulation` instead")]
140141
Instrumentation,
142+
Simulation,
141143
Walltime,
142144
}
143145

@@ -156,7 +158,7 @@ impl RunArgs {
156158
repository: None,
157159
provider: None,
158160
working_directory: None,
159-
mode: RunnerMode::Instrumentation,
161+
mode: RunnerMode::Simulation,
160162
instruments: vec![],
161163
mongo_uri_env_name: None,
162164
message_format: None,
@@ -184,6 +186,14 @@ pub async fn run(
184186
let provider = run_environment::get_provider(&config)?;
185187
let logger = Logger::new(&provider)?;
186188

189+
#[allow(deprecated)]
190+
if config.mode == RunnerMode::Instrumentation {
191+
warn!(
192+
"The 'instrumentation' runner mode is deprecated and will be removed in a future version. \
193+
Please use 'simulation' instead."
194+
);
195+
}
196+
187197
if provider.get_run_environment() != RunEnvironment::Local {
188198
show_banner();
189199
}

src/run/runner/helpers/env.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,16 @@ pub fn get_base_injected_env(
66
mode: RunnerMode,
77
profile_folder: &Path,
88
) -> HashMap<&'static str, String> {
9+
let runner_mode_internal_env_value = match mode {
10+
// While the runner now deprecates the usage of instrumentation with a message, we
11+
// internally still use instrumentation temporarily to give time to users to upgrade their
12+
// integrations to a version that accepts both instrumentation and simulation.
13+
// TODO: Remove Instrumentation mode completely in the next major release, and set this
14+
// value to simulation instead.
15+
#[allow(deprecated)]
16+
RunnerMode::Instrumentation | RunnerMode::Simulation => "instrumentation",
17+
RunnerMode::Walltime => "walltime",
18+
};
919
HashMap::from([
1020
("PYTHONHASHSEED", "0".into()),
1121
(
@@ -18,7 +28,10 @@ pub fn get_base_injected_env(
1828
),
1929
("ARCH", ARCH.into()),
2030
("CODSPEED_ENV", "runner".into()),
21-
("CODSPEED_RUNNER_MODE", mode.to_string()),
31+
(
32+
"CODSPEED_RUNNER_MODE",
33+
runner_mode_internal_env_value.into(),
34+
),
2235
(
2336
"CODSPEED_PROFILE_FOLDER",
2437
profile_folder.to_string_lossy().to_string(),

src/run/runner/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ use wall_time::executor::WallTimeExecutor;
2121
impl Display for RunnerMode {
2222
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2323
match self {
24+
#[allow(deprecated)]
2425
RunnerMode::Instrumentation => write!(f, "instrumentation"),
26+
RunnerMode::Simulation => write!(f, "simulation"),
2527
RunnerMode::Walltime => write!(f, "walltime"),
2628
}
2729
}
@@ -31,7 +33,8 @@ pub const EXECUTOR_TARGET: &str = "executor";
3133

3234
pub fn get_executor_from_mode(mode: &RunnerMode) -> Box<dyn Executor> {
3335
match mode {
34-
RunnerMode::Instrumentation => Box::new(ValgrindExecutor),
36+
#[allow(deprecated)]
37+
RunnerMode::Instrumentation | RunnerMode::Simulation => Box::new(ValgrindExecutor),
3538
RunnerMode::Walltime => Box::new(WallTimeExecutor::new()),
3639
}
3740
}

src/run/runner/tests.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,10 @@ mod valgrind {
145145
.await
146146
}
147147

148+
#[cfg(test)]
148149
fn valgrind_config(command: &str) -> Config {
149150
Config {
150-
mode: RunnerMode::Instrumentation,
151+
mode: RunnerMode::Simulation,
151152
command: command.to_string(),
152153
..Config::test()
153154
}

src/run/runner/valgrind/measure.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ pub async fn measure(
8585
cmd.arg(ARCH).arg("-R");
8686
// Configure the environment
8787
cmd.envs(get_base_injected_env(
88-
RunnerMode::Instrumentation,
88+
RunnerMode::Simulation,
8989
profile_folder,
9090
))
9191
.env("PYTHONMALLOC", "malloc")

0 commit comments

Comments
 (0)