New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@opentelemetry/instrumentation-xml-http-request

Package Overview
Dependencies
Maintainers
2
Versions
183
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@opentelemetry/instrumentation-xml-http-request - npm Package Compare versions

Comparing version 0.27.0 to 0.28.0

build/esnext/enums/AttributeNames.d.ts

2

build/esm/types.d.ts

@@ -9,3 +9,3 @@ import * as api from '@opentelemetry/api';

*/
export declare type SendFunction = (body?: SendBody) => void;
export declare type SendFunction = typeof XMLHttpRequest.prototype.send;
export declare type SendBody = string | Document | Blob | ArrayBufferView | ArrayBuffer | FormData | URLSearchParams | ReadableStream<Uint8Array> | null;

@@ -12,0 +12,0 @@ /**

@@ -1,2 +0,2 @@

export declare const VERSION = "0.27.0";
export declare const VERSION = "0.28.0";
//# sourceMappingURL=version.d.ts.map

@@ -17,3 +17,3 @@ /*

// this is autogenerated file, see scripts/version-update.js
export var VERSION = '0.27.0';
export var VERSION = '0.28.0';
//# sourceMappingURL=version.js.map

@@ -44,3 +44,3 @@ import * as api from '@opentelemetry/api';

* @param xhr
* @param span
* @param spanUrl
* @private

@@ -47,0 +47,0 @@ */

@@ -35,6 +35,11 @@ /*

import { SemanticAttributes } from '@opentelemetry/semantic-conventions';
import { addSpanNetworkEvents, getResource, parseUrl, PerformanceTimingNames as PTN, shouldPropagateTraceHeaders, getUrlNormalizingAnchor } from '@opentelemetry/sdk-trace-web';
import { addSpanNetworkEvents, getResource, PerformanceTimingNames as PTN, shouldPropagateTraceHeaders } from '@opentelemetry/sdk-trace-web';
import { EventNames } from './enums/EventNames';
import { VERSION } from './version';
import { AttributeNames } from './enums/AttributeNames';
function parseUrl(url) {
var element = document.createElement('a');
element.href = url;
return element;
}
// how long to wait for observer to collect information about resources

@@ -67,7 +72,8 @@ // this is needed as event "load" is called before observer

* @param xhr
* @param span
* @param spanUrl
* @private
*/
XMLHttpRequestInstrumentation.prototype._addHeaders = function (xhr, spanUrl) {
if (!shouldPropagateTraceHeaders(spanUrl, this._getConfig().propagateTraceHeaderCorsUrls)) {
var url = parseUrl(spanUrl).href;
if (!shouldPropagateTraceHeaders(url, this._getConfig().propagateTraceHeaderCorsUrls)) {
var headers_1 = {};

@@ -148,4 +154,4 @@ api.propagation.inject(api.context.active(), headers_1);

if (!xhrMem ||
typeof window.PerformanceObserver === 'undefined' ||
typeof window.PerformanceResourceTiming === 'undefined') {
PerformanceObserver == null ||
PerformanceResourceTiming == null) {
return;

@@ -156,7 +162,6 @@ }

var entries = list.getEntries();
var urlNormalizingAnchor = getUrlNormalizingAnchor();
urlNormalizingAnchor.href = spanUrl;
var parsedUrl = parseUrl(spanUrl);
entries.forEach(function (entry) {
if (entry.initiatorType === 'xmlhttprequest' &&
entry.name === urlNormalizingAnchor.href) {
entry.name === parsedUrl.href) {
if (xhrMem.createdResources) {

@@ -203,3 +208,3 @@ xhrMem.createdResources.entries.push(entry);

}
var resource = getResource(spanUrl, startTime, endTime, resources, this._usedResources);
var resource = getResource(parseUrl(spanUrl).href, startTime, endTime, resources, this._usedResources);
if (resource.mainRequest) {

@@ -206,0 +211,0 @@ var mainRequest = resource.mainRequest;

@@ -9,3 +9,3 @@ import * as api from '@opentelemetry/api';

*/
export declare type SendFunction = (body?: SendBody) => void;
export declare type SendFunction = typeof XMLHttpRequest.prototype.send;
export declare type SendBody = string | Document | Blob | ArrayBufferView | ArrayBuffer | FormData | URLSearchParams | ReadableStream<Uint8Array> | null;

@@ -12,0 +12,0 @@ /**

@@ -1,2 +0,2 @@

export declare const VERSION = "0.27.0";
export declare const VERSION = "0.28.0";
//# sourceMappingURL=version.d.ts.map

@@ -20,3 +20,3 @@ "use strict";

// this is autogenerated file, see scripts/version-update.js
exports.VERSION = '0.27.0';
exports.VERSION = '0.28.0';
//# sourceMappingURL=version.js.map

@@ -44,3 +44,3 @@ import * as api from '@opentelemetry/api';

* @param xhr
* @param span
* @param spanUrl
* @private

@@ -47,0 +47,0 @@ */

@@ -27,2 +27,7 @@ "use strict";

const AttributeNames_1 = require("./enums/AttributeNames");
function parseUrl(url) {
const element = document.createElement('a');
element.href = url;
return element;
}
// how long to wait for observer to collect information about resources

@@ -53,7 +58,8 @@ // this is needed as event "load" is called before observer

* @param xhr
* @param span
* @param spanUrl
* @private
*/
_addHeaders(xhr, spanUrl) {
if (!sdk_trace_web_1.shouldPropagateTraceHeaders(spanUrl, this._getConfig().propagateTraceHeaderCorsUrls)) {
const url = parseUrl(spanUrl).href;
if (!(0, sdk_trace_web_1.shouldPropagateTraceHeaders)(url, this._getConfig().propagateTraceHeaderCorsUrls)) {
const headers = {};

@@ -83,3 +89,3 @@ api.propagation.inject(api.context.active(), headers);

});
sdk_trace_web_1.addSpanNetworkEvents(childSpan, corsPreFlightRequest);
(0, sdk_trace_web_1.addSpanNetworkEvents)(childSpan, corsPreFlightRequest);
childSpan.end(corsPreFlightRequest[sdk_trace_web_1.PerformanceTimingNames.RESPONSE_END]);

@@ -97,3 +103,3 @@ });

if (typeof spanUrl === 'string') {
const parsedUrl = sdk_trace_web_1.parseUrl(spanUrl);
const parsedUrl = parseUrl(spanUrl);
if (xhrMem.status !== undefined) {

@@ -116,3 +122,3 @@ span.setAttribute(semantic_conventions_1.SemanticAttributes.HTTP_STATUS_CODE, xhrMem.status);

if (typeof applyCustomAttributesOnSpan === 'function') {
instrumentation_1.safeExecuteInTheMiddle(() => applyCustomAttributesOnSpan(span, xhr), error => {
(0, instrumentation_1.safeExecuteInTheMiddle)(() => applyCustomAttributesOnSpan(span, xhr), error => {
if (!error) {

@@ -135,4 +141,4 @@ return;

if (!xhrMem ||
typeof window.PerformanceObserver === 'undefined' ||
typeof window.PerformanceResourceTiming === 'undefined') {
PerformanceObserver == null ||
PerformanceResourceTiming == null) {
return;

@@ -143,7 +149,6 @@ }

const entries = list.getEntries();
const urlNormalizingAnchor = sdk_trace_web_1.getUrlNormalizingAnchor();
urlNormalizingAnchor.href = spanUrl;
const parsedUrl = parseUrl(spanUrl);
entries.forEach(entry => {
if (entry.initiatorType === 'xmlhttprequest' &&
entry.name === urlNormalizingAnchor.href) {
entry.name === parsedUrl.href) {
if (xhrMem.createdResources) {

@@ -190,3 +195,3 @@ xhrMem.createdResources.entries.push(entry);

}
const resource = sdk_trace_web_1.getResource(spanUrl, startTime, endTime, resources, this._usedResources);
const resource = (0, sdk_trace_web_1.getResource)(parseUrl(spanUrl).href, startTime, endTime, resources, this._usedResources);
if (resource.mainRequest) {

@@ -200,3 +205,3 @@ const mainRequest = resource.mainRequest;

}
sdk_trace_web_1.addSpanNetworkEvents(span, mainRequest);
(0, sdk_trace_web_1.addSpanNetworkEvents)(span, mainRequest);
}

@@ -228,3 +233,3 @@ }

_createSpan(xhr, url, method) {
if (core_1.isUrlIgnored(url, this._getConfig().ignoreUrls)) {
if ((0, core_1.isUrlIgnored)(url, this._getConfig().ignoreUrls)) {
this._diag.debug('ignoring span as url matches ignored url');

@@ -306,3 +311,3 @@ return;

}
const endTime = core_1.hrTime();
const endTime = (0, core_1.hrTime)();
// the timeout is needed as observer doesn't have yet information

@@ -353,3 +358,3 @@ // when event "load" is called. Also the time may differ depends on

plugin._tasksCount++;
xhrMem.sendStartTime = core_1.hrTime();
xhrMem.sendStartTime = (0, core_1.hrTime)();
currentSpan.addEvent(EventNames_1.EventNames.METHOD_SEND);

@@ -379,7 +384,7 @@ this.addEventListener('abort', onAbort);

this._diag.debug('applying patch to', this.moduleName, this.version);
if (instrumentation_1.isWrapped(XMLHttpRequest.prototype.open)) {
if ((0, instrumentation_1.isWrapped)(XMLHttpRequest.prototype.open)) {
this._unwrap(XMLHttpRequest.prototype, 'open');
this._diag.debug('removing previous patch from method open');
}
if (instrumentation_1.isWrapped(XMLHttpRequest.prototype.send)) {
if ((0, instrumentation_1.isWrapped)(XMLHttpRequest.prototype.send)) {
this._unwrap(XMLHttpRequest.prototype, 'send');

@@ -386,0 +391,0 @@ this._diag.debug('removing previous patch from method send');

{
"name": "@opentelemetry/instrumentation-xml-http-request",
"version": "0.27.0",
"version": "0.28.0",
"description": "OpenTelemetry XMLHttpRequest automatic instrumentation package.",
"main": "build/src/index.js",
"module": "build/esm/index.js",
"esnext": "build/esnext/index.js",
"types": "build/src/index.d.ts",
"repository": "open-telemetry/opentelemetry-js",
"scripts": {
"compile": "tsc --build tsconfig.json tsconfig.esm.json",
"clean": "tsc --build --clean tsconfig.json tsconfig.esm.json",
"prepublishOnly": "npm run compile",
"compile": "tsc --build tsconfig.all.json",
"clean": "tsc --build --clean tsconfig.all.json",
"lint": "eslint . --ext .ts",
"lint:fix": "eslint . --ext .ts --fix",
"codecov:browser": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../",
"codecov:browser": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../../",
"version": "node ../../../scripts/version-update.js",
"tdd": "karma start",
"test:browser": "nyc karma start --single-run",
"watch": "tsc --build --watch tsconfig.json tsconfig.esm.json",
"precompile": "lerna run version --scope $(npm pkg get name) --include-filtered-dependencies",
"prewatch": "node ../../../scripts/version-update.js"
"watch": "tsc --build --watch tsconfig.all.json",
"precompile": "lerna run version --scope $(npm pkg get name) --include-dependencies",
"prewatch": "node ../../../scripts/version-update.js",
"peer-api-check": "node ../../../scripts/peer-api-check.js"
},

@@ -34,3 +37,3 @@ "keywords": [

"engines": {
"node": ">=8.0.0"
"node": ">=8.12.0"
},

@@ -41,2 +44,5 @@ "files": [

"build/esm/**/*.d.ts",
"build/esnext/**/*.js",
"build/esnext/**/*.js.map",
"build/esnext/**/*.d.ts",
"build/src/**/*.js",

@@ -53,15 +59,15 @@ "build/src/**/*.js.map",

"devDependencies": {
"@babel/core": "7.15.0",
"@opentelemetry/api": "^1.0.3",
"@opentelemetry/context-zone": "1.0.1",
"@opentelemetry/propagator-b3": "1.0.1",
"@opentelemetry/sdk-trace-base": "1.0.1",
"@babel/core": "7.16.0",
"@opentelemetry/api": "^1.0.0",
"@opentelemetry/context-zone": "1.2.0",
"@opentelemetry/propagator-b3": "1.2.0",
"@opentelemetry/sdk-trace-base": "1.2.0",
"@types/mocha": "8.2.3",
"@types/node": "14.17.11",
"@types/sinon": "10.0.2",
"@types/webpack-env": "1.16.2",
"babel-loader": "8.2.2",
"@types/node": "14.17.33",
"@types/sinon": "10.0.6",
"@types/webpack-env": "1.16.3",
"babel-loader": "8.2.3",
"codecov": "3.8.3",
"istanbul-instrumenter-loader": "3.0.1",
"karma": "6.3.7",
"karma": "6.3.16",
"karma-chrome-launcher": "3.1.0",

@@ -78,5 +84,5 @@ "karma-coverage-istanbul-reporter": "3.0.3",

"ts-mocha": "8.0.0",
"typescript": "4.3.5",
"typescript": "4.4.4",
"webpack": "4.46.0",
"webpack-cli": "4.8.0",
"webpack-cli": "4.9.1",
"webpack-merge": "5.8.0"

@@ -88,8 +94,8 @@ },

"dependencies": {
"@opentelemetry/core": "1.0.1",
"@opentelemetry/instrumentation": "0.27.0",
"@opentelemetry/sdk-trace-web": "1.0.1",
"@opentelemetry/semantic-conventions": "1.0.1"
"@opentelemetry/core": "1.2.0",
"@opentelemetry/instrumentation": "0.28.0",
"@opentelemetry/sdk-trace-web": "1.2.0",
"@opentelemetry/semantic-conventions": "1.2.0"
},
"gitHead": "f5e227f0cb829df1ca2dc220a3e0e8ae0e607405"
"gitHead": "a0a670a03fd35b0799bee8cc466f79e93b5b6dd2"
}
# OpenTelemetry XMLHttpRequest Instrumentation for web
[![NPM Published Version][npm-img]][npm-url]
[![dependencies][dependencies-image]][dependencies-url]
[![devDependencies][devDependencies-image]][devDependencies-url]
[![Apache License][license-image]][license-image]

@@ -85,7 +83,3 @@

[license-image]: https://img.shields.io/badge/license-Apache_2.0-green.svg?style=flat
[dependencies-image]: https://status.david-dm.org/gh/open-telemetry/opentelemetry-js.svg?path=packages%2Fopentelemetry-instrumentation-xml-http-request
[dependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js?path=packages%2Fopentelemetry-instrumentation-xml-http-request
[devDependencies-image]: https://status.david-dm.org/gh/open-telemetry/opentelemetry-js.svg?path=packages%2Fopentelemetry-instrumentation-xml-http-request&type=dev
[devDependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js?path=packages%2Fopentelemetry-instrumentation-xml-http-request&type=dev
[npm-url]: https://www.npmjs.com/package/@opentelemetry/instrumentation-xml-http-request
[npm-img]: https://badge.fury.io/js/%40opentelemetry%2Finstrumentation-xml-http-request.svg

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc