diff --git a/input/elasticapm/internal/modeldecoder/v2/span_test.go b/input/elasticapm/internal/modeldecoder/v2/span_test.go index 82ed6852..520bc923 100644 --- a/input/elasticapm/internal/modeldecoder/v2/span_test.go +++ b/input/elasticapm/internal/modeldecoder/v2/span_test.go @@ -174,9 +174,16 @@ func TestDecodeMapToSpanModel(t *testing.T) { assert.Equal(t, "failure", out.Event.Outcome) // derive from other fields - unknown input.Outcome.Reset() + input.OTel.Reset() input.Context.HTTP.StatusCode.Reset() mapToSpanModel(&input, &out) assert.Equal(t, "unknown", out.Event.Outcome) + // outcome is success when not assigned and it's otel + input.Outcome.Reset() + input.OTel.SpanKind.Set(spanKindInternal) + input.Context.HTTP.StatusCode.Reset() + mapToSpanModel(&input, &out) + assert.Equal(t, "success", out.Event.Outcome) }) t.Run("timestamp", func(t *testing.T) { diff --git a/input/elasticapm/internal/modeldecoder/v2/transaction_test.go b/input/elasticapm/internal/modeldecoder/v2/transaction_test.go index 03899501..662071f7 100644 --- a/input/elasticapm/internal/modeldecoder/v2/transaction_test.go +++ b/input/elasticapm/internal/modeldecoder/v2/transaction_test.go @@ -423,9 +423,16 @@ func TestDecodeMapToTransactionModel(t *testing.T) { assert.Equal(t, "failure", out.Event.Outcome) // derive from other fields - unknown input.Outcome.Reset() + input.OTel.Reset() input.Context.Response.StatusCode.Reset() mapToTransactionModel(&input, &out) assert.Equal(t, "unknown", out.Event.Outcome) + // outcome is success when not assigned and it's otel + input.Outcome.Reset() + input.OTel.SpanKind.Set(spanKindInternal) + input.Context.Response.StatusCode.Reset() + mapToTransactionModel(&input, &out) + assert.Equal(t, "success", out.Event.Outcome) }) t.Run("session", func(t *testing.T) { diff --git a/input/otlp/test_approved/jaeger_sampling_rate.approved.json b/input/otlp/test_approved/jaeger_sampling_rate.approved.json index 140a7ced..636cc749 100644 --- a/input/otlp/test_approved/jaeger_sampling_rate.approved.json +++ b/input/otlp/test_approved/jaeger_sampling_rate.approved.json @@ -8,7 +8,7 @@ }, "event": { "duration": 79000000000, - "outcome": "unknown" + "outcome": "success" }, "host": { "hostname": "host-abc" @@ -24,6 +24,7 @@ }, "transaction": { "representative_count": 1.25, + "result": "Success", "sampled": true, "type": "unknown" } @@ -36,7 +37,7 @@ }, "event": { "duration": 79000000000, - "outcome": "unknown" + "outcome": "success" }, "host": { "hostname": "host-abc" @@ -69,7 +70,7 @@ }, "event": { "duration": 79000000000, - "outcome": "unknown" + "outcome": "success" }, "host": { "hostname": "host-abc" @@ -91,6 +92,7 @@ }, "transaction": { "sampled": true, + "result": "Success", "type": "unknown" } }, @@ -102,7 +104,7 @@ }, "event": { "duration": 79000000000, - "outcome": "unknown" + "outcome": "success" }, "host": { "hostname": "host-abc" diff --git a/input/otlp/test_approved/metadata_jaeger-no-language.approved.json b/input/otlp/test_approved/metadata_jaeger-no-language.approved.json index 4b4649f6..1cc29194 100644 --- a/input/otlp/test_approved/metadata_jaeger-no-language.approved.json +++ b/input/otlp/test_approved/metadata_jaeger-no-language.approved.json @@ -7,7 +7,7 @@ "version": "3.4.12" }, "event": { - "outcome": "unknown" + "outcome": "success" }, "service": { "language": { @@ -28,6 +28,7 @@ "id": "0000000041414646", "representative_count": 1, "sampled": true, + "result": "Success", "type": "unknown" } } diff --git a/input/otlp/test_approved/metadata_jaeger-version.approved.json b/input/otlp/test_approved/metadata_jaeger-version.approved.json index be4cd67c..fb933ac8 100644 --- a/input/otlp/test_approved/metadata_jaeger-version.approved.json +++ b/input/otlp/test_approved/metadata_jaeger-version.approved.json @@ -7,7 +7,7 @@ "version": "3.4.12" }, "event": { - "outcome": "unknown" + "outcome": "success" }, "service": { "language": { @@ -28,6 +28,7 @@ "id": "0000000041414646", "representative_count": 1, "sampled": true, + "result": "Success", "type": "unknown" } } diff --git a/input/otlp/test_approved/metadata_jaeger.approved.json b/input/otlp/test_approved/metadata_jaeger.approved.json index 89494312..62201de1 100644 --- a/input/otlp/test_approved/metadata_jaeger.approved.json +++ b/input/otlp/test_approved/metadata_jaeger.approved.json @@ -8,7 +8,7 @@ "version": "3.2.1" }, "event": { - "outcome": "unknown" + "outcome": "success" }, "host": { "hostname": "host-foo", @@ -39,6 +39,7 @@ "id": "0000000041414646", "representative_count": 1, "sampled": true, + "result": "Success", "type": "unknown" } } diff --git a/input/otlp/test_approved/span_jaeger_custom.approved.json b/input/otlp/test_approved/span_jaeger_custom.approved.json index 95d6ff8b..6c387339 100644 --- a/input/otlp/test_approved/span_jaeger_custom.approved.json +++ b/input/otlp/test_approved/span_jaeger_custom.approved.json @@ -8,7 +8,7 @@ }, "event": { "duration": 79000000000, - "outcome": "unknown" + "outcome": "success" }, "host": { "hostname": "host-abc" diff --git a/input/otlp/test_approved/span_jaeger_db.approved.json b/input/otlp/test_approved/span_jaeger_db.approved.json index 5bba422b..570e8303 100644 --- a/input/otlp/test_approved/span_jaeger_db.approved.json +++ b/input/otlp/test_approved/span_jaeger_db.approved.json @@ -12,7 +12,7 @@ }, "event": { "duration": 79000000000, - "outcome": "unknown" + "outcome": "success" }, "host": { "hostname": "host-abc" diff --git a/input/otlp/test_approved/span_jaeger_https_default_port.approved.json b/input/otlp/test_approved/span_jaeger_https_default_port.approved.json index 5b82b4cf..bc5ce442 100644 --- a/input/otlp/test_approved/span_jaeger_https_default_port.approved.json +++ b/input/otlp/test_approved/span_jaeger_https_default_port.approved.json @@ -12,7 +12,7 @@ }, "event": { "duration": 79000000000, - "outcome": "unknown" + "outcome": "success" }, "host": { "hostname": "host-abc" diff --git a/input/otlp/test_approved/span_jaeger_messaging.approved.json b/input/otlp/test_approved/span_jaeger_messaging.approved.json index df4c74f7..fa347182 100644 --- a/input/otlp/test_approved/span_jaeger_messaging.approved.json +++ b/input/otlp/test_approved/span_jaeger_messaging.approved.json @@ -12,7 +12,7 @@ }, "event": { "duration": 79000000000, - "outcome": "unknown" + "outcome": "success" }, "host": { "hostname": "host-abc" diff --git a/input/otlp/test_approved/span_jaeger_subtype_component.approved.json b/input/otlp/test_approved/span_jaeger_subtype_component.approved.json index 204f7a00..b38b94c4 100644 --- a/input/otlp/test_approved/span_jaeger_subtype_component.approved.json +++ b/input/otlp/test_approved/span_jaeger_subtype_component.approved.json @@ -8,7 +8,7 @@ }, "event": { "duration": 79000000000, - "outcome": "unknown" + "outcome": "success" }, "host": { "hostname": "host-abc" diff --git a/input/otlp/test_approved/transaction_jaeger_custom.approved.json b/input/otlp/test_approved/transaction_jaeger_custom.approved.json index ce6650b3..0a73ecc0 100644 --- a/input/otlp/test_approved/transaction_jaeger_custom.approved.json +++ b/input/otlp/test_approved/transaction_jaeger_custom.approved.json @@ -7,7 +7,7 @@ "version": "unknown" }, "event": { - "outcome": "unknown" + "outcome": "success" }, "host": { "hostname": "host-abc" @@ -27,6 +27,7 @@ "transaction": { "representative_count": 1, "sampled": true, + "result": "Success", "type": "unknown" } } diff --git a/input/otlp/test_approved/transaction_jaeger_type_component.approved.json b/input/otlp/test_approved/transaction_jaeger_type_component.approved.json index 67e8638a..439aa67f 100644 --- a/input/otlp/test_approved/transaction_jaeger_type_component.approved.json +++ b/input/otlp/test_approved/transaction_jaeger_type_component.approved.json @@ -7,7 +7,7 @@ "version": "unknown" }, "event": { - "outcome": "unknown" + "outcome": "success" }, "host": { "hostname": "host-abc" @@ -27,6 +27,7 @@ "transaction": { "representative_count": 1, "sampled": true, + "result": "Success", "type": "unknown" } } diff --git a/input/otlp/test_approved/transaction_jaeger_type_messaging.approved.json b/input/otlp/test_approved/transaction_jaeger_type_messaging.approved.json index 6e07198d..d48f53fd 100644 --- a/input/otlp/test_approved/transaction_jaeger_type_messaging.approved.json +++ b/input/otlp/test_approved/transaction_jaeger_type_messaging.approved.json @@ -7,7 +7,7 @@ "version": "unknown" }, "event": { - "outcome": "unknown" + "outcome": "success" }, "host": { "hostname": "host-abc" @@ -31,6 +31,7 @@ } }, "representative_count": 1, + "result": "Success", "sampled": true, "type": "messaging" } diff --git a/input/otlp/traces.go b/input/otlp/traces.go index b9e33b75..533a1000 100644 --- a/input/otlp/traces.go +++ b/input/otlp/traces.go @@ -520,6 +520,14 @@ func TranslateTransaction( event.Service.Framework.Name = name event.Service.Framework.Version = library.Version() } + + // if outcome and result are still not assigned, assign success + if event.Event.Outcome == outcomeUnknown { + event.Event.Outcome = outcomeSuccess + if event.Transaction.Result == "" { + event.Transaction.Result = "Success" + } + } } // TranslateSpan converts incoming otlp/otel trace data into the @@ -945,6 +953,11 @@ func TranslateSpan(spanKind ptrace.SpanKind, attributes pcommon.Map, event *mode // The client has reported its sampling rate, so we can use it to extrapolate transaction metrics. parseSamplerAttributes(samplerType, samplerParam, event) } + + // if outcome is still not assigned, assign success + if event.Event.Outcome == outcomeUnknown { + event.Event.Outcome = outcomeSuccess + } } func parseSamplerAttributes(samplerType, samplerParam pcommon.Value, event *modelpb.APMEvent) { diff --git a/input/otlp/traces_test.go b/input/otlp/traces_test.go index a38f7ae7..c7951314 100644 --- a/input/otlp/traces_test.go +++ b/input/otlp/traces_test.go @@ -106,7 +106,7 @@ func TestOutcome(t *testing.T) { assert.Equal(t, expectedOutcome, (*batch)[1].GetEvent().GetOutcome()) } - test(t, "unknown", "", ptrace.StatusCodeUnset) + test(t, "success", "Success", ptrace.StatusCodeUnset) test(t, "success", "Success", ptrace.StatusCodeOk) test(t, "failure", "Error", ptrace.StatusCodeError) }