diff --git a/CHANGELOG.md b/CHANGELOG.md index 582e8f21c..566b40051 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +### Fixed + +- Error tracing spans not logging the details. + ## [6.45.21] - 2023-09-19 ### Changed - Fix tracingMiddleware shouldTrace decision diff --git a/src/HttpClient/middlewares/request/setupAxios/__tests__/axiosTracingTestSuite.ts b/src/HttpClient/middlewares/request/setupAxios/__tests__/axiosTracingTestSuite.ts index 31a7774ab..3caff4f58 100644 --- a/src/HttpClient/middlewares/request/setupAxios/__tests__/axiosTracingTestSuite.ts +++ b/src/HttpClient/middlewares/request/setupAxios/__tests__/axiosTracingTestSuite.ts @@ -167,7 +167,7 @@ export const registerSharedTestSuite = (testSuiteConfig: TestSuiteConfig) => { expect((requestSpan as any)._logs[len - 1].fields[ErrorReportLogFields.ERROR_ID]).toBeDefined() expect((requestSpan as any)._logs[len - 1].fields[ErrorReportLogFields.ERROR_KIND]).toBeDefined() expect( - ((requestSpan as any)._logs[len - 1].fields.error.message as string).startsWith( + ((requestSpan as any)._logs[len - 1].fields[ErrorReportLogFields.ERROR_MESSAGE] as string).startsWith( testSuiteConfig.expects.error!.errorMessagePrefix ) ).toBeTruthy() diff --git a/src/tracing/LogFields.ts b/src/tracing/LogFields.ts index c65b3c0ec..3de4b2e99 100644 --- a/src/tracing/LogFields.ts +++ b/src/tracing/LogFields.ts @@ -15,6 +15,11 @@ export const enum ErrorReportLogFields { */ ERROR_KIND = 'error.kind', ERROR_ID = 'error.id', + ERROR_MESSAGE = 'error.message', + ERROR_CODE = 'error.code', + ERROR_STACK = 'error.stack', + ERROR_METADATA_REPORT_COUNT = 'error.metadata.reportCount', + ERROR_METADATA_METRICS_INSTANTIATION_TIME = 'error.metadata.metrics.InstantiationTime', /** * VTEX's Infra errors adds error details to the response diff --git a/src/tracing/errorReporting/ErrorReport.ts b/src/tracing/errorReporting/ErrorReport.ts index 9446b835e..8d9866892 100644 --- a/src/tracing/errorReporting/ErrorReport.ts +++ b/src/tracing/errorReporting/ErrorReport.ts @@ -61,7 +61,15 @@ export class ErrorReport extends ErrorReportBase { } const serializableError = this.toObject() - span?.log({ event: 'error', ...indexedLogs, error: serializableError }) + span?.log({ + event: 'error', + ...indexedLogs, + [ErrorReportLogFields.ERROR_MESSAGE]: serializableError.message, + [ErrorReportLogFields.ERROR_METADATA_METRICS_INSTANTIATION_TIME]: serializableError.metadata?.reportCount, + [ErrorReportLogFields.ERROR_METADATA_REPORT_COUNT]: serializableError.metadata?.metrics?.instantiationTime, + [ErrorReportLogFields.ERROR_STACK]: serializableError.stack, + [ErrorReportLogFields.ERROR_CODE]: serializableError.code, + }) if (logger && this.shouldLogToSplunk(span)) { logger.error(serializableError)