relay_spans/
description.rs1use relay_conventions::attributes::*;
2use relay_conventions::description::description_for_op_and_attributes;
3use relay_event_schema::protocol::Attributes;
4use relay_protocol::{Annotated, Getter, Val};
5
6pub fn derive_description_for_v2_span(
14 attributes: &Attributes,
15 name: &Annotated<String>,
16) -> Option<String> {
17 let origin = attributes
18 .get_value(SENTRY__ORIGIN)
19 .and_then(|o| o.as_str());
20
21 let name = name.as_str();
22
23 if let Some(name) = name
24 && origin == Some("manual")
25 {
26 return Some(name.to_owned());
27 }
28
29 let op = attributes.get_value(SENTRY__OP)?.as_str()?;
30
31 description_for_op_and_attributes(op, &AttributeGetter(attributes))
32}
33
34struct AttributeGetter<'a>(&'a Attributes);
39
40impl<'a> Getter for AttributeGetter<'a> {
41 fn get_value(&self, path: &str) -> Option<Val<'_>> {
42 self.0.get_value(path).map(|value| value.into())
43 }
44}