Skip to content

Commit

Permalink
Merge pull request #4 from jennypavlova/fix-otel-error-correlation
Browse files Browse the repository at this point in the history
[APM][Otel] Errors: Add fallback to span id if the parent id is undefined
  • Loading branch information
crespocarlos authored Oct 14, 2024
2 parents 06ec4ef + 7e4e43e commit 7def09a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
TRACE_ID,
TRANSACTION_ID,
ERROR_STACK_TRACE,
SPAN_ID,
} from '../../../../common/es_fields/apm';
import { environmentQuery } from '../../../../common/utils/environment_query';
import { ApmDocumentType } from '../../../../common/document_type';
Expand Down Expand Up @@ -79,6 +80,7 @@ export async function getErrorSampleDetails({

const optionalFields = asMutableArray([
TRANSACTION_ID,
SPAN_ID,
AGENT_VERSION,
PROCESSOR_NAME,
ERROR_STACK_TRACE,
Expand Down Expand Up @@ -129,7 +131,7 @@ export async function getErrorSampleDetails({

const errorFromFields = unflattenKnownApmEventFields(hit.fields, requiredFields);

const transactionId = errorFromFields.transaction?.id;
const transactionId = errorFromFields.transaction?.id ?? errorFromFields.span?.id;
const traceId = errorFromFields.trace.id;

let transaction: Transaction | undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ export async function getTraceItems({

const waterfallErrorEvent: WaterfallError = {
...event,
parent: {
...event?.parent,
id: event?.parent?.id ?? event?.span?.id,
},
error: {
...(event.error ?? {}),
exception:
Expand Down

0 comments on commit 7def09a

Please sign in to comment.