@opentelemetry/instrumentation-xml-http-request 0.27.0 → 0.29.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -6
- package/build/esm/types.d.ts +1 -1
- package/build/esm/types.js.map +1 -1
- package/build/esm/version.d.ts +1 -1
- package/build/esm/version.js +1 -1
- package/build/esm/version.js.map +1 -1
- package/build/esm/xhr.d.ts +1 -1
- package/build/esm/xhr.js +9 -9
- package/build/esm/xhr.js.map +1 -1
- package/build/esnext/enums/AttributeNames.d.ts +7 -0
- package/build/esnext/enums/AttributeNames.js +23 -0
- package/build/esnext/enums/AttributeNames.js.map +1 -0
- package/build/esnext/enums/EventNames.d.ts +9 -0
- package/build/esnext/enums/EventNames.js +25 -0
- package/build/esnext/enums/EventNames.js.map +1 -0
- package/build/esnext/index.d.ts +2 -0
- package/build/esnext/index.js +17 -0
- package/build/esnext/index.js.map +1 -0
- package/build/esnext/types.d.ts +29 -0
- package/build/esnext/types.js +17 -0
- package/build/esnext/types.js.map +1 -0
- package/build/esnext/version.d.ts +2 -0
- package/build/esnext/version.js +18 -0
- package/build/esnext/version.js.map +1 -0
- package/build/esnext/xhr.d.ts +126 -0
- package/build/esnext/xhr.js +387 -0
- package/build/esnext/xhr.js.map +1 -0
- package/build/src/types.d.ts +1 -1
- package/build/src/types.js.map +1 -1
- package/build/src/version.d.ts +1 -1
- package/build/src/version.js +1 -1
- package/build/src/version.js.map +1 -1
- package/build/src/xhr.d.ts +1 -1
- package/build/src/xhr.js +17 -17
- package/build/src/xhr.js.map +1 -1
- package/package.json +32 -26
|
@@ -0,0 +1,387 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright The OpenTelemetry Authors
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import * as api from '@opentelemetry/api';
|
|
17
|
+
import { isWrapped, InstrumentationBase, safeExecuteInTheMiddle, } from '@opentelemetry/instrumentation';
|
|
18
|
+
import { hrTime, isUrlIgnored, otperformance } from '@opentelemetry/core';
|
|
19
|
+
import { SemanticAttributes } from '@opentelemetry/semantic-conventions';
|
|
20
|
+
import { addSpanNetworkEvents, getResource, PerformanceTimingNames as PTN, shouldPropagateTraceHeaders, parseUrl, } from '@opentelemetry/sdk-trace-web';
|
|
21
|
+
import { EventNames } from './enums/EventNames';
|
|
22
|
+
import { VERSION } from './version';
|
|
23
|
+
import { AttributeNames } from './enums/AttributeNames';
|
|
24
|
+
// how long to wait for observer to collect information about resources
|
|
25
|
+
// this is needed as event "load" is called before observer
|
|
26
|
+
// hard to say how long it should really wait, seems like 300ms is
|
|
27
|
+
// safe enough
|
|
28
|
+
const OBSERVER_WAIT_TIME_MS = 300;
|
|
29
|
+
/**
|
|
30
|
+
* This class represents a XMLHttpRequest plugin for auto instrumentation
|
|
31
|
+
*/
|
|
32
|
+
export class XMLHttpRequestInstrumentation extends InstrumentationBase {
|
|
33
|
+
constructor(config) {
|
|
34
|
+
super('@opentelemetry/instrumentation-xml-http-request', VERSION, config);
|
|
35
|
+
this.component = 'xml-http-request';
|
|
36
|
+
this.version = VERSION;
|
|
37
|
+
this.moduleName = this.component;
|
|
38
|
+
this._tasksCount = 0;
|
|
39
|
+
this._xhrMem = new WeakMap();
|
|
40
|
+
this._usedResources = new WeakSet();
|
|
41
|
+
}
|
|
42
|
+
init() { }
|
|
43
|
+
_getConfig() {
|
|
44
|
+
return this._config;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Adds custom headers to XMLHttpRequest
|
|
48
|
+
* @param xhr
|
|
49
|
+
* @param spanUrl
|
|
50
|
+
* @private
|
|
51
|
+
*/
|
|
52
|
+
_addHeaders(xhr, spanUrl) {
|
|
53
|
+
const url = parseUrl(spanUrl).href;
|
|
54
|
+
if (!shouldPropagateTraceHeaders(url, this._getConfig().propagateTraceHeaderCorsUrls)) {
|
|
55
|
+
const headers = {};
|
|
56
|
+
api.propagation.inject(api.context.active(), headers);
|
|
57
|
+
if (Object.keys(headers).length > 0) {
|
|
58
|
+
this._diag.debug('headers inject skipped due to CORS policy');
|
|
59
|
+
}
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const headers = {};
|
|
63
|
+
api.propagation.inject(api.context.active(), headers);
|
|
64
|
+
Object.keys(headers).forEach(key => {
|
|
65
|
+
xhr.setRequestHeader(key, String(headers[key]));
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Add cors pre flight child span
|
|
70
|
+
* @param span
|
|
71
|
+
* @param corsPreFlightRequest
|
|
72
|
+
* @private
|
|
73
|
+
*/
|
|
74
|
+
_addChildSpan(span, corsPreFlightRequest) {
|
|
75
|
+
api.context.with(api.trace.setSpan(api.context.active(), span), () => {
|
|
76
|
+
const childSpan = this.tracer.startSpan('CORS Preflight', {
|
|
77
|
+
startTime: corsPreFlightRequest[PTN.FETCH_START],
|
|
78
|
+
});
|
|
79
|
+
addSpanNetworkEvents(childSpan, corsPreFlightRequest);
|
|
80
|
+
childSpan.end(corsPreFlightRequest[PTN.RESPONSE_END]);
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Add attributes when span is going to end
|
|
85
|
+
* @param span
|
|
86
|
+
* @param xhr
|
|
87
|
+
* @param spanUrl
|
|
88
|
+
* @private
|
|
89
|
+
*/
|
|
90
|
+
_addFinalSpanAttributes(span, xhrMem, spanUrl) {
|
|
91
|
+
if (typeof spanUrl === 'string') {
|
|
92
|
+
const parsedUrl = parseUrl(spanUrl);
|
|
93
|
+
if (xhrMem.status !== undefined) {
|
|
94
|
+
span.setAttribute(SemanticAttributes.HTTP_STATUS_CODE, xhrMem.status);
|
|
95
|
+
}
|
|
96
|
+
if (xhrMem.statusText !== undefined) {
|
|
97
|
+
span.setAttribute(AttributeNames.HTTP_STATUS_TEXT, xhrMem.statusText);
|
|
98
|
+
}
|
|
99
|
+
span.setAttribute(SemanticAttributes.HTTP_HOST, parsedUrl.host);
|
|
100
|
+
span.setAttribute(SemanticAttributes.HTTP_SCHEME, parsedUrl.protocol.replace(':', ''));
|
|
101
|
+
// @TODO do we want to collect this or it will be collected earlier once only or
|
|
102
|
+
// maybe when parent span is not available ?
|
|
103
|
+
span.setAttribute(SemanticAttributes.HTTP_USER_AGENT, navigator.userAgent);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
_applyAttributesAfterXHR(span, xhr) {
|
|
107
|
+
const applyCustomAttributesOnSpan = this._getConfig()
|
|
108
|
+
.applyCustomAttributesOnSpan;
|
|
109
|
+
if (typeof applyCustomAttributesOnSpan === 'function') {
|
|
110
|
+
safeExecuteInTheMiddle(() => applyCustomAttributesOnSpan(span, xhr), error => {
|
|
111
|
+
if (!error) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
this._diag.error('applyCustomAttributesOnSpan', error);
|
|
115
|
+
}, true);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* will collect information about all resources created
|
|
120
|
+
* between "send" and "end" with additional waiting for main resource
|
|
121
|
+
* @param xhr
|
|
122
|
+
* @param spanUrl
|
|
123
|
+
* @private
|
|
124
|
+
*/
|
|
125
|
+
_addResourceObserver(xhr, spanUrl) {
|
|
126
|
+
const xhrMem = this._xhrMem.get(xhr);
|
|
127
|
+
if (!xhrMem ||
|
|
128
|
+
typeof PerformanceObserver !== 'function' ||
|
|
129
|
+
typeof PerformanceResourceTiming !== 'function') {
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
xhrMem.createdResources = {
|
|
133
|
+
observer: new PerformanceObserver(list => {
|
|
134
|
+
const entries = list.getEntries();
|
|
135
|
+
const parsedUrl = parseUrl(spanUrl);
|
|
136
|
+
entries.forEach(entry => {
|
|
137
|
+
if (entry.initiatorType === 'xmlhttprequest' &&
|
|
138
|
+
entry.name === parsedUrl.href) {
|
|
139
|
+
if (xhrMem.createdResources) {
|
|
140
|
+
xhrMem.createdResources.entries.push(entry);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
}),
|
|
145
|
+
entries: [],
|
|
146
|
+
};
|
|
147
|
+
xhrMem.createdResources.observer.observe({
|
|
148
|
+
entryTypes: ['resource'],
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Clears the resource timings and all resources assigned with spans
|
|
153
|
+
* when {@link XMLHttpRequestInstrumentationConfig.clearTimingResources} is
|
|
154
|
+
* set to true (default false)
|
|
155
|
+
* @private
|
|
156
|
+
*/
|
|
157
|
+
_clearResources() {
|
|
158
|
+
if (this._tasksCount === 0 && this._getConfig().clearTimingResources) {
|
|
159
|
+
otperformance.clearResourceTimings();
|
|
160
|
+
this._xhrMem = new WeakMap();
|
|
161
|
+
this._usedResources = new WeakSet();
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Finds appropriate resource and add network events to the span
|
|
166
|
+
* @param span
|
|
167
|
+
*/
|
|
168
|
+
_findResourceAndAddNetworkEvents(xhrMem, span, spanUrl, startTime, endTime) {
|
|
169
|
+
if (!spanUrl || !startTime || !endTime || !xhrMem.createdResources) {
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
let resources = xhrMem.createdResources.entries;
|
|
173
|
+
if (!resources || !resources.length) {
|
|
174
|
+
// fallback - either Observer is not available or it took longer
|
|
175
|
+
// then OBSERVER_WAIT_TIME_MS and observer didn't collect enough
|
|
176
|
+
// information
|
|
177
|
+
// ts thinks this is the perf_hooks module, but it is the browser performance api
|
|
178
|
+
resources = otperformance.getEntriesByType('resource');
|
|
179
|
+
}
|
|
180
|
+
const resource = getResource(parseUrl(spanUrl).href, startTime, endTime, resources, this._usedResources);
|
|
181
|
+
if (resource.mainRequest) {
|
|
182
|
+
const mainRequest = resource.mainRequest;
|
|
183
|
+
this._markResourceAsUsed(mainRequest);
|
|
184
|
+
const corsPreFlightRequest = resource.corsPreFlightRequest;
|
|
185
|
+
if (corsPreFlightRequest) {
|
|
186
|
+
this._addChildSpan(span, corsPreFlightRequest);
|
|
187
|
+
this._markResourceAsUsed(corsPreFlightRequest);
|
|
188
|
+
}
|
|
189
|
+
addSpanNetworkEvents(span, mainRequest);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Removes the previous information about span.
|
|
194
|
+
* This might happened when the same xhr is used again.
|
|
195
|
+
* @param xhr
|
|
196
|
+
* @private
|
|
197
|
+
*/
|
|
198
|
+
_cleanPreviousSpanInformation(xhr) {
|
|
199
|
+
const xhrMem = this._xhrMem.get(xhr);
|
|
200
|
+
if (xhrMem) {
|
|
201
|
+
const callbackToRemoveEvents = xhrMem.callbackToRemoveEvents;
|
|
202
|
+
if (callbackToRemoveEvents) {
|
|
203
|
+
callbackToRemoveEvents();
|
|
204
|
+
}
|
|
205
|
+
this._xhrMem.delete(xhr);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Creates a new span when method "open" is called
|
|
210
|
+
* @param xhr
|
|
211
|
+
* @param url
|
|
212
|
+
* @param method
|
|
213
|
+
* @private
|
|
214
|
+
*/
|
|
215
|
+
_createSpan(xhr, url, method) {
|
|
216
|
+
if (isUrlIgnored(url, this._getConfig().ignoreUrls)) {
|
|
217
|
+
this._diag.debug('ignoring span as url matches ignored url');
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
const spanName = `HTTP ${method.toUpperCase()}`;
|
|
221
|
+
const currentSpan = this.tracer.startSpan(spanName, {
|
|
222
|
+
kind: api.SpanKind.CLIENT,
|
|
223
|
+
attributes: {
|
|
224
|
+
[SemanticAttributes.HTTP_METHOD]: method,
|
|
225
|
+
[SemanticAttributes.HTTP_URL]: url,
|
|
226
|
+
},
|
|
227
|
+
});
|
|
228
|
+
currentSpan.addEvent(EventNames.METHOD_OPEN);
|
|
229
|
+
this._cleanPreviousSpanInformation(xhr);
|
|
230
|
+
this._xhrMem.set(xhr, {
|
|
231
|
+
span: currentSpan,
|
|
232
|
+
spanUrl: url,
|
|
233
|
+
});
|
|
234
|
+
return currentSpan;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Marks certain [resource]{@link PerformanceResourceTiming} when information
|
|
238
|
+
* from this is used to add events to span.
|
|
239
|
+
* This is done to avoid reusing the same resource again for next span
|
|
240
|
+
* @param resource
|
|
241
|
+
* @private
|
|
242
|
+
*/
|
|
243
|
+
_markResourceAsUsed(resource) {
|
|
244
|
+
this._usedResources.add(resource);
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Patches the method open
|
|
248
|
+
* @private
|
|
249
|
+
*/
|
|
250
|
+
_patchOpen() {
|
|
251
|
+
return (original) => {
|
|
252
|
+
const plugin = this;
|
|
253
|
+
return function patchOpen(...args) {
|
|
254
|
+
const method = args[0];
|
|
255
|
+
const url = args[1];
|
|
256
|
+
plugin._createSpan(this, url, method);
|
|
257
|
+
return original.apply(this, args);
|
|
258
|
+
};
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Patches the method send
|
|
263
|
+
* @private
|
|
264
|
+
*/
|
|
265
|
+
_patchSend() {
|
|
266
|
+
const plugin = this;
|
|
267
|
+
function endSpanTimeout(eventName, xhrMem, endTime) {
|
|
268
|
+
const callbackToRemoveEvents = xhrMem.callbackToRemoveEvents;
|
|
269
|
+
if (typeof callbackToRemoveEvents === 'function') {
|
|
270
|
+
callbackToRemoveEvents();
|
|
271
|
+
}
|
|
272
|
+
const { span, spanUrl, sendStartTime } = xhrMem;
|
|
273
|
+
if (span) {
|
|
274
|
+
plugin._findResourceAndAddNetworkEvents(xhrMem, span, spanUrl, sendStartTime, endTime);
|
|
275
|
+
span.addEvent(eventName, endTime);
|
|
276
|
+
plugin._addFinalSpanAttributes(span, xhrMem, spanUrl);
|
|
277
|
+
span.end(endTime);
|
|
278
|
+
plugin._tasksCount--;
|
|
279
|
+
}
|
|
280
|
+
plugin._clearResources();
|
|
281
|
+
}
|
|
282
|
+
function endSpan(eventName, xhr) {
|
|
283
|
+
const xhrMem = plugin._xhrMem.get(xhr);
|
|
284
|
+
if (!xhrMem) {
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
xhrMem.status = xhr.status;
|
|
288
|
+
xhrMem.statusText = xhr.statusText;
|
|
289
|
+
plugin._xhrMem.delete(xhr);
|
|
290
|
+
if (xhrMem.span) {
|
|
291
|
+
plugin._applyAttributesAfterXHR(xhrMem.span, xhr);
|
|
292
|
+
}
|
|
293
|
+
const endTime = hrTime();
|
|
294
|
+
// the timeout is needed as observer doesn't have yet information
|
|
295
|
+
// when event "load" is called. Also the time may differ depends on
|
|
296
|
+
// browser and speed of computer
|
|
297
|
+
setTimeout(() => {
|
|
298
|
+
endSpanTimeout(eventName, xhrMem, endTime);
|
|
299
|
+
}, OBSERVER_WAIT_TIME_MS);
|
|
300
|
+
}
|
|
301
|
+
function onError() {
|
|
302
|
+
endSpan(EventNames.EVENT_ERROR, this);
|
|
303
|
+
}
|
|
304
|
+
function onAbort() {
|
|
305
|
+
endSpan(EventNames.EVENT_ABORT, this);
|
|
306
|
+
}
|
|
307
|
+
function onTimeout() {
|
|
308
|
+
endSpan(EventNames.EVENT_TIMEOUT, this);
|
|
309
|
+
}
|
|
310
|
+
function onLoad() {
|
|
311
|
+
if (this.status < 299) {
|
|
312
|
+
endSpan(EventNames.EVENT_LOAD, this);
|
|
313
|
+
}
|
|
314
|
+
else {
|
|
315
|
+
endSpan(EventNames.EVENT_ERROR, this);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
function unregister(xhr) {
|
|
319
|
+
xhr.removeEventListener('abort', onAbort);
|
|
320
|
+
xhr.removeEventListener('error', onError);
|
|
321
|
+
xhr.removeEventListener('load', onLoad);
|
|
322
|
+
xhr.removeEventListener('timeout', onTimeout);
|
|
323
|
+
const xhrMem = plugin._xhrMem.get(xhr);
|
|
324
|
+
if (xhrMem) {
|
|
325
|
+
xhrMem.callbackToRemoveEvents = undefined;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
return (original) => {
|
|
329
|
+
return function patchSend(...args) {
|
|
330
|
+
const xhrMem = plugin._xhrMem.get(this);
|
|
331
|
+
if (!xhrMem) {
|
|
332
|
+
return original.apply(this, args);
|
|
333
|
+
}
|
|
334
|
+
const currentSpan = xhrMem.span;
|
|
335
|
+
const spanUrl = xhrMem.spanUrl;
|
|
336
|
+
if (currentSpan && spanUrl) {
|
|
337
|
+
api.context.with(api.trace.setSpan(api.context.active(), currentSpan), () => {
|
|
338
|
+
plugin._tasksCount++;
|
|
339
|
+
xhrMem.sendStartTime = hrTime();
|
|
340
|
+
currentSpan.addEvent(EventNames.METHOD_SEND);
|
|
341
|
+
this.addEventListener('abort', onAbort);
|
|
342
|
+
this.addEventListener('error', onError);
|
|
343
|
+
this.addEventListener('load', onLoad);
|
|
344
|
+
this.addEventListener('timeout', onTimeout);
|
|
345
|
+
xhrMem.callbackToRemoveEvents = () => {
|
|
346
|
+
unregister(this);
|
|
347
|
+
if (xhrMem.createdResources) {
|
|
348
|
+
xhrMem.createdResources.observer.disconnect();
|
|
349
|
+
}
|
|
350
|
+
};
|
|
351
|
+
plugin._addHeaders(this, spanUrl);
|
|
352
|
+
plugin._addResourceObserver(this, spanUrl);
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
return original.apply(this, args);
|
|
356
|
+
};
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
/**
|
|
360
|
+
* implements enable function
|
|
361
|
+
*/
|
|
362
|
+
enable() {
|
|
363
|
+
this._diag.debug('applying patch to', this.moduleName, this.version);
|
|
364
|
+
if (isWrapped(XMLHttpRequest.prototype.open)) {
|
|
365
|
+
this._unwrap(XMLHttpRequest.prototype, 'open');
|
|
366
|
+
this._diag.debug('removing previous patch from method open');
|
|
367
|
+
}
|
|
368
|
+
if (isWrapped(XMLHttpRequest.prototype.send)) {
|
|
369
|
+
this._unwrap(XMLHttpRequest.prototype, 'send');
|
|
370
|
+
this._diag.debug('removing previous patch from method send');
|
|
371
|
+
}
|
|
372
|
+
this._wrap(XMLHttpRequest.prototype, 'open', this._patchOpen());
|
|
373
|
+
this._wrap(XMLHttpRequest.prototype, 'send', this._patchSend());
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* implements disable function
|
|
377
|
+
*/
|
|
378
|
+
disable() {
|
|
379
|
+
this._diag.debug('removing patch from', this.moduleName, this.version);
|
|
380
|
+
this._unwrap(XMLHttpRequest.prototype, 'open');
|
|
381
|
+
this._unwrap(XMLHttpRequest.prototype, 'send');
|
|
382
|
+
this._tasksCount = 0;
|
|
383
|
+
this._xhrMem = new WeakMap();
|
|
384
|
+
this._usedResources = new WeakSet();
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
//# sourceMappingURL=xhr.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"xhr.js","sourceRoot":"","sources":["../../src/xhr.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,GAAG,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EACL,SAAS,EACT,mBAAmB,EAEnB,sBAAsB,GACvB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAC1E,OA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O,GAAG,IAAI,OAAO,EAA0B,CAAC;QACrD,IAAI,CAAC,cAAc,GAAG,IAAI,OAAO,EAA6B,CAAC;IACjE,CAAC;CACF","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport * as api from '@opentelemetry/api';\nimport {\n isWrapped,\n InstrumentationBase,\n InstrumentationConfig,\n safeExecuteInTheMiddle,\n} from '@opentelemetry/instrumentation';\nimport { hrTime, isUrlIgnored, otperformance } from '@opentelemetry/core';\nimport { SemanticAttributes } from '@opentelemetry/semantic-conventions';\nimport {\n addSpanNetworkEvents,\n getResource,\n PerformanceTimingNames as PTN,\n shouldPropagateTraceHeaders,\n parseUrl,\n} from '@opentelemetry/sdk-trace-web';\nimport { EventNames } from './enums/EventNames';\nimport {\n OpenFunction,\n PropagateTraceHeaderCorsUrls,\n SendFunction,\n XhrMem,\n} from './types';\nimport { VERSION } from './version';\nimport { AttributeNames } from './enums/AttributeNames';\n\n// how long to wait for observer to collect information about resources\n// this is needed as event \"load\" is called before observer\n// hard to say how long it should really wait, seems like 300ms is\n// safe enough\nconst OBSERVER_WAIT_TIME_MS = 300;\n\nexport type XHRCustomAttributeFunction = (\n span: api.Span,\n xhr: XMLHttpRequest\n) => void;\n\n/**\n * XMLHttpRequest config\n */\nexport interface XMLHttpRequestInstrumentationConfig\n extends InstrumentationConfig {\n /**\n * The number of timing resources is limited, after the limit\n * (chrome 250, safari 150) the information is not collected anymore.\n * The only way to prevent that is to regularly clean the resources\n * whenever it is possible. This is needed only when PerformanceObserver\n * is not available\n */\n clearTimingResources?: boolean;\n /** URLs which should include trace headers when origin doesn't match */\n propagateTraceHeaderCorsUrls?: PropagateTraceHeaderCorsUrls;\n /**\n * URLs that partially match any regex in ignoreUrls will not be traced.\n * In addition, URLs that are _exact matches_ of strings in ignoreUrls will\n * also not be traced.\n */\n ignoreUrls?: Array<string | RegExp>;\n /** Function for adding custom attributes on the span */\n applyCustomAttributesOnSpan?: XHRCustomAttributeFunction;\n}\n\n/**\n * This class represents a XMLHttpRequest plugin for auto instrumentation\n */\nexport class XMLHttpRequestInstrumentation extends InstrumentationBase<XMLHttpRequest> {\n readonly component: string = 'xml-http-request';\n readonly version: string = VERSION;\n moduleName = this.component;\n\n private _tasksCount = 0;\n private _xhrMem = new WeakMap<XMLHttpRequest, XhrMem>();\n private _usedResources = new WeakSet<PerformanceResourceTiming>();\n\n constructor(config?: XMLHttpRequestInstrumentationConfig) {\n super(\n '@opentelemetry/instrumentation-xml-http-request',\n VERSION,\n config\n );\n }\n\n init() {}\n\n private _getConfig(): XMLHttpRequestInstrumentationConfig {\n return this._config;\n }\n\n /**\n * Adds custom headers to XMLHttpRequest\n * @param xhr\n * @param spanUrl\n * @private\n */\n private _addHeaders(xhr: XMLHttpRequest, spanUrl: string) {\n const url = parseUrl(spanUrl).href;\n if (\n !shouldPropagateTraceHeaders(\n url,\n this._getConfig().propagateTraceHeaderCorsUrls\n )\n ) {\n const headers: Partial<Record<string, unknown>> = {};\n api.propagation.inject(api.context.active(), headers);\n if (Object.keys(headers).length > 0) {\n this._diag.debug('headers inject skipped due to CORS policy');\n }\n return;\n }\n const headers: { [key: string]: unknown } = {};\n api.propagation.inject(api.context.active(), headers);\n Object.keys(headers).forEach(key => {\n xhr.setRequestHeader(key, String(headers[key]));\n });\n }\n\n /**\n * Add cors pre flight child span\n * @param span\n * @param corsPreFlightRequest\n * @private\n */\n private _addChildSpan(\n span: api.Span,\n corsPreFlightRequest: PerformanceResourceTiming\n ): void {\n api.context.with(api.trace.setSpan(api.context.active(), span), () => {\n const childSpan = this.tracer.startSpan('CORS Preflight', {\n startTime: corsPreFlightRequest[PTN.FETCH_START],\n });\n addSpanNetworkEvents(childSpan, corsPreFlightRequest);\n childSpan.end(corsPreFlightRequest[PTN.RESPONSE_END]);\n });\n }\n\n /**\n * Add attributes when span is going to end\n * @param span\n * @param xhr\n * @param spanUrl\n * @private\n */\n _addFinalSpanAttributes(span: api.Span, xhrMem: XhrMem, spanUrl?: string) {\n if (typeof spanUrl === 'string') {\n const parsedUrl = parseUrl(spanUrl);\n if (xhrMem.status !== undefined) {\n span.setAttribute(SemanticAttributes.HTTP_STATUS_CODE, xhrMem.status);\n }\n if (xhrMem.statusText !== undefined) {\n span.setAttribute(AttributeNames.HTTP_STATUS_TEXT, xhrMem.statusText);\n }\n span.setAttribute(SemanticAttributes.HTTP_HOST, parsedUrl.host);\n span.setAttribute(\n SemanticAttributes.HTTP_SCHEME,\n parsedUrl.protocol.replace(':', '')\n );\n\n // @TODO do we want to collect this or it will be collected earlier once only or\n // maybe when parent span is not available ?\n span.setAttribute(\n SemanticAttributes.HTTP_USER_AGENT,\n navigator.userAgent\n );\n }\n }\n\n private _applyAttributesAfterXHR(span: api.Span, xhr: XMLHttpRequest) {\n const applyCustomAttributesOnSpan = this._getConfig()\n .applyCustomAttributesOnSpan;\n if (typeof applyCustomAttributesOnSpan === 'function') {\n safeExecuteInTheMiddle(\n () => applyCustomAttributesOnSpan(span, xhr),\n error => {\n if (!error) {\n return;\n }\n\n this._diag.error('applyCustomAttributesOnSpan', error);\n },\n true\n );\n }\n }\n\n /**\n * will collect information about all resources created\n * between \"send\" and \"end\" with additional waiting for main resource\n * @param xhr\n * @param spanUrl\n * @private\n */\n private _addResourceObserver(xhr: XMLHttpRequest, spanUrl: string) {\n const xhrMem = this._xhrMem.get(xhr);\n if (\n !xhrMem ||\n typeof PerformanceObserver !== 'function' ||\n typeof PerformanceResourceTiming !== 'function'\n ) {\n return;\n }\n xhrMem.createdResources = {\n observer: new PerformanceObserver(list => {\n const entries = list.getEntries() as PerformanceResourceTiming[];\n const parsedUrl = parseUrl(spanUrl);\n\n entries.forEach(entry => {\n if (\n entry.initiatorType === 'xmlhttprequest' &&\n entry.name === parsedUrl.href\n ) {\n if (xhrMem.createdResources) {\n xhrMem.createdResources.entries.push(entry);\n }\n }\n });\n }),\n entries: [],\n };\n xhrMem.createdResources.observer.observe({\n entryTypes: ['resource'],\n });\n }\n\n /**\n * Clears the resource timings and all resources assigned with spans\n * when {@link XMLHttpRequestInstrumentationConfig.clearTimingResources} is\n * set to true (default false)\n * @private\n */\n private _clearResources() {\n if (this._tasksCount === 0 && this._getConfig().clearTimingResources) {\n ((otperformance as unknown) as Performance).clearResourceTimings();\n this._xhrMem = new WeakMap<XMLHttpRequest, XhrMem>();\n this._usedResources = new WeakSet<PerformanceResourceTiming>();\n }\n }\n\n /**\n * Finds appropriate resource and add network events to the span\n * @param span\n */\n private _findResourceAndAddNetworkEvents(\n xhrMem: XhrMem,\n span: api.Span,\n spanUrl?: string,\n startTime?: api.HrTime,\n endTime?: api.HrTime\n ): void {\n if (!spanUrl || !startTime || !endTime || !xhrMem.createdResources) {\n return;\n }\n\n let resources: PerformanceResourceTiming[] =\n xhrMem.createdResources.entries;\n\n if (!resources || !resources.length) {\n // fallback - either Observer is not available or it took longer\n // then OBSERVER_WAIT_TIME_MS and observer didn't collect enough\n // information\n // ts thinks this is the perf_hooks module, but it is the browser performance api\n resources = ((otperformance as unknown) as Performance).getEntriesByType(\n 'resource'\n ) as PerformanceResourceTiming[];\n }\n\n const resource = getResource(\n parseUrl(spanUrl).href,\n startTime,\n endTime,\n resources,\n this._usedResources\n );\n\n if (resource.mainRequest) {\n const mainRequest = resource.mainRequest;\n this._markResourceAsUsed(mainRequest);\n\n const corsPreFlightRequest = resource.corsPreFlightRequest;\n if (corsPreFlightRequest) {\n this._addChildSpan(span, corsPreFlightRequest);\n this._markResourceAsUsed(corsPreFlightRequest);\n }\n addSpanNetworkEvents(span, mainRequest);\n }\n }\n\n /**\n * Removes the previous information about span.\n * This might happened when the same xhr is used again.\n * @param xhr\n * @private\n */\n private _cleanPreviousSpanInformation(xhr: XMLHttpRequest) {\n const xhrMem = this._xhrMem.get(xhr);\n if (xhrMem) {\n const callbackToRemoveEvents = xhrMem.callbackToRemoveEvents;\n if (callbackToRemoveEvents) {\n callbackToRemoveEvents();\n }\n this._xhrMem.delete(xhr);\n }\n }\n\n /**\n * Creates a new span when method \"open\" is called\n * @param xhr\n * @param url\n * @param method\n * @private\n */\n private _createSpan(\n xhr: XMLHttpRequest,\n url: string,\n method: string\n ): api.Span | undefined {\n if (isUrlIgnored(url, this._getConfig().ignoreUrls)) {\n this._diag.debug('ignoring span as url matches ignored url');\n return;\n }\n const spanName = `HTTP ${method.toUpperCase()}`;\n\n const currentSpan = this.tracer.startSpan(spanName, {\n kind: api.SpanKind.CLIENT,\n attributes: {\n [SemanticAttributes.HTTP_METHOD]: method,\n [SemanticAttributes.HTTP_URL]: url,\n },\n });\n\n currentSpan.addEvent(EventNames.METHOD_OPEN);\n\n this._cleanPreviousSpanInformation(xhr);\n\n this._xhrMem.set(xhr, {\n span: currentSpan,\n spanUrl: url,\n });\n\n return currentSpan;\n }\n\n /**\n * Marks certain [resource]{@link PerformanceResourceTiming} when information\n * from this is used to add events to span.\n * This is done to avoid reusing the same resource again for next span\n * @param resource\n * @private\n */\n private _markResourceAsUsed(resource: PerformanceResourceTiming) {\n this._usedResources.add(resource);\n }\n\n /**\n * Patches the method open\n * @private\n */\n protected _patchOpen() {\n return (original: OpenFunction): OpenFunction => {\n const plugin = this;\n return function patchOpen(this: XMLHttpRequest, ...args): void {\n const method: string = args[0];\n const url: string = args[1];\n plugin._createSpan(this, url, method);\n\n return original.apply(this, args);\n };\n };\n }\n\n /**\n * Patches the method send\n * @private\n */\n protected _patchSend() {\n const plugin = this;\n\n function endSpanTimeout(\n eventName: string,\n xhrMem: XhrMem,\n endTime: api.HrTime\n ) {\n const callbackToRemoveEvents = xhrMem.callbackToRemoveEvents;\n\n if (typeof callbackToRemoveEvents === 'function') {\n callbackToRemoveEvents();\n }\n\n const { span, spanUrl, sendStartTime } = xhrMem;\n\n if (span) {\n plugin._findResourceAndAddNetworkEvents(\n xhrMem,\n span,\n spanUrl,\n sendStartTime,\n endTime\n );\n span.addEvent(eventName, endTime);\n plugin._addFinalSpanAttributes(span, xhrMem, spanUrl);\n span.end(endTime);\n plugin._tasksCount--;\n }\n plugin._clearResources();\n }\n\n function endSpan(eventName: string, xhr: XMLHttpRequest) {\n const xhrMem = plugin._xhrMem.get(xhr);\n if (!xhrMem) {\n return;\n }\n xhrMem.status = xhr.status;\n xhrMem.statusText = xhr.statusText;\n plugin._xhrMem.delete(xhr);\n\n if (xhrMem.span) {\n plugin._applyAttributesAfterXHR(xhrMem.span, xhr);\n }\n const endTime = hrTime();\n\n // the timeout is needed as observer doesn't have yet information\n // when event \"load\" is called. Also the time may differ depends on\n // browser and speed of computer\n setTimeout(() => {\n endSpanTimeout(eventName, xhrMem, endTime);\n }, OBSERVER_WAIT_TIME_MS);\n }\n\n function onError(this: XMLHttpRequest) {\n endSpan(EventNames.EVENT_ERROR, this);\n }\n\n function onAbort(this: XMLHttpRequest) {\n endSpan(EventNames.EVENT_ABORT, this);\n }\n\n function onTimeout(this: XMLHttpRequest) {\n endSpan(EventNames.EVENT_TIMEOUT, this);\n }\n\n function onLoad(this: XMLHttpRequest) {\n if (this.status < 299) {\n endSpan(EventNames.EVENT_LOAD, this);\n } else {\n endSpan(EventNames.EVENT_ERROR, this);\n }\n }\n\n function unregister(xhr: XMLHttpRequest) {\n xhr.removeEventListener('abort', onAbort);\n xhr.removeEventListener('error', onError);\n xhr.removeEventListener('load', onLoad);\n xhr.removeEventListener('timeout', onTimeout);\n const xhrMem = plugin._xhrMem.get(xhr);\n if (xhrMem) {\n xhrMem.callbackToRemoveEvents = undefined;\n }\n }\n\n return (original: SendFunction): SendFunction => {\n return function patchSend(this: XMLHttpRequest, ...args): void {\n const xhrMem = plugin._xhrMem.get(this);\n if (!xhrMem) {\n return original.apply(this, args);\n }\n const currentSpan = xhrMem.span;\n const spanUrl = xhrMem.spanUrl;\n\n if (currentSpan && spanUrl) {\n api.context.with(\n api.trace.setSpan(api.context.active(), currentSpan),\n () => {\n plugin._tasksCount++;\n xhrMem.sendStartTime = hrTime();\n currentSpan.addEvent(EventNames.METHOD_SEND);\n\n this.addEventListener('abort', onAbort);\n this.addEventListener('error', onError);\n this.addEventListener('load', onLoad);\n this.addEventListener('timeout', onTimeout);\n\n xhrMem.callbackToRemoveEvents = () => {\n unregister(this);\n if (xhrMem.createdResources) {\n xhrMem.createdResources.observer.disconnect();\n }\n };\n plugin._addHeaders(this, spanUrl);\n plugin._addResourceObserver(this, spanUrl);\n }\n );\n }\n return original.apply(this, args);\n };\n };\n }\n\n /**\n * implements enable function\n */\n override enable() {\n this._diag.debug('applying patch to', this.moduleName, this.version);\n\n if (isWrapped(XMLHttpRequest.prototype.open)) {\n this._unwrap(XMLHttpRequest.prototype, 'open');\n this._diag.debug('removing previous patch from method open');\n }\n\n if (isWrapped(XMLHttpRequest.prototype.send)) {\n this._unwrap(XMLHttpRequest.prototype, 'send');\n this._diag.debug('removing previous patch from method send');\n }\n\n this._wrap(XMLHttpRequest.prototype, 'open', this._patchOpen());\n this._wrap(XMLHttpRequest.prototype, 'send', this._patchSend());\n }\n\n /**\n * implements disable function\n */\n override disable() {\n this._diag.debug('removing patch from', this.moduleName, this.version);\n\n this._unwrap(XMLHttpRequest.prototype, 'open');\n this._unwrap(XMLHttpRequest.prototype, 'send');\n\n this._tasksCount = 0;\n this._xhrMem = new WeakMap<XMLHttpRequest, XhrMem>();\n this._usedResources = new WeakSet<PerformanceResourceTiming>();\n }\n}\n"]}
|
package/build/src/types.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export declare type OpenFunction = (method: string, url: string, async?: boolean
|
|
|
6
6
|
/**
|
|
7
7
|
* method "send" from XMLHttpRequest
|
|
8
8
|
*/
|
|
9
|
-
export declare type SendFunction =
|
|
9
|
+
export declare type SendFunction = typeof XMLHttpRequest.prototype.send;
|
|
10
10
|
export declare type SendBody = string | Document | Blob | ArrayBufferView | ArrayBuffer | FormData | URLSearchParams | ReadableStream<Uint8Array> | null;
|
|
11
11
|
/**
|
|
12
12
|
* interface to store information in weak map about spans, resources and
|
package/build/src/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport * as api from '@opentelemetry/api';\n\n/**\n * method \"open\" from XMLHttpRequest\n */\nexport type OpenFunction = (\n method: string,\n url: string,\n async?: boolean,\n user?: string | null,\n pass?: string | null\n) => void;\n\n/**\n * method \"send\" from XMLHttpRequest\n */\nexport type SendFunction =
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport * as api from '@opentelemetry/api';\n\n/**\n * method \"open\" from XMLHttpRequest\n */\nexport type OpenFunction = (\n method: string,\n url: string,\n async?: boolean,\n user?: string | null,\n pass?: string | null\n) => void;\n\n/**\n * method \"send\" from XMLHttpRequest\n */\nexport type SendFunction = typeof XMLHttpRequest.prototype.send;\n\nexport type SendBody =\n | string\n | Document\n | Blob\n | ArrayBufferView\n | ArrayBuffer\n | FormData\n // eslint-disable-next-line node/no-unsupported-features/node-builtins\n | URLSearchParams\n | ReadableStream<Uint8Array>\n | null;\n\n/**\n * interface to store information in weak map about spans, resources and\n * callbacks\n */\nexport interface XhrMem {\n status?: number;\n statusText?: string;\n // span assigned to xhr\n span: api.Span;\n // span url - not available on types.Span\n spanUrl?: string;\n // startTime of send function - used to filter cors preflight requests\n sendStartTime?: api.HrTime;\n // resources created between send and end plus some additional timeout\n createdResources?: {\n observer: PerformanceObserver;\n entries: PerformanceResourceTiming[];\n };\n // callback to remove events from xhr once the span ends\n callbackToRemoveEvents?: Function;\n}\n\nexport type PropagateTraceHeaderCorsUrl = string | RegExp;\n\nexport type PropagateTraceHeaderCorsUrls =\n | PropagateTraceHeaderCorsUrl\n | PropagateTraceHeaderCorsUrl[];\n"]}
|
package/build/src/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.29.1";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/build/src/version.js
CHANGED
package/build/src/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4DAA4D;AAC/C,QAAA,OAAO,GAAG,QAAQ,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// this is autogenerated file, see scripts/version-update.js\nexport const VERSION = '0.
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4DAA4D;AAC/C,QAAA,OAAO,GAAG,QAAQ,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// this is autogenerated file, see scripts/version-update.js\nexport const VERSION = '0.29.1';\n"]}
|
package/build/src/xhr.d.ts
CHANGED
package/build/src/xhr.js
CHANGED
|
@@ -49,11 +49,12 @@ class XMLHttpRequestInstrumentation extends instrumentation_1.InstrumentationBas
|
|
|
49
49
|
/**
|
|
50
50
|
* Adds custom headers to XMLHttpRequest
|
|
51
51
|
* @param xhr
|
|
52
|
-
* @param
|
|
52
|
+
* @param spanUrl
|
|
53
53
|
* @private
|
|
54
54
|
*/
|
|
55
55
|
_addHeaders(xhr, spanUrl) {
|
|
56
|
-
|
|
56
|
+
const url = (0, sdk_trace_web_1.parseUrl)(spanUrl).href;
|
|
57
|
+
if (!(0, sdk_trace_web_1.shouldPropagateTraceHeaders)(url, this._getConfig().propagateTraceHeaderCorsUrls)) {
|
|
57
58
|
const headers = {};
|
|
58
59
|
api.propagation.inject(api.context.active(), headers);
|
|
59
60
|
if (Object.keys(headers).length > 0) {
|
|
@@ -78,7 +79,7 @@ class XMLHttpRequestInstrumentation extends instrumentation_1.InstrumentationBas
|
|
|
78
79
|
const childSpan = this.tracer.startSpan('CORS Preflight', {
|
|
79
80
|
startTime: corsPreFlightRequest[sdk_trace_web_1.PerformanceTimingNames.FETCH_START],
|
|
80
81
|
});
|
|
81
|
-
sdk_trace_web_1.addSpanNetworkEvents(childSpan, corsPreFlightRequest);
|
|
82
|
+
(0, sdk_trace_web_1.addSpanNetworkEvents)(childSpan, corsPreFlightRequest);
|
|
82
83
|
childSpan.end(corsPreFlightRequest[sdk_trace_web_1.PerformanceTimingNames.RESPONSE_END]);
|
|
83
84
|
});
|
|
84
85
|
}
|
|
@@ -91,7 +92,7 @@ class XMLHttpRequestInstrumentation extends instrumentation_1.InstrumentationBas
|
|
|
91
92
|
*/
|
|
92
93
|
_addFinalSpanAttributes(span, xhrMem, spanUrl) {
|
|
93
94
|
if (typeof spanUrl === 'string') {
|
|
94
|
-
const parsedUrl = sdk_trace_web_1.parseUrl(spanUrl);
|
|
95
|
+
const parsedUrl = (0, sdk_trace_web_1.parseUrl)(spanUrl);
|
|
95
96
|
if (xhrMem.status !== undefined) {
|
|
96
97
|
span.setAttribute(semantic_conventions_1.SemanticAttributes.HTTP_STATUS_CODE, xhrMem.status);
|
|
97
98
|
}
|
|
@@ -109,7 +110,7 @@ class XMLHttpRequestInstrumentation extends instrumentation_1.InstrumentationBas
|
|
|
109
110
|
const applyCustomAttributesOnSpan = this._getConfig()
|
|
110
111
|
.applyCustomAttributesOnSpan;
|
|
111
112
|
if (typeof applyCustomAttributesOnSpan === 'function') {
|
|
112
|
-
instrumentation_1.safeExecuteInTheMiddle(() => applyCustomAttributesOnSpan(span, xhr), error => {
|
|
113
|
+
(0, instrumentation_1.safeExecuteInTheMiddle)(() => applyCustomAttributesOnSpan(span, xhr), error => {
|
|
113
114
|
if (!error) {
|
|
114
115
|
return;
|
|
115
116
|
}
|
|
@@ -127,18 +128,17 @@ class XMLHttpRequestInstrumentation extends instrumentation_1.InstrumentationBas
|
|
|
127
128
|
_addResourceObserver(xhr, spanUrl) {
|
|
128
129
|
const xhrMem = this._xhrMem.get(xhr);
|
|
129
130
|
if (!xhrMem ||
|
|
130
|
-
typeof
|
|
131
|
-
typeof
|
|
131
|
+
typeof PerformanceObserver !== 'function' ||
|
|
132
|
+
typeof PerformanceResourceTiming !== 'function') {
|
|
132
133
|
return;
|
|
133
134
|
}
|
|
134
135
|
xhrMem.createdResources = {
|
|
135
136
|
observer: new PerformanceObserver(list => {
|
|
136
137
|
const entries = list.getEntries();
|
|
137
|
-
const
|
|
138
|
-
urlNormalizingAnchor.href = spanUrl;
|
|
138
|
+
const parsedUrl = (0, sdk_trace_web_1.parseUrl)(spanUrl);
|
|
139
139
|
entries.forEach(entry => {
|
|
140
140
|
if (entry.initiatorType === 'xmlhttprequest' &&
|
|
141
|
-
entry.name ===
|
|
141
|
+
entry.name === parsedUrl.href) {
|
|
142
142
|
if (xhrMem.createdResources) {
|
|
143
143
|
xhrMem.createdResources.entries.push(entry);
|
|
144
144
|
}
|
|
@@ -180,7 +180,7 @@ class XMLHttpRequestInstrumentation extends instrumentation_1.InstrumentationBas
|
|
|
180
180
|
// ts thinks this is the perf_hooks module, but it is the browser performance api
|
|
181
181
|
resources = core_1.otperformance.getEntriesByType('resource');
|
|
182
182
|
}
|
|
183
|
-
const resource = sdk_trace_web_1.getResource(spanUrl, startTime, endTime, resources, this._usedResources);
|
|
183
|
+
const resource = (0, sdk_trace_web_1.getResource)((0, sdk_trace_web_1.parseUrl)(spanUrl).href, startTime, endTime, resources, this._usedResources);
|
|
184
184
|
if (resource.mainRequest) {
|
|
185
185
|
const mainRequest = resource.mainRequest;
|
|
186
186
|
this._markResourceAsUsed(mainRequest);
|
|
@@ -189,7 +189,7 @@ class XMLHttpRequestInstrumentation extends instrumentation_1.InstrumentationBas
|
|
|
189
189
|
this._addChildSpan(span, corsPreFlightRequest);
|
|
190
190
|
this._markResourceAsUsed(corsPreFlightRequest);
|
|
191
191
|
}
|
|
192
|
-
sdk_trace_web_1.addSpanNetworkEvents(span, mainRequest);
|
|
192
|
+
(0, sdk_trace_web_1.addSpanNetworkEvents)(span, mainRequest);
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
195
|
/**
|
|
@@ -216,7 +216,7 @@ class XMLHttpRequestInstrumentation extends instrumentation_1.InstrumentationBas
|
|
|
216
216
|
* @private
|
|
217
217
|
*/
|
|
218
218
|
_createSpan(xhr, url, method) {
|
|
219
|
-
if (core_1.isUrlIgnored(url, this._getConfig().ignoreUrls)) {
|
|
219
|
+
if ((0, core_1.isUrlIgnored)(url, this._getConfig().ignoreUrls)) {
|
|
220
220
|
this._diag.debug('ignoring span as url matches ignored url');
|
|
221
221
|
return;
|
|
222
222
|
}
|
|
@@ -293,7 +293,7 @@ class XMLHttpRequestInstrumentation extends instrumentation_1.InstrumentationBas
|
|
|
293
293
|
if (xhrMem.span) {
|
|
294
294
|
plugin._applyAttributesAfterXHR(xhrMem.span, xhr);
|
|
295
295
|
}
|
|
296
|
-
const endTime = core_1.hrTime();
|
|
296
|
+
const endTime = (0, core_1.hrTime)();
|
|
297
297
|
// the timeout is needed as observer doesn't have yet information
|
|
298
298
|
// when event "load" is called. Also the time may differ depends on
|
|
299
299
|
// browser and speed of computer
|
|
@@ -339,7 +339,7 @@ class XMLHttpRequestInstrumentation extends instrumentation_1.InstrumentationBas
|
|
|
339
339
|
if (currentSpan && spanUrl) {
|
|
340
340
|
api.context.with(api.trace.setSpan(api.context.active(), currentSpan), () => {
|
|
341
341
|
plugin._tasksCount++;
|
|
342
|
-
xhrMem.sendStartTime = core_1.hrTime();
|
|
342
|
+
xhrMem.sendStartTime = (0, core_1.hrTime)();
|
|
343
343
|
currentSpan.addEvent(EventNames_1.EventNames.METHOD_SEND);
|
|
344
344
|
this.addEventListener('abort', onAbort);
|
|
345
345
|
this.addEventListener('error', onError);
|
|
@@ -364,11 +364,11 @@ class XMLHttpRequestInstrumentation extends instrumentation_1.InstrumentationBas
|
|
|
364
364
|
*/
|
|
365
365
|
enable() {
|
|
366
366
|
this._diag.debug('applying patch to', this.moduleName, this.version);
|
|
367
|
-
if (instrumentation_1.isWrapped(XMLHttpRequest.prototype.open)) {
|
|
367
|
+
if ((0, instrumentation_1.isWrapped)(XMLHttpRequest.prototype.open)) {
|
|
368
368
|
this._unwrap(XMLHttpRequest.prototype, 'open');
|
|
369
369
|
this._diag.debug('removing previous patch from method open');
|
|
370
370
|
}
|
|
371
|
-
if (instrumentation_1.isWrapped(XMLHttpRequest.prototype.send)) {
|
|
371
|
+
if ((0, instrumentation_1.isWrapped)(XMLHttpRequest.prototype.send)) {
|
|
372
372
|
this._unwrap(XMLHttpRequest.prototype, 'send');
|
|
373
373
|
this._diag.debug('removing previous patch from method send');
|
|
374
374
|
}
|