MCPcopy Create free account
hub / github.com/buggregator/server / classifySpan

Function classifySpan

modules/sentry/span_classifier.go:10–40  ·  view source on GitHub ↗

classifySpan extracts service graph metadata from raw span attributes. Returns peer_type ("db", "http", "cache", "queue", "unknown") and peer_address.

(span RawSpan)

Source from the content-addressed store, hash-verified

8// classifySpan extracts service graph metadata from raw span attributes.
9// Returns peer_type ("db", "http", "cache", "queue", "unknown") and peer_address.
10func classifySpan(span RawSpan) (peerType string, peerAddress string) {
11 op := span.Op
12 attrs := span.Data
13
14 switch {
15 case strings.HasPrefix(op, "db."):
16 peerType = "db"
17 peerAddress = firstNonEmpty(
18 attrs["server.address"],
19 attrs["db.server.address"],
20 attrs["db.name"],
21 )
22 case op == "http.client":
23 peerType = "http"
24 if raw := attrs["http.url"]; raw != "" {
25 if u, err := url.Parse(raw); err == nil {
26 peerAddress = u.Host
27 }
28 }
29 case strings.HasPrefix(op, "cache."):
30 peerType = "cache"
31 peerAddress = attrs["server.address"]
32 case strings.HasPrefix(op, "queue."):
33 peerType = "queue"
34 peerAddress = attrs["messaging.destination"]
35 default:
36 peerType = "unknown"
37 }
38
39 return
40}
41
42// extractServiceName extracts the service name from span attributes or SDK info.
43func extractServiceName(span RawSpan, sdk *SDK) string {

Callers 3

storeTransactionFunction · 0.85
storeSpansV2Function · 0.85
TestSpanClassifierFunction · 0.85

Calls 2

firstNonEmptyFunction · 0.85
ParseMethod · 0.80

Tested by 1

TestSpanClassifierFunction · 0.68