From 33f64fd200cc57bd4f74154b0098bd97f26ca6f4 Mon Sep 17 00:00:00 2001 From: Carlos Crespo Date: Mon, 30 Dec 2024 13:50:48 +0100 Subject: [PATCH] [APM Fix missing error.culprit (#205242) fixes [#205240](https://github.com/elastic/kibana/issues/205240) ## Summary Fixes the issue where `error.culprit` is always missing. image image ### How to test - Run `simple_trace` synthtrace scenario - Run the request below
POST logs-apm.error-default/_doc ``` POST logs-apm.error-default/_doc { "container": { "id": "80cc20ecab1b57865d7aca0f66ab75a0c6ec2c51f7c53da04a8540215369c359" }, "kubernetes": { "node": { "name": "ip-192-168-55-136.ec2.internal" }, "pod": { "uid": "9bbfe3dc-dace-4638-b8f5-aa6ccf435cbe", "name": "otel-demo-green-3-cartservice-5d5ccc86dd-gcxtr" }, "namespace": "otel-demo-green-3" }, "parent": { "id": "f39639f56a540e0e" }, "agent": { "name": "opentelemetry/dotnet", "version": "1.6.0" }, "source": { "port": 35136, "ip": "::ffff:192.168.50.132" }, "error": { "exception": [ { "handled": true, "message": "Exception (plain, .NET) without culprit", "type": "Grpc.Core.RpcException" } ], "culprit": "culprit msg", // remove to test the N/A scenario "id": "60674e9b23c8b06d83889e63ffe82c1c", //change the id on every run "stack_trace": "Grpc.Core.RpcException: Status(StatusCode=\"FailedPrecondition\", Detail=\"Can't access cart storage. System.ApplicationException: Wasn't able to connect to redis\n at cartservice.cartstore.RedisCartStore.EnsureRedisConnected() in /usr/src/app/src/cartstore/RedisCartStore.cs:line 79\n at cartservice.cartstore.RedisCartStore.EmptyCartAsync(String userId) in /usr/src/app/src/cartstore/RedisCartStore.cs:line 157\")\n at cartservice.cartstore.RedisCartStore.EmptyCartAsync(String userId) in /usr/src/app/src/cartstore/RedisCartStore.cs:line 166\n at cartservice.services.CartService.EmptyCart(EmptyCartRequest request, ServerCallContext context) in /usr/src/app/src/services/CartService.cs:line 65", "grouping_key": "6082c58afd7fa6838ebc27eef6e04829" }, "message": "Exception (plain, .NET)", "url": { "path": "/oteldemo.CartService/EmptyCart", "original": "http://otel-demo-green-3-cartservice:8080/oteldemo.CartService/EmptyCart", "scheme": "http", "port": 8080, "domain": "otel-demo-green-3-cartservice", "full": "http://otel-demo-green-3-cartservice:8080/oteldemo.CartService/EmptyCart" }, "labels": { "k8s_pod_ip": "192.168.62.174", "k8s_pod_start_time": "2024-12-17T02:55:54Z", "service_namespace": "opentelemetry-demo", "k8s_deployment_name": "otel-demo-green-3-cartservice" }, "observer": { "hostname": "450fbf7ab701", "type": "apm-server", "version": "8.13.2" }, "trace": { "id": "699f6d1039fc873191a1c983790db3a2" }, "@timestamp": "2024-12-30T10:30:00.000Z", "data_stream": { "namespace": "default", "type": "logs", "dataset": "apm.error" }, "service": { "node": { "name": "80cc20ecab1b57865d7aca0f66ab75a0c6ec2c51f7c53da04a8540215369c359" }, "framework": { "name": "Microsoft.AspNetCore" }, "name": "synth-node-0", "language": { "name": "dotnet" } }, "host": { "hostname": "ip-192-168-55-136.ec2.internal", "name": "ip-192-168-55-136.ec2.internal" }, "client": { "port": 35136, "ip": "::ffff:192.168.50.132" }, "http": { "request": { "method": "POST" }, "response": { "status_code": 200 }, "version": "2" }, "event": { "agent_id_status": "missing", "ingested": "2024-12-18T18:04:22Z" }, "transaction": { "id": "f39639f56a540e0e", "type": "request", "sampled": true }, "user_agent": { "original": "grpc-go/1.59.0", "name": "Other", "device": { "name": "Other" } }, "span": { "id": "f39639f56a540e0e" }, "timestamp": { "us": 1704892605838000 } } ```
(cherry picked from commit 12608c3659a2aaea702c1d341bd0fab30f968056) --- .../errors/get_error_groups/get_error_sample_details.ts | 2 ++ .../apis/observability/apm/mobile/errors/generate_data.ts | 6 +++++- .../apm/mobile/errors/group_id_samples.spec.ts | 4 ++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/x-pack/solutions/observability/plugins/apm/server/routes/errors/get_error_groups/get_error_sample_details.ts b/x-pack/solutions/observability/plugins/apm/server/routes/errors/get_error_groups/get_error_sample_details.ts index 954086ee53084..2ea8605789acc 100644 --- a/x-pack/solutions/observability/plugins/apm/server/routes/errors/get_error_groups/get_error_sample_details.ts +++ b/x-pack/solutions/observability/plugins/apm/server/routes/errors/get_error_groups/get_error_sample_details.ts @@ -13,6 +13,7 @@ import { AGENT_NAME, AGENT_VERSION, AT_TIMESTAMP, + ERROR_CULPRIT, ERROR_EXCEPTION, ERROR_GROUP_ID, ERROR_ID, @@ -82,6 +83,7 @@ export async function getErrorSampleDetails({ SPAN_ID, AGENT_VERSION, PROCESSOR_NAME, + ERROR_CULPRIT, ERROR_STACK_TRACE, ERROR_EXC_MESSAGE, ERROR_EXC_HANDLED, diff --git a/x-pack/test/api_integration/deployment_agnostic/apis/observability/apm/mobile/errors/generate_data.ts b/x-pack/test/api_integration/deployment_agnostic/apis/observability/apm/mobile/errors/generate_data.ts index c1ae372335824..1db1e4388a197 100644 --- a/x-pack/test/api_integration/deployment_agnostic/apis/observability/apm/mobile/errors/generate_data.ts +++ b/x-pack/test/api_integration/deployment_agnostic/apis/observability/apm/mobile/errors/generate_data.ts @@ -59,7 +59,11 @@ export async function generateData({ .transaction({ transactionName: transaction.name }) .errors( serviceGoProdInstance - .error({ message: `Error ${index}`, type: transaction.name }) + .error({ + message: `Error ${index}`, + type: transaction.name, + culprit: `Error culprit ${index}`, + }) .timestamp(timestamp) ) .duration(1000) diff --git a/x-pack/test/api_integration/deployment_agnostic/apis/observability/apm/mobile/errors/group_id_samples.spec.ts b/x-pack/test/api_integration/deployment_agnostic/apis/observability/apm/mobile/errors/group_id_samples.spec.ts index 6e5a19327c24f..f50f762c5c075 100644 --- a/x-pack/test/api_integration/deployment_agnostic/apis/observability/apm/mobile/errors/group_id_samples.spec.ts +++ b/x-pack/test/api_integration/deployment_agnostic/apis/observability/apm/mobile/errors/group_id_samples.spec.ts @@ -134,6 +134,10 @@ export default function ApiTest({ getService }: DeploymentAgnosticFtrProviderCon 'Error 1' ); }); + + it('displays correct error culprit info', () => { + expect(errorSampleDetailsResponse.error.error.culprit).to.equal('Error culprit 1'); + }); }); });