@opentelemetry/instrumentation-fetch
Advanced tools
Comparing version
@@ -230,14 +230,47 @@ /* | ||
var spanData = plugin._prepareSpanData(url); | ||
function endSpanOnError(span, error) { | ||
plugin._applyAttributesAfterFetch(span, options, error); | ||
plugin._endSpan(span, spanData, { | ||
status: error.status || 0, | ||
statusText: error.message, | ||
url: url, | ||
}); | ||
} | ||
function endSpanOnSuccess(span, response) { | ||
plugin._applyAttributesAfterFetch(span, options, response); | ||
if (response.status >= 200 && response.status < 400) { | ||
plugin._endSpan(span, spanData, response); | ||
} | ||
else { | ||
plugin._endSpan(span, spanData, { | ||
status: response.status, | ||
statusText: response.statusText, | ||
url: url, | ||
}); | ||
} | ||
} | ||
function onSuccess(span, resolve, response) { | ||
try { | ||
plugin._applyAttributesAfterFetch(span, options, response); | ||
if (response.status >= 200 && response.status < 400) { | ||
plugin._endSpan(span, spanData, response); | ||
var resClone = response.clone(); | ||
var body = resClone.body; | ||
if (body) { | ||
var reader_1 = body.getReader(); | ||
var read_1 = function () { | ||
reader_1.read().then(function (_a) { | ||
var done = _a.done; | ||
if (done) { | ||
endSpanOnSuccess(span, response); | ||
} | ||
else { | ||
read_1(); | ||
} | ||
}, function (error) { | ||
endSpanOnError(span, error); | ||
}); | ||
}; | ||
read_1(); | ||
} | ||
else { | ||
plugin._endSpan(span, spanData, { | ||
status: response.status, | ||
statusText: response.statusText, | ||
url: url, | ||
}); | ||
// some older browsers don't have .body implemented | ||
endSpanOnSuccess(span, response); | ||
} | ||
@@ -251,8 +284,3 @@ } | ||
try { | ||
plugin._applyAttributesAfterFetch(span, options, error); | ||
plugin._endSpan(span, spanData, { | ||
status: error.status || 0, | ||
statusText: error.message, | ||
url: url, | ||
}); | ||
endSpanOnError(span, error); | ||
} | ||
@@ -259,0 +287,0 @@ finally { |
@@ -210,14 +210,46 @@ "use strict"; | ||
const spanData = plugin._prepareSpanData(url); | ||
function endSpanOnError(span, error) { | ||
plugin._applyAttributesAfterFetch(span, options, error); | ||
plugin._endSpan(span, spanData, { | ||
status: error.status || 0, | ||
statusText: error.message, | ||
url, | ||
}); | ||
} | ||
function endSpanOnSuccess(span, response) { | ||
plugin._applyAttributesAfterFetch(span, options, response); | ||
if (response.status >= 200 && response.status < 400) { | ||
plugin._endSpan(span, spanData, response); | ||
} | ||
else { | ||
plugin._endSpan(span, spanData, { | ||
status: response.status, | ||
statusText: response.statusText, | ||
url, | ||
}); | ||
} | ||
} | ||
function onSuccess(span, resolve, response) { | ||
try { | ||
plugin._applyAttributesAfterFetch(span, options, response); | ||
if (response.status >= 200 && response.status < 400) { | ||
plugin._endSpan(span, spanData, response); | ||
const resClone = response.clone(); | ||
const body = resClone.body; | ||
if (body) { | ||
const reader = body.getReader(); | ||
const read = () => { | ||
reader.read().then(({ done }) => { | ||
if (done) { | ||
endSpanOnSuccess(span, response); | ||
} | ||
else { | ||
read(); | ||
} | ||
}, error => { | ||
endSpanOnError(span, error); | ||
}); | ||
}; | ||
read(); | ||
} | ||
else { | ||
plugin._endSpan(span, spanData, { | ||
status: response.status, | ||
statusText: response.statusText, | ||
url, | ||
}); | ||
// some older browsers don't have .body implemented | ||
endSpanOnSuccess(span, response); | ||
} | ||
@@ -231,8 +263,3 @@ } | ||
try { | ||
plugin._applyAttributesAfterFetch(span, options, error); | ||
plugin._endSpan(span, spanData, { | ||
status: error.status || 0, | ||
statusText: error.message, | ||
url, | ||
}); | ||
endSpanOnError(span, error); | ||
} | ||
@@ -239,0 +266,0 @@ finally { |
{ | ||
"name": "@opentelemetry/instrumentation-fetch", | ||
"version": "0.19.1-alpha.29+e379e59c", | ||
"version": "0.19.1-alpha.30+cc44db13", | ||
"description": "OpenTelemetry fetch automatic instrumentation package.", | ||
@@ -53,3 +53,3 @@ "main": "build/src/index.js", | ||
"@opentelemetry/propagator-b3": "^0.19.0", | ||
"@opentelemetry/tracing": "^0.19.1-alpha.29+e379e59c", | ||
"@opentelemetry/tracing": "^0.19.0", | ||
"@types/mocha": "8.2.2", | ||
@@ -89,5 +89,5 @@ "@types/node": "14.14.43", | ||
"@opentelemetry/semantic-conventions": "^0.19.0", | ||
"@opentelemetry/web": "^0.19.1-alpha.29+e379e59c" | ||
"@opentelemetry/web": "^0.19.0" | ||
}, | ||
"gitHead": "e379e59c1a2490053be16d0ca8aeb1c99d786a4c" | ||
"gitHead": "cc44db13c65043d1b1d90f70c2265620be31771c" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
82411
4.86%1145
5.05%+ Added
+ Added
- Removed
- Removed
- Removed
Updated