MCPcopy Create free account
hub / github.com/CodSpeedHQ/codspeed / apply_run_command_transformations

Method apply_run_command_transformations

src/instruments/mongo_tracer.rs:196–226  ·  view source on GitHub ↗

Applies the necessary transformations to the command to run the benchmark TODO: move this to a `Instrument` trait, refactor and implement it for valgring as well

(&self, command: &mut Command)

Source from the content-addressed store, hash-verified

194 /// Applies the necessary transformations to the command to run the benchmark
195 /// TODO: move this to a `Instrument` trait, refactor and implement it for valgring as well
196 pub fn apply_run_command_transformations(&self, command: &mut Command) -> Result<()> {
197 let mut envs = vec![(
198 "CODSPEED_MONGO_INSTR_SERVER_ADDRESS",
199 self.server_address.as_str(),
200 )];
201
202 let mut new_uri = Url::from_str(&self.proxy_mongo_uri)?;
203 if let Some(user_input) = &self.user_input {
204 let destination_uri = Url::parse(&user_input.mongo_uri)?;
205 new_uri.set_path(destination_uri.path());
206 let cleaned_query_pairs = destination_uri
207 .query_pairs()
208 .filter(|(k, _)| {
209 if k == "directConnection" {
210 info!("Overriding directionConnection to true. This is necessary to make the MongoDB tracer work.");
211 return false;
212 }
213 true
214 });
215 new_uri
216 .query_pairs_mut()
217 .extend_pairs(cleaned_query_pairs)
218 .append_pair("directConnection", "true");
219
220 envs.push((user_input.uri_env_name.as_str(), new_uri.as_str()));
221 }
222
223 command.envs(envs);
224
225 Ok(())
226 }
227}
228
229pub async fn install_mongodb_tracer() -> Result<()> {

Calls 3

pathMethod · 0.80
as_strMethod · 0.80
envsMethod · 0.80