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

Method start

src/instruments/mongo_tracer.rs:120–167  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

118 }
119
120 pub async fn start(&mut self) -> Result<()> {
121 let mut command = Command::new("cs-mongo-tracer");
122 let (server_address, proxy_host_port, destination_host_port) = self
123 .get_host_port_from_uris()
124 .context("Failed to parse the uris")?;
125
126 let mut envs = vec![
127 ("RUST_LOG", "debug"),
128 (
129 "CODSPEED_MONGO_INSTR_SERVER_ADDRESS",
130 server_address.as_str(),
131 ),
132 ("CODSPEED_MONGO_PROXY_HOST_PORT", proxy_host_port.as_str()),
133 ];
134 if let Some(destination_host_port) = destination_host_port.as_ref() {
135 envs.push((
136 "CODSPEED_MONGO_DEST_HOST_PORT",
137 destination_host_port.as_str(),
138 ));
139 }
140 command.envs(envs);
141
142 debug!("Start the MongoDB tracer: {command:?}");
143 if let Some(destination_host_port) = destination_host_port {
144 debug!("Proxy MongoDB from {proxy_host_port} to {destination_host_port}");
145 } else {
146 info!(
147 "No MongoDB URI provided, user will have to provide it dynamically through the CodSpeed integration"
148 );
149 }
150 let mut process = command
151 .stdout(Stdio::piped())
152 .stderr(Stdio::piped())
153 .spawn()?;
154
155 let process_stdout = process.stdout.take().expect("error taking child stdout");
156 let process_stderr = process.stderr.take().expect("error taking child stderr");
157 thread::spawn(move || {
158 dump_tracer_log(process_stdout).expect("error communicating with child stdout")
159 });
160 thread::spawn(move || {
161 dump_tracer_log(process_stderr).expect("error communicating with child stderr")
162 });
163
164 self.process = Some(process);
165
166 Ok(())
167 }
168
169 pub async fn stop(&mut self) -> Result<()> {
170 let response = Client::new()

Callers 1

run_executorFunction · 0.80

Calls 4

dump_tracer_logFunction · 0.85
as_strMethod · 0.80
envsMethod · 0.80

Tested by

no test coverage detected