@opentelemetry/instrumentation-fetch
Advanced tools
Comparing version 0.54.2 to 0.55.0
@@ -23,2 +23,4 @@ import * as api from '@opentelemetry/api'; | ||
ignoreNetworkEvents?: boolean; | ||
/** Measure outgoing request size */ | ||
measureRequestSize?: boolean; | ||
} | ||
@@ -25,0 +27,0 @@ /** |
@@ -31,2 +31,27 @@ /* | ||
})(); | ||
var __read = (this && this.__read) || function (o, n) { | ||
var m = typeof Symbol === "function" && o[Symbol.iterator]; | ||
if (!m) return o; | ||
var i = m.call(o), r, ar = [], e; | ||
try { | ||
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); | ||
} | ||
catch (error) { e = { error: error }; } | ||
finally { | ||
try { | ||
if (r && !r.done && (m = i["return"])) m.call(i); | ||
} | ||
finally { if (e) throw e.error; } | ||
} | ||
return ar; | ||
}; | ||
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { | ||
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { | ||
if (ar || !(i in from)) { | ||
if (!ar) ar = Array.prototype.slice.call(from, 0, i); | ||
ar[i] = from[i]; | ||
} | ||
} | ||
return to.concat(ar || Array.prototype.slice.call(from)); | ||
}; | ||
var _a; | ||
@@ -38,3 +63,4 @@ import * as api from '@opentelemetry/api'; | ||
import { AttributeNames } from './enums/AttributeNames'; | ||
import { SEMATTRS_HTTP_STATUS_CODE, SEMATTRS_HTTP_HOST, SEMATTRS_HTTP_USER_AGENT, SEMATTRS_HTTP_SCHEME, SEMATTRS_HTTP_URL, SEMATTRS_HTTP_METHOD, } from '@opentelemetry/semantic-conventions'; | ||
import { SEMATTRS_HTTP_STATUS_CODE, SEMATTRS_HTTP_HOST, SEMATTRS_HTTP_USER_AGENT, SEMATTRS_HTTP_SCHEME, SEMATTRS_HTTP_URL, SEMATTRS_HTTP_METHOD, SEMATTRS_HTTP_REQUEST_CONTENT_LENGTH_UNCOMPRESSED, } from '@opentelemetry/semantic-conventions'; | ||
import { getFetchBodyLength } from './utils'; | ||
import { VERSION } from './version'; | ||
@@ -245,2 +271,12 @@ import { _globalThis } from '@opentelemetry/core'; | ||
var spanData = plugin._prepareSpanData(url); | ||
if (plugin.getConfig().measureRequestSize) { | ||
getFetchBodyLength.apply(void 0, __spreadArray([], __read(args), false)).then(function (length) { | ||
if (!length) | ||
return; | ||
createdSpan.setAttribute(SEMATTRS_HTTP_REQUEST_CONTENT_LENGTH_UNCOMPRESSED, length); | ||
}) | ||
.catch(function (error) { | ||
plugin._diag.warn('getFetchBodyLength', error); | ||
}); | ||
} | ||
function endSpanOnError(span, error) { | ||
@@ -247,0 +283,0 @@ plugin._applyAttributesAfterFetch(span, options, error); |
@@ -1,2 +0,2 @@ | ||
export declare const VERSION = "0.54.2"; | ||
export declare const VERSION = "0.55.0"; | ||
//# sourceMappingURL=version.d.ts.map |
@@ -17,3 +17,3 @@ /* | ||
// this is autogenerated file, see scripts/version-update.js | ||
export var VERSION = '0.54.2'; | ||
export var VERSION = '0.55.0'; | ||
//# sourceMappingURL=version.js.map |
@@ -23,2 +23,4 @@ import * as api from '@opentelemetry/api'; | ||
ignoreNetworkEvents?: boolean; | ||
/** Measure outgoing request size */ | ||
measureRequestSize?: boolean; | ||
} | ||
@@ -25,0 +27,0 @@ /** |
@@ -22,3 +22,4 @@ /* | ||
import { AttributeNames } from './enums/AttributeNames'; | ||
import { SEMATTRS_HTTP_STATUS_CODE, SEMATTRS_HTTP_HOST, SEMATTRS_HTTP_USER_AGENT, SEMATTRS_HTTP_SCHEME, SEMATTRS_HTTP_URL, SEMATTRS_HTTP_METHOD, } from '@opentelemetry/semantic-conventions'; | ||
import { SEMATTRS_HTTP_STATUS_CODE, SEMATTRS_HTTP_HOST, SEMATTRS_HTTP_USER_AGENT, SEMATTRS_HTTP_SCHEME, SEMATTRS_HTTP_URL, SEMATTRS_HTTP_METHOD, SEMATTRS_HTTP_REQUEST_CONTENT_LENGTH_UNCOMPRESSED, } from '@opentelemetry/semantic-conventions'; | ||
import { getFetchBodyLength } from './utils'; | ||
import { VERSION } from './version'; | ||
@@ -218,2 +219,13 @@ import { _globalThis } from '@opentelemetry/core'; | ||
const spanData = plugin._prepareSpanData(url); | ||
if (plugin.getConfig().measureRequestSize) { | ||
getFetchBodyLength(...args) | ||
.then(length => { | ||
if (!length) | ||
return; | ||
createdSpan.setAttribute(SEMATTRS_HTTP_REQUEST_CONTENT_LENGTH_UNCOMPRESSED, length); | ||
}) | ||
.catch(error => { | ||
plugin._diag.warn('getFetchBodyLength', error); | ||
}); | ||
} | ||
function endSpanOnError(span, error) { | ||
@@ -220,0 +232,0 @@ plugin._applyAttributesAfterFetch(span, options, error); |
@@ -1,2 +0,2 @@ | ||
export declare const VERSION = "0.54.2"; | ||
export declare const VERSION = "0.55.0"; | ||
//# sourceMappingURL=version.d.ts.map |
@@ -17,3 +17,3 @@ /* | ||
// this is autogenerated file, see scripts/version-update.js | ||
export const VERSION = '0.54.2'; | ||
export const VERSION = '0.55.0'; | ||
//# sourceMappingURL=version.js.map |
@@ -23,2 +23,4 @@ import * as api from '@opentelemetry/api'; | ||
ignoreNetworkEvents?: boolean; | ||
/** Measure outgoing request size */ | ||
measureRequestSize?: boolean; | ||
} | ||
@@ -25,0 +27,0 @@ /** |
@@ -26,2 +26,3 @@ "use strict"; | ||
const semantic_conventions_1 = require("@opentelemetry/semantic-conventions"); | ||
const utils_1 = require("./utils"); | ||
const version_1 = require("./version"); | ||
@@ -221,2 +222,13 @@ const core_1 = require("@opentelemetry/core"); | ||
const spanData = plugin._prepareSpanData(url); | ||
if (plugin.getConfig().measureRequestSize) { | ||
(0, utils_1.getFetchBodyLength)(...args) | ||
.then(length => { | ||
if (!length) | ||
return; | ||
createdSpan.setAttribute(semantic_conventions_1.SEMATTRS_HTTP_REQUEST_CONTENT_LENGTH_UNCOMPRESSED, length); | ||
}) | ||
.catch(error => { | ||
plugin._diag.warn('getFetchBodyLength', error); | ||
}); | ||
} | ||
function endSpanOnError(span, error) { | ||
@@ -223,0 +235,0 @@ plugin._applyAttributesAfterFetch(span, options, error); |
@@ -1,2 +0,2 @@ | ||
export declare const VERSION = "0.54.2"; | ||
export declare const VERSION = "0.55.0"; | ||
//# sourceMappingURL=version.d.ts.map |
@@ -20,3 +20,3 @@ "use strict"; | ||
// this is autogenerated file, see scripts/version-update.js | ||
exports.VERSION = '0.54.2'; | ||
exports.VERSION = '0.55.0'; | ||
//# sourceMappingURL=version.js.map |
{ | ||
"name": "@opentelemetry/instrumentation-fetch", | ||
"version": "0.54.2", | ||
"version": "0.55.0", | ||
"description": "OpenTelemetry instrumentation for fetch http client in web browsers", | ||
@@ -57,9 +57,9 @@ "main": "build/src/index.js", | ||
"devDependencies": { | ||
"@babel/core": "7.25.2", | ||
"@babel/preset-env": "7.25.4", | ||
"@babel/core": "7.26.0", | ||
"@babel/preset-env": "7.26.0", | ||
"@opentelemetry/api": "1.9.0", | ||
"@opentelemetry/context-zone": "1.27.0", | ||
"@opentelemetry/propagator-b3": "1.27.0", | ||
"@opentelemetry/sdk-trace-base": "1.27.0", | ||
"@types/mocha": "10.0.8", | ||
"@opentelemetry/context-zone": "1.28.0", | ||
"@opentelemetry/propagator-b3": "1.28.0", | ||
"@opentelemetry/sdk-trace-base": "1.28.0", | ||
"@types/mocha": "10.0.9", | ||
"@types/node": "18.6.5", | ||
@@ -78,3 +78,3 @@ "@types/sinon": "17.0.3", | ||
"lerna": "6.6.2", | ||
"mocha": "10.7.3", | ||
"mocha": "10.8.2", | ||
"nyc": "15.1.0", | ||
@@ -84,3 +84,3 @@ "sinon": "15.1.2", | ||
"typescript": "4.4.4", | ||
"webpack": "5.94.0", | ||
"webpack": "5.96.1", | ||
"webpack-cli": "5.1.4", | ||
@@ -93,5 +93,5 @@ "webpack-merge": "5.10.0" | ||
"dependencies": { | ||
"@opentelemetry/core": "1.27.0", | ||
"@opentelemetry/instrumentation": "0.54.2", | ||
"@opentelemetry/sdk-trace-web": "1.27.0", | ||
"@opentelemetry/core": "1.28.0", | ||
"@opentelemetry/instrumentation": "0.55.0", | ||
"@opentelemetry/sdk-trace-web": "1.28.0", | ||
"@opentelemetry/semantic-conventions": "1.27.0" | ||
@@ -101,3 +101,3 @@ }, | ||
"sideEffects": false, | ||
"gitHead": "72c9af91983e4b7aade98c901bd45c6cefee0da4" | ||
"gitHead": "4b1ad3fda0cde58907e30fab25c3c767546708e5" | ||
} |
@@ -29,6 +29,6 @@ # OpenTelemetry Fetch Instrumentation for web | ||
const provider = new WebTracerProvider(); | ||
const provider = new WebTracerProvider({ | ||
spanProcessors: [new SimpleSpanProcessor(new ConsoleSpanExporter())] | ||
}); | ||
provider.addSpanProcessor(new SimpleSpanProcessor(new ConsoleSpanExporter())); | ||
provider.register({ | ||
@@ -44,3 +44,5 @@ contextManager: new ZoneContextManager(), | ||
const fetchInstrumentation = new FetchInstrumentation(); | ||
const provider = new WebTracerProvider(); | ||
const provider = new WebTracerProvider({ | ||
spanProcessors: [new SimpleSpanProcessor(new ConsoleSpanExporter())] | ||
}); | ||
provider.register({ | ||
@@ -51,5 +53,2 @@ contextManager: new ZoneContextManager(), | ||
provider.addSpanProcessor(new SimpleSpanProcessor(new ConsoleSpanExporter())); | ||
// and some test | ||
@@ -75,4 +74,5 @@ | ||
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------|-----------------------------------------------------------------------------------------| | ||
| [`applyCustomAttributesOnSpan`](https://github.com/open-telemetry/opentelemetry-js/blob/main/experimental/packages/opentelemetry-instrumentation-fetch/src/fetch.ts#L64) | `HttpCustomAttributeFunction` | Function for adding custom attributes | | ||
| [`ignoreNetworkEvents`](https://github.com/open-telemetry/opentelemetry-js/blob/main/experimental/packages/opentelemetry-instrumentation-fetch/src/fetch.ts#L67) | `boolean` | Disable network events being added as span events (network events are added by default) | | ||
| [`applyCustomAttributesOnSpan`](https://github.com/open-telemetry/opentelemetry-js/blob/main/experimental/packages/opentelemetry-instrumentation-fetch/src/fetch.ts#L75) | `HttpCustomAttributeFunction` | Function for adding custom attributes | | ||
| [`ignoreNetworkEvents`](https://github.com/open-telemetry/opentelemetry-js/blob/main/experimental/packages/opentelemetry-instrumentation-fetch/src/fetch.ts#L77) | `boolean` | Disable network events being added as span events (network events are added by default) | | ||
| [`measureRequestSize`](https://github.com/open-telemetry/opentelemetry-js/blob/main/experimental/packages/opentelemetry-instrumentation-fetch/src/fetch.ts#L79) | `boolean` | Measure outgoing request length (outgoing request length is not measured by default) | | ||
@@ -87,3 +87,3 @@ ## Semantic Conventions | ||
| ------------------------------------------- | ------------------------------------------------------------------------------ | | ||
| `http.status_code` | HTTP response status code | | ||
| `http.status_code` | HTTP response status code | | ||
| `http.host` | The value of the HTTP host header | | ||
@@ -94,2 +94,3 @@ | `http.user_agent` | Value of the HTTP User-Agent header sent by the client | | ||
| `http.method` | HTTP request method | | ||
| `http.request_content_length_uncompressed` | Uncompressed size of the request body, if any body exists | | ||
@@ -96,0 +97,0 @@ ## Useful links |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
239776
57
2469
106
+ Added@opentelemetry/api-logs@0.55.0(transitive)
+ Added@opentelemetry/core@1.28.0(transitive)
+ Added@opentelemetry/instrumentation@0.55.0(transitive)
+ Added@opentelemetry/resources@1.28.0(transitive)
+ Added@opentelemetry/sdk-trace-base@1.28.0(transitive)
+ Added@opentelemetry/sdk-trace-web@1.28.0(transitive)
- Removed@opentelemetry/api-logs@0.54.2(transitive)
- Removed@opentelemetry/core@1.27.0(transitive)
- Removed@opentelemetry/instrumentation@0.54.2(transitive)
- Removed@opentelemetry/resources@1.27.0(transitive)
- Removed@opentelemetry/sdk-trace-base@1.27.0(transitive)
- Removed@opentelemetry/sdk-trace-web@1.27.0(transitive)
Updated@opentelemetry/core@1.28.0