Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[APM][Otel] Errors: Add fallback to span id if the parent id is undefined #4

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is needed because the otel errors don't have transaction.id but they have span.id (for APM those 2 are the same based on my testing with the PoC data/otel demo)

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
Loading