From cf15f56e5acd5b242ffaf3c121144a6924581a4b Mon Sep 17 00:00:00 2001 From: Carson Ip Date: Fri, 27 Sep 2024 19:13:30 +0100 Subject: [PATCH] Fix log event.parent_id from otlp span event --- input/otlp/exceptions_test.go | 4 +++- input/otlp/traces.go | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/input/otlp/exceptions_test.go b/input/otlp/exceptions_test.go index f15193fc..e73bf25c 100644 --- a/input/otlp/exceptions_test.go +++ b/input/otlp/exceptions_test.go @@ -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) { diff --git a/input/otlp/traces.go b/input/otlp/traces.go index a996a8f7..664df40d 100644 --- a/input/otlp/traces.go +++ b/input/otlp/traces.go @@ -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 } }