Skip to content

Commit

Permalink
Remove incorrect or unnecessary fields from documents from otlp span …
Browse files Browse the repository at this point in the history
…event (#374)

otlp span event documents contain unnecessary fields, as a side effect of span event APMEvent being cloned from the span APMEvent. Due to this, parent.id value is either empty or grandparent's id. Remove it. Remove service.target.* and service.origin.*
  • Loading branch information
carsonip authored Oct 9, 2024
1 parent 330078b commit 44e3a29
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 54 deletions.
63 changes: 9 additions & 54 deletions input/otlp/test_approved/span_jaeger_http.approved.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,7 @@
"language": {
"name": "unknown"
},
"name": "unknown",
"target": {
"name": "foo.bar.com:80",
"type": "http"
}
"name": "unknown"
},
"timestamp": {
"us": 1576500418000768
Expand Down Expand Up @@ -151,11 +147,7 @@
"language": {
"name": "unknown"
},
"name": "unknown",
"target": {
"name": "foo.bar.com:80",
"type": "http"
}
"name": "unknown"
},
"timestamp": {
"us": 1576500418000768
Expand Down Expand Up @@ -199,11 +191,7 @@
"language": {
"name": "unknown"
},
"name": "unknown",
"target": {
"name": "foo.bar.com:80",
"type": "http"
}
"name": "unknown"
},
"timestamp": {
"us": 1576500418000768
Expand Down Expand Up @@ -247,11 +235,7 @@
"language": {
"name": "unknown"
},
"name": "unknown",
"target": {
"name": "foo.bar.com:80",
"type": "http"
}
"name": "unknown"
},
"timestamp": {
"us": 1576500418000768
Expand Down Expand Up @@ -295,11 +279,7 @@
"language": {
"name": "unknown"
},
"name": "unknown",
"target": {
"name": "foo.bar.com:80",
"type": "http"
}
"name": "unknown"
},
"timestamp": {
"us": 1576500418000768
Expand Down Expand Up @@ -340,11 +320,7 @@
"language": {
"name": "unknown"
},
"name": "unknown",
"target": {
"name": "foo.bar.com:80",
"type": "http"
}
"name": "unknown"
},
"timestamp": {
"us": 1576500418000768
Expand Down Expand Up @@ -380,18 +356,11 @@
"isValid": "false"
},
"message": "baggage",
"parent": {
"id": "0000000058585858"
},
"service": {
"language": {
"name": "unknown"
},
"name": "unknown",
"target": {
"name": "foo.bar.com:80",
"type": "http"
}
"name": "unknown"
},
"span": {
"id": "0000000041414646"
Expand Down Expand Up @@ -427,18 +396,11 @@
"level": "info"
},
"message": "retrying connection",
"parent": {
"id": "0000000058585858"
},
"service": {
"language": {
"name": "unknown"
},
"name": "unknown",
"target": {
"name": "foo.bar.com:80",
"type": "http"
}
"name": "unknown"
},
"span": {
"id": "0000000041414646"
Expand Down Expand Up @@ -473,18 +435,11 @@
"labels": {
"level": "error"
},
"parent": {
"id": "0000000058585858"
},
"service": {
"language": {
"name": "unknown"
},
"name": "unknown",
"target": {
"name": "foo.bar.com:80",
"type": "http"
}
"name": "unknown"
},
"span": {
"id": "0000000041414646"
Expand Down
8 changes: 8 additions & 0 deletions input/otlp/traces.go
Original file line number Diff line number Diff line change
Expand Up @@ -1073,6 +1073,14 @@ func (c *Consumer) convertSpanEvent(
initEventLabels(event)
event.Transaction = nil // populate fields as required from parent
event.Span = nil // populate fields as required from parent
event.ParentId = "" // populate fields as required from parent

// Remove unnecessary fields from span event
if event.Service != nil {
event.Service.Target = nil
event.Service.Origin = nil
}

event.Timestamp = modelpb.FromTime(spanEvent.Timestamp().AsTime().Add(timeDelta))

isJaeger := strings.HasPrefix(parent.Agent.Name, "Jaeger")
Expand Down

0 comments on commit 44e3a29

Please sign in to comment.