From 73084b9b0f6dbbc327c2f7245f0be040cbdfc7d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mai=CC=81ra=20Bello?= Date: Tue, 10 Oct 2023 11:18:25 -0300 Subject: [PATCH] Add retry fields to the current span --- .../request/setupAxios/interceptors/exponentialBackoff.ts | 6 +++++- src/tracing/Tags.ts | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/HttpClient/middlewares/request/setupAxios/interceptors/exponentialBackoff.ts b/src/HttpClient/middlewares/request/setupAxios/interceptors/exponentialBackoff.ts index 94c869c0b..17c706841 100644 --- a/src/HttpClient/middlewares/request/setupAxios/interceptors/exponentialBackoff.ts +++ b/src/HttpClient/middlewares/request/setupAxios/interceptors/exponentialBackoff.ts @@ -3,7 +3,7 @@ import { HttpLogEvents } from '../../../../../tracing/LogEvents' import { HttpRetryLogFields } from '../../../../../tracing/LogFields' import { isAbortedOrNetworkErrorOrRouterTimeout } from '../../../../../utils/retry' import { RequestConfig } from '../../../../typings' -import { TraceableRequestConfig } from '../../../tracing' +import { CustomHttpTags } from '../../../../../tracing/Tags' function fixConfig(axiosInstance: AxiosInstance, config: RequestConfig) { if (axiosInstance.defaults.httpAgent === config.httpAgent) { @@ -66,6 +66,10 @@ const onResponseError = (http: AxiosInstance) => (error: any) => { config.transformRequest = [data => data] config.tracing?.rootSpan?.log({ event: HttpLogEvents.SETUP_REQUEST_RETRY, [HttpRetryLogFields.RETRY_NUMBER]: config.retryCount, [HttpRetryLogFields.RETRY_IN]: delay }) + config.tracing?.rootSpan?.addTags({ + [CustomHttpTags.HTTP_RETRY_COUNT]: config.retryCount, + [CustomHttpTags.HTTP_RETRY_ERROR_CODE]: error.code + }) return new Promise(resolve => setTimeout(() => resolve(http(config)), delay)) } diff --git a/src/tracing/Tags.ts b/src/tracing/Tags.ts index cdbe6524a..d6047f10b 100644 --- a/src/tracing/Tags.ts +++ b/src/tracing/Tags.ts @@ -69,6 +69,9 @@ export const enum CustomHttpTags { HTTP_MEMOIZATION_CACHE_RESULT = 'http.cache.memoization', HTTP_DISK_CACHE_RESULT = 'http.cache.disk', HTTP_ROUTER_CACHE_RESULT = 'http.cache.router', + + HTTP_RETRY_ERROR_CODE = 'http.retry.error.code', + HTTP_RETRY_COUNT = 'http.retry.count' } export const UserlandTags = {