1use relay_conventions::attributes::*;
2use relay_event_schema::protocol::{Attributes, SpanKind};
3use relay_protocol::Annotated;
4
5pub fn derive_op_for_v2_span(attributes: &Annotated<Attributes>) -> String {
12 let op = String::from("default");
14
15 let Some(attributes) = attributes.value() else {
16 return op;
17 };
18
19 if attributes.contains_key(HTTP__REQUEST__METHOD) {
20 let kind = attributes.get_value(SENTRY__KIND).and_then(|v| v.as_str());
21 return match kind {
22 Some(kind) if kind == SpanKind::Client.as_str() => String::from("http.client"),
23 Some(kind) if kind == SpanKind::Server.as_str() => String::from("http.server"),
24 _ => {
25 if attributes.contains_key(SENTRY__HTTP__PREFETCH) {
26 String::from("http.prefetch")
27 } else {
28 String::from("http")
29 }
30 }
31 };
32 }
33
34 if attributes.contains_key(DB__SYSTEM__NAME) {
35 return String::from("db");
36 }
37
38 if attributes.contains_key(GEN_AI__PROVIDER__NAME) {
39 return String::from("gen_ai");
40 }
41
42 if attributes.contains_key(RPC__SERVICE) {
43 return String::from("rpc");
44 }
45
46 if attributes.contains_key(MESSAGING__SYSTEM) {
47 return String::from("message");
48 }
49
50 if let Some(faas_trigger) = attributes.get_value(FAAS__TRIGGER).and_then(|v| v.as_str()) {
51 return faas_trigger.to_owned();
52 }
53
54 op
55}