Skip to content

Commit

Permalink
Fix log event.parent.id from otlp span event
Browse files Browse the repository at this point in the history
  • Loading branch information
carsonip committed Sep 27, 2024
1 parent 866967b commit 3e00737
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion input/otlp/exceptions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,12 @@ func TestEncodeSpanEventsNonExceptions(t *testing.T) {
semconv.AttributeExceptionStacktrace, "stacktrace",
)

_, events := transformTransactionSpanEvents(t, "java", nonExceptionEvent, incompleteExceptionEvent)
transactionEvent, events := transformTransactionSpanEvents(t, "java", nonExceptionEvent, incompleteExceptionEvent)
require.Len(t, events, 2)
assert.Equal(t, modelpb.LogEventType, events[0].Type())
assert.Equal(t, transactionEvent.Transaction.Id, events[0].ParentId)
assert.Equal(t, modelpb.LogEventType, events[1].Type())
assert.Equal(t, transactionEvent.Transaction.Id, events[1].ParentId)
}

func TestEncodeSpanEventsJavaExceptions(t *testing.T) {
Expand Down
2 changes: 2 additions & 0 deletions input/otlp/traces.go
Original file line number Diff line number Diff line change
Expand Up @@ -1265,10 +1265,12 @@ func setLogContext(out *modelpb.APMEvent, parent *modelpb.APMEvent) {
out.Transaction.Id = parent.Transaction.Id
out.Span = &modelpb.Span{}
out.Span.Id = parent.Transaction.Id
out.ParentId = parent.Transaction.Id
}
if parent.Span != nil {
out.Span = &modelpb.Span{}
out.Span.Id = parent.Span.Id
out.ParentId = parent.Span.Id
}
}

Expand Down

0 comments on commit 3e00737

Please sign in to comment.