From e9d78306e26d311db25f4076cb5035cf7a0d6066 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaras=C5=82a=C5=AD=20Viktor=C4=8Dyk?= Date: Thu, 21 Jul 2022 20:10:43 +0200 Subject: [PATCH] refactor(fetch): revert to original code in endSpanOnSuccess --- .../src/fetch.ts | 21 +++++++------------ 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/experimental/packages/opentelemetry-instrumentation-fetch/src/fetch.ts b/experimental/packages/opentelemetry-instrumentation-fetch/src/fetch.ts index 37ff62e234..f30c185bce 100644 --- a/experimental/packages/opentelemetry-instrumentation-fetch/src/fetch.ts +++ b/experimental/packages/opentelemetry-instrumentation-fetch/src/fetch.ts @@ -321,22 +321,15 @@ export class FetchInstrumentation extends InstrumentationBase> function endSpanOnSuccess(span: api.Span, response: Response) { plugin._applyAttributesAfterFetch(span, options, response); - const spanResponse = { - status: response.status, - statusText: response.statusText, - headers: response.headers, - url - }; if (response.status >= 200 && response.status < 400) { - if (response.url != null && response.url !== '') { - spanResponse.url = url; - } + plugin._endSpan(span, spanData, response); + } else { + plugin._endSpan(span, spanData, { + status: response.status, + statusText: response.statusText, + url, + }); } - plugin._endSpan(span, spanData, { - status: response.status, - statusText: response.statusText, - url, - }); } function onSuccess(