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

Method try_from

src/instruments/mod.rs:44–68  ·  view source on GitHub ↗
(args: &RunArgs)

Source from the content-addressed store, hash-verified

42impl TryFrom<&RunArgs> for Instruments {
43 type Error = Error;
44 fn try_from(args: &RunArgs) -> Result<Self> {
45 let mut validated_instrument_names: HashSet<InstrumentName> = HashSet::new();
46
47 for instrument_name in &args.instruments {
48 match instrument_name.as_str() {
49 "mongodb" => validated_instrument_names.insert(InstrumentName::MongoDB),
50 _ => bail!("Invalid instrument name: {instrument_name}"),
51 };
52 }
53
54 let mongodb = if validated_instrument_names.contains(&InstrumentName::MongoDB) {
55 Some(MongoDBConfig {
56 uri_env_name: args.mongo_uri_env_name.clone(),
57 })
58 } else if args.mongo_uri_env_name.is_some() {
59 warn!(
60 "The MongoDB instrument is disabled but a MongoDB URI environment variable name was provided, ignoring it"
61 );
62 None
63 } else {
64 None
65 };
66
67 Ok(Self { mongodb })
68 }
69}
70
71#[cfg(test)]

Callers

nothing calls this directly

Calls 1

as_strMethod · 0.80

Tested by

no test coverage detected