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

Method try_from

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 1

as_strMethod · 0.80

Tested by

no test coverage detected