@equinor/fusion-framework-vite-plugin-spa 5.2.0 → 5.2.2

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.
@@ -1,4 +1,4 @@
1
- import { D as DiagAPI, N as NOOP_METER, r as registerGlobal, g as getGlobal, u as unregisterGlobal, C as ContextAPI, c as createContextKey, R as ROOT_CONTEXT, i as isTracingSuppressed, d as diag$1, t as trace, a as isSpanContextValid, T as TraceFlags, b as NoopLogger, e as NOOP_LOGGER, f as createInstrumentationScope, h as createResource, j as toAttributes, J as JSON_ENCODER, O as OTLPExporterBase, k as createLegacyOtlpBrowserExportDelegate, o as otperformance, l as isTimeInput, m as hrTimeDuration, n as hrTime, p as millisToHrTime, q as isTimeInputHrTime, s as addHrTimes, A as ATTR_EXCEPTION_TYPE, v as ATTR_EXCEPTION_MESSAGE, w as ATTR_EXCEPTION_STACKTRACE, I as INVALID_SPAN_CONTEXT, x as context, y as globalErrorHandler, z as ATTR_ERROR_TYPE, B as BindOnceFuture, E as createNoopMeter, F as suppressTracing, G as ExportResultCode, H as defaultResource, K as isValidTraceId, L as hrTimeToNanoseconds, M as timeInputToHrTime, P as ATTR_URL_FULL, Q as ATTR_USER_AGENT_ORIGINAL, S as ATTR_HTTP_RESPONSE_STATUS_CODE, U as ATTR_SERVER_ADDRESS, V as ATTR_SERVER_PORT, W as ATTR_ERROR_TYPE$1, X as ATTR_HTTP_REQUEST_METHOD, Y as ATTR_HTTP_REQUEST_METHOD_ORIGINAL, Z as ProxyTracerProvider, _ as resourceFromAttributes } from './create-legacy-browser-delegate-B4z_676L.js';
1
+ import { D as DiagAPI, N as NOOP_METER, r as registerGlobal, g as getGlobal, u as unregisterGlobal, C as ContextAPI, c as createContextKey, R as ROOT_CONTEXT, i as isTracingSuppressed, d as diag$1, t as trace, a as isSpanContextValid, T as TraceFlags, b as NoopLogger, e as NOOP_LOGGER, f as createInstrumentationScope, h as createResource, j as toAttributes, J as JSON_ENCODER, O as OTLPExporterBase, k as createLegacyOtlpBrowserExportDelegate, o as otperformance, l as isTimeInput, m as hrTimeDuration, n as hrTime, p as millisToHrTime, q as isTimeInputHrTime, s as addHrTimes, A as ATTR_EXCEPTION_TYPE, v as ATTR_EXCEPTION_MESSAGE, w as ATTR_EXCEPTION_STACKTRACE, I as INVALID_SPAN_CONTEXT, x as context, y as globalErrorHandler, z as ATTR_ERROR_TYPE, B as BindOnceFuture, E as createNoopMeter, F as suppressTracing, G as ExportResultCode, H as defaultResource, K as isValidTraceId, L as ATTR_URL_FULL, M as ATTR_USER_AGENT_ORIGINAL, P as hrTimeToNanoseconds, Q as timeInputToHrTime, S as ATTR_HTTP_RESPONSE_STATUS_CODE, U as ATTR_SERVER_ADDRESS, V as ATTR_SERVER_PORT, W as ATTR_HTTP_REQUEST_METHOD, X as ATTR_HTTP_REQUEST_METHOD_ORIGINAL, Y as ProxyTracerProvider, Z as resourceFromAttributes } from './create-legacy-browser-delegate-4GII-R4B.js';
2
2
 
3
3
  /*
4
4
  * Copyright The OpenTelemetry Authors
@@ -4948,7 +4948,7 @@ function samplingDecisionToString(decision) {
4948
4948
  * SPDX-License-Identifier: Apache-2.0
4949
4949
  */
4950
4950
  // this is autogenerated file, see scripts/version-update.js
4951
- const VERSION$2 = '2.11.0';
4951
+ const VERSION$2 = '2.12.0';
4952
4952
 
4953
4953
  /*
4954
4954
  * Copyright The OpenTelemetry Authors
@@ -6055,7 +6055,7 @@ class WebTracerProvider extends BasicTracerProvider {
6055
6055
  * Copyright The OpenTelemetry Authors
6056
6056
  * SPDX-License-Identifier: Apache-2.0
6057
6057
  */
6058
- var PerformanceTimingNames;
6058
+ var PerformanceTimingNames$1;
6059
6059
  (function (PerformanceTimingNames) {
6060
6060
  PerformanceTimingNames["CONNECT_END"] = "connectEnd";
6061
6061
  PerformanceTimingNames["CONNECT_START"] = "connectStart";
@@ -6080,7 +6080,7 @@ var PerformanceTimingNames;
6080
6080
  PerformanceTimingNames["START_TIME"] = "startTime";
6081
6081
  PerformanceTimingNames["UNLOAD_EVENT_END"] = "unloadEventEnd";
6082
6082
  PerformanceTimingNames["UNLOAD_EVENT_START"] = "unloadEventStart";
6083
- })(PerformanceTimingNames || (PerformanceTimingNames = {}));
6083
+ })(PerformanceTimingNames$1 || (PerformanceTimingNames$1 = {}));
6084
6084
 
6085
6085
  /*
6086
6086
  * Copyright The OpenTelemetry Authors
@@ -6116,20 +6116,12 @@ const ATTR_HTTP_RESPONSE_CONTENT_LENGTH_UNCOMPRESSED = 'http.response_content_le
6116
6116
  * Copyright The OpenTelemetry Authors
6117
6117
  * SPDX-License-Identifier: Apache-2.0
6118
6118
  */
6119
- // Used to normalize relative URLs
6120
- let urlNormalizingAnchor;
6121
- function getUrlNormalizingAnchor() {
6122
- if (!urlNormalizingAnchor) {
6123
- urlNormalizingAnchor = document.createElement('a');
6124
- }
6125
- return urlNormalizingAnchor;
6126
- }
6127
6119
  /**
6128
6120
  * Helper function to be able to use enum as typed key in type and in interface when using forEach
6129
6121
  * @param obj
6130
6122
  * @param key
6131
6123
  */
6132
- function hasKey(obj, key) {
6124
+ function hasKey$1(obj, key) {
6133
6125
  return key in obj;
6134
6126
  }
6135
6127
  /**
@@ -6139,8 +6131,8 @@ function hasKey(obj, key) {
6139
6131
  * @param entries
6140
6132
  * @param ignoreZeros
6141
6133
  */
6142
- function addSpanNetworkEvent(span, performanceName, entries, ignoreZeros = true) {
6143
- if (hasKey(entries, performanceName) &&
6134
+ function addSpanNetworkEvent$1(span, performanceName, entries, ignoreZeros = true) {
6135
+ if (hasKey$1(entries, performanceName) &&
6144
6136
  typeof entries[performanceName] === 'number' &&
6145
6137
  !(ignoreZeros && entries[performanceName] === 0)) {
6146
6138
  return span.addEvent(performanceName, entries[performanceName]);
@@ -6150,190 +6142,35 @@ function addSpanNetworkEvent(span, performanceName, entries, ignoreZeros = true)
6150
6142
  /**
6151
6143
  * Helper function for adding network events and content length attributes.
6152
6144
  */
6153
- function addSpanNetworkEvents(span, resource, ignoreNetworkEvents = false, ignoreZeros, skipOldSemconvContentLengthAttrs) {
6145
+ function addSpanNetworkEvents$1(span, resource, ignoreNetworkEvents = false, ignoreZeros, skipOldSemconvContentLengthAttrs) {
6154
6146
  if (ignoreZeros === undefined) {
6155
- ignoreZeros = resource[PerformanceTimingNames.START_TIME] !== 0;
6147
+ ignoreZeros = resource[PerformanceTimingNames$1.START_TIME] !== 0;
6156
6148
  }
6157
6149
  if (!ignoreNetworkEvents) {
6158
- addSpanNetworkEvent(span, PerformanceTimingNames.FETCH_START, resource, ignoreZeros);
6159
- addSpanNetworkEvent(span, PerformanceTimingNames.DOMAIN_LOOKUP_START, resource, ignoreZeros);
6160
- addSpanNetworkEvent(span, PerformanceTimingNames.DOMAIN_LOOKUP_END, resource, ignoreZeros);
6161
- addSpanNetworkEvent(span, PerformanceTimingNames.CONNECT_START, resource, ignoreZeros);
6162
- addSpanNetworkEvent(span, PerformanceTimingNames.SECURE_CONNECTION_START, resource, ignoreZeros);
6163
- addSpanNetworkEvent(span, PerformanceTimingNames.CONNECT_END, resource, ignoreZeros);
6164
- addSpanNetworkEvent(span, PerformanceTimingNames.REQUEST_START, resource, ignoreZeros);
6165
- addSpanNetworkEvent(span, PerformanceTimingNames.RESPONSE_START, resource, ignoreZeros);
6166
- addSpanNetworkEvent(span, PerformanceTimingNames.RESPONSE_END, resource, ignoreZeros);
6150
+ addSpanNetworkEvent$1(span, PerformanceTimingNames$1.FETCH_START, resource, ignoreZeros);
6151
+ addSpanNetworkEvent$1(span, PerformanceTimingNames$1.DOMAIN_LOOKUP_START, resource, ignoreZeros);
6152
+ addSpanNetworkEvent$1(span, PerformanceTimingNames$1.DOMAIN_LOOKUP_END, resource, ignoreZeros);
6153
+ addSpanNetworkEvent$1(span, PerformanceTimingNames$1.CONNECT_START, resource, ignoreZeros);
6154
+ addSpanNetworkEvent$1(span, PerformanceTimingNames$1.SECURE_CONNECTION_START, resource, ignoreZeros);
6155
+ addSpanNetworkEvent$1(span, PerformanceTimingNames$1.CONNECT_END, resource, ignoreZeros);
6156
+ addSpanNetworkEvent$1(span, PerformanceTimingNames$1.REQUEST_START, resource, ignoreZeros);
6157
+ addSpanNetworkEvent$1(span, PerformanceTimingNames$1.RESPONSE_START, resource, ignoreZeros);
6158
+ addSpanNetworkEvent$1(span, PerformanceTimingNames$1.RESPONSE_END, resource, ignoreZeros);
6167
6159
  }
6168
- if (!skipOldSemconvContentLengthAttrs) {
6160
+ {
6169
6161
  // This block adds content-length-related span attributes using the
6170
6162
  // *old* HTTP semconv (v1.7.0).
6171
- const encodedLength = resource[PerformanceTimingNames.ENCODED_BODY_SIZE];
6163
+ const encodedLength = resource[PerformanceTimingNames$1.ENCODED_BODY_SIZE];
6172
6164
  if (encodedLength !== undefined) {
6173
6165
  span.setAttribute(ATTR_HTTP_RESPONSE_CONTENT_LENGTH, encodedLength);
6174
6166
  }
6175
- const decodedLength = resource[PerformanceTimingNames.DECODED_BODY_SIZE];
6167
+ const decodedLength = resource[PerformanceTimingNames$1.DECODED_BODY_SIZE];
6176
6168
  // Spec: Not set if transport encoding not used (in which case encoded and decoded sizes match)
6177
6169
  if (decodedLength !== undefined && encodedLength !== decodedLength) {
6178
6170
  span.setAttribute(ATTR_HTTP_RESPONSE_CONTENT_LENGTH_UNCOMPRESSED, decodedLength);
6179
6171
  }
6180
6172
  }
6181
6173
  }
6182
- /**
6183
- * sort resources by startTime
6184
- * @param filteredResources
6185
- */
6186
- function sortResources(filteredResources) {
6187
- return filteredResources.slice().sort((a, b) => {
6188
- const valueA = a[PerformanceTimingNames.FETCH_START];
6189
- const valueB = b[PerformanceTimingNames.FETCH_START];
6190
- if (valueA > valueB) {
6191
- return 1;
6192
- }
6193
- else if (valueA < valueB) {
6194
- return -1;
6195
- }
6196
- return 0;
6197
- });
6198
- }
6199
- /** Returns the origin if present (if in browser context). */
6200
- function getOrigin() {
6201
- return typeof location !== 'undefined' ? location.origin : undefined;
6202
- }
6203
- /**
6204
- * Get closest performance resource ignoring the resources that have been
6205
- * already used.
6206
- * @param spanUrl
6207
- * @param startTimeHR
6208
- * @param endTimeHR
6209
- * @param resources
6210
- * @param ignoredResources
6211
- * @param initiatorType
6212
- */
6213
- function getResource(spanUrl, startTimeHR, endTimeHR, resources, ignoredResources = new WeakSet(), initiatorType) {
6214
- // de-relativize the URL before usage (does no harm to absolute URLs)
6215
- const parsedSpanUrl = parseUrl(spanUrl);
6216
- spanUrl = parsedSpanUrl.toString();
6217
- const filteredResources = filterResourcesForSpan(spanUrl, startTimeHR, endTimeHR, resources, ignoredResources, initiatorType);
6218
- if (filteredResources.length === 0) {
6219
- return {
6220
- mainRequest: undefined,
6221
- };
6222
- }
6223
- if (filteredResources.length === 1) {
6224
- return {
6225
- mainRequest: filteredResources[0],
6226
- };
6227
- }
6228
- const sorted = sortResources(filteredResources);
6229
- if (parsedSpanUrl.origin !== getOrigin() && sorted.length > 1) {
6230
- let corsPreFlightRequest = sorted[0];
6231
- let mainRequest = findMainRequest(sorted, corsPreFlightRequest[PerformanceTimingNames.RESPONSE_END], endTimeHR);
6232
- const responseEnd = corsPreFlightRequest[PerformanceTimingNames.RESPONSE_END];
6233
- const fetchStart = mainRequest[PerformanceTimingNames.FETCH_START];
6234
- // no corsPreFlightRequest
6235
- if (fetchStart < responseEnd) {
6236
- mainRequest = corsPreFlightRequest;
6237
- corsPreFlightRequest = undefined;
6238
- }
6239
- return {
6240
- corsPreFlightRequest,
6241
- mainRequest,
6242
- };
6243
- }
6244
- else {
6245
- return {
6246
- mainRequest: filteredResources[0],
6247
- };
6248
- }
6249
- }
6250
- /**
6251
- * Will find the main request skipping the cors pre flight requests
6252
- * @param resources
6253
- * @param corsPreFlightRequestEndTime
6254
- * @param spanEndTimeHR
6255
- */
6256
- function findMainRequest(resources, corsPreFlightRequestEndTime, spanEndTimeHR) {
6257
- const spanEndTime = hrTimeToNanoseconds(spanEndTimeHR);
6258
- const minTime = hrTimeToNanoseconds(timeInputToHrTime(corsPreFlightRequestEndTime));
6259
- let mainRequest = resources[1];
6260
- let bestGap;
6261
- const length = resources.length;
6262
- for (let i = 1; i < length; i++) {
6263
- const resource = resources[i];
6264
- const resourceStartTime = hrTimeToNanoseconds(timeInputToHrTime(resource[PerformanceTimingNames.FETCH_START]));
6265
- const resourceEndTime = hrTimeToNanoseconds(timeInputToHrTime(resource[PerformanceTimingNames.RESPONSE_END]));
6266
- const currentGap = spanEndTime - resourceEndTime;
6267
- if (resourceStartTime >= minTime && (!bestGap || currentGap < bestGap)) {
6268
- bestGap = currentGap;
6269
- mainRequest = resource;
6270
- }
6271
- }
6272
- return mainRequest;
6273
- }
6274
- /**
6275
- * Filter all resources that has started and finished according to span start time and end time.
6276
- * It will return the closest resource to a start time
6277
- * @param spanUrl
6278
- * @param startTimeHR
6279
- * @param endTimeHR
6280
- * @param resources
6281
- * @param ignoredResources
6282
- */
6283
- function filterResourcesForSpan(spanUrl, startTimeHR, endTimeHR, resources, ignoredResources, initiatorType) {
6284
- const startTime = hrTimeToNanoseconds(startTimeHR);
6285
- const endTime = hrTimeToNanoseconds(endTimeHR);
6286
- let filteredResources = resources.filter(resource => {
6287
- const resourceStartTime = hrTimeToNanoseconds(timeInputToHrTime(resource[PerformanceTimingNames.FETCH_START]));
6288
- const resourceEndTime = hrTimeToNanoseconds(timeInputToHrTime(resource[PerformanceTimingNames.RESPONSE_END]));
6289
- return (resource.initiatorType.toLowerCase() ===
6290
- (initiatorType || 'xmlhttprequest') &&
6291
- resource.name === spanUrl &&
6292
- resourceStartTime >= startTime &&
6293
- resourceEndTime <= endTime);
6294
- });
6295
- if (filteredResources.length > 0) {
6296
- filteredResources = filteredResources.filter(resource => {
6297
- return !ignoredResources.has(resource);
6298
- });
6299
- }
6300
- return filteredResources;
6301
- }
6302
- /**
6303
- * Parses url using URL constructor or fallback to anchor element.
6304
- * @param url
6305
- */
6306
- function parseUrl(url) {
6307
- if (typeof URL === 'function') {
6308
- return new URL(url, typeof document !== 'undefined'
6309
- ? document.baseURI
6310
- : typeof location !== 'undefined' // Some JS runtimes (e.g. Deno) don't define this
6311
- ? location.href
6312
- : undefined);
6313
- }
6314
- const element = getUrlNormalizingAnchor();
6315
- element.href = url;
6316
- return element;
6317
- }
6318
- /**
6319
- * Checks if trace headers should be propagated
6320
- * @param spanUrl
6321
- * @private
6322
- */
6323
- function shouldPropagateTraceHeaders(spanUrl, propagateTraceHeaderCorsUrls) {
6324
- let propagateTraceHeaderUrls = propagateTraceHeaderCorsUrls || [];
6325
- if (typeof propagateTraceHeaderUrls === 'string' ||
6326
- propagateTraceHeaderUrls instanceof RegExp) {
6327
- propagateTraceHeaderUrls = [propagateTraceHeaderUrls];
6328
- }
6329
- const parsedSpanUrl = parseUrl(spanUrl);
6330
- if (parsedSpanUrl.origin === getOrigin()) {
6331
- return true;
6332
- }
6333
- else {
6334
- return propagateTraceHeaderUrls.some(propagateTraceHeaderUrl => urlMatches(spanUrl, propagateTraceHeaderUrl));
6335
- }
6336
- }
6337
6174
 
6338
6175
  /*
6339
6176
  * Copyright The OpenTelemetry Authors
@@ -6620,7 +6457,7 @@ var AttributeNames;
6620
6457
  * SPDX-License-Identifier: Apache-2.0
6621
6458
  */
6622
6459
  // this is autogenerated file, see scripts/version-update.js
6623
- const PACKAGE_VERSION = '0.67.0';
6460
+ const PACKAGE_VERSION = '0.68.0';
6624
6461
  const PACKAGE_NAME = '@opentelemetry/instrumentation-document-load';
6625
6462
 
6626
6463
  /*
@@ -6639,11 +6476,11 @@ var EventNames$1;
6639
6476
  */
6640
6477
  const getPerformanceNavigationEntries = () => {
6641
6478
  const entries = {};
6642
- const performanceNavigationTiming = otperformance.getEntriesByType?.('navigation')[0];
6479
+ const performanceNavigationTiming = performance.getEntriesByType?.('navigation')[0];
6643
6480
  if (performanceNavigationTiming) {
6644
- const keys = Object.values(PerformanceTimingNames);
6481
+ const keys = Object.values(PerformanceTimingNames$1);
6645
6482
  keys.forEach((key) => {
6646
- if (hasKey(performanceNavigationTiming, key)) {
6483
+ if (hasKey$1(performanceNavigationTiming, key)) {
6647
6484
  const value = performanceNavigationTiming[key];
6648
6485
  if (typeof value === 'number') {
6649
6486
  entries[key] = value;
@@ -6653,12 +6490,14 @@ const getPerformanceNavigationEntries = () => {
6653
6490
  }
6654
6491
  else {
6655
6492
  // // fallback to previous version
6656
- const perf = otperformance;
6493
+ const perf = performance;
6494
+ // PerformanceTiming is required for legacy browser support.
6495
+ // eslint-disable-next-line baseline-js/use-baseline
6657
6496
  const performanceTiming = perf.timing;
6658
6497
  if (performanceTiming) {
6659
- const keys = Object.values(PerformanceTimingNames);
6498
+ const keys = Object.values(PerformanceTimingNames$1);
6660
6499
  keys.forEach((key) => {
6661
- if (hasKey(performanceTiming, key)) {
6500
+ if (hasKey$1(performanceTiming, key)) {
6662
6501
  const value = performanceTiming[key];
6663
6502
  if (typeof value === 'number') {
6664
6503
  entries[key] = value;
@@ -6674,10 +6513,10 @@ const performancePaintNames = {
6674
6513
  'first-contentful-paint': EventNames$1.FIRST_CONTENTFUL_PAINT,
6675
6514
  };
6676
6515
  const addSpanPerformancePaintEvents = (span) => {
6677
- const performancePaintTiming = otperformance.getEntriesByType?.('paint');
6516
+ const performancePaintTiming = performance.getEntriesByType?.('paint');
6678
6517
  if (performancePaintTiming) {
6679
6518
  performancePaintTiming.forEach(({ name, startTime }) => {
6680
- if (hasKey(performancePaintNames, name)) {
6519
+ if (hasKey$1(performancePaintNames, name)) {
6681
6520
  span.addEvent(performancePaintNames[name], startTime);
6682
6521
  }
6683
6522
  });
@@ -6714,7 +6553,7 @@ class DocumentLoadInstrumentation extends InstrumentationBase {
6714
6553
  * @param rootSpan
6715
6554
  */
6716
6555
  _addResourcesSpans(rootSpan) {
6717
- const resources = otperformance.getEntriesByType?.('resource');
6556
+ const resources = performance.getEntriesByType?.('resource');
6718
6557
  if (resources) {
6719
6558
  resources.forEach(resource => {
6720
6559
  this._initResourceSpan(resource, rootSpan);
@@ -6729,18 +6568,18 @@ class DocumentLoadInstrumentation extends InstrumentationBase {
6729
6568
  const entries = getPerformanceNavigationEntries();
6730
6569
  const traceparent = (metaElement && metaElement.content) || '';
6731
6570
  context.with(propagation.extract(ROOT_CONTEXT, { traceparent }), () => {
6732
- const rootSpan = this._startSpan(AttributeNames.DOCUMENT_LOAD, PerformanceTimingNames.FETCH_START, entries);
6571
+ const rootSpan = this._startSpan(AttributeNames.DOCUMENT_LOAD, PerformanceTimingNames$1.FETCH_START, entries);
6733
6572
  if (!rootSpan) {
6734
6573
  return;
6735
6574
  }
6736
6575
  context.with(trace.setSpan(context.active(), rootSpan), () => {
6737
- const fetchSpan = this._startSpan(AttributeNames.DOCUMENT_FETCH, PerformanceTimingNames.FETCH_START, entries);
6576
+ const fetchSpan = this._startSpan(AttributeNames.DOCUMENT_FETCH, PerformanceTimingNames$1.FETCH_START, entries);
6738
6577
  if (fetchSpan) {
6739
6578
  fetchSpan.setAttribute(ATTR_URL_FULL, location.href);
6740
6579
  context.with(trace.setSpan(context.active(), fetchSpan), () => {
6741
- addSpanNetworkEvents(fetchSpan, entries, this.getConfig().ignoreNetworkEvents);
6580
+ addSpanNetworkEvents$1(fetchSpan, entries, this.getConfig().ignoreNetworkEvents);
6742
6581
  this._addCustomAttributesOnSpan(fetchSpan, this.getConfig().applyCustomAttributesOnSpan?.documentFetch);
6743
- this._endSpan(fetchSpan, PerformanceTimingNames.RESPONSE_END, entries);
6582
+ this._endSpan(fetchSpan, PerformanceTimingNames$1.RESPONSE_END, entries);
6744
6583
  });
6745
6584
  }
6746
6585
  });
@@ -6748,21 +6587,21 @@ class DocumentLoadInstrumentation extends InstrumentationBase {
6748
6587
  rootSpan.setAttribute(ATTR_USER_AGENT_ORIGINAL, navigator.userAgent);
6749
6588
  this._addResourcesSpans(rootSpan);
6750
6589
  if (!this.getConfig().ignoreNetworkEvents) {
6751
- addSpanNetworkEvent(rootSpan, PerformanceTimingNames.FETCH_START, entries);
6752
- addSpanNetworkEvent(rootSpan, PerformanceTimingNames.UNLOAD_EVENT_START, entries);
6753
- addSpanNetworkEvent(rootSpan, PerformanceTimingNames.UNLOAD_EVENT_END, entries);
6754
- addSpanNetworkEvent(rootSpan, PerformanceTimingNames.DOM_INTERACTIVE, entries);
6755
- addSpanNetworkEvent(rootSpan, PerformanceTimingNames.DOM_CONTENT_LOADED_EVENT_START, entries);
6756
- addSpanNetworkEvent(rootSpan, PerformanceTimingNames.DOM_CONTENT_LOADED_EVENT_END, entries);
6757
- addSpanNetworkEvent(rootSpan, PerformanceTimingNames.DOM_COMPLETE, entries);
6758
- addSpanNetworkEvent(rootSpan, PerformanceTimingNames.LOAD_EVENT_START, entries);
6759
- addSpanNetworkEvent(rootSpan, PerformanceTimingNames.LOAD_EVENT_END, entries);
6590
+ addSpanNetworkEvent$1(rootSpan, PerformanceTimingNames$1.FETCH_START, entries);
6591
+ addSpanNetworkEvent$1(rootSpan, PerformanceTimingNames$1.UNLOAD_EVENT_START, entries);
6592
+ addSpanNetworkEvent$1(rootSpan, PerformanceTimingNames$1.UNLOAD_EVENT_END, entries);
6593
+ addSpanNetworkEvent$1(rootSpan, PerformanceTimingNames$1.DOM_INTERACTIVE, entries);
6594
+ addSpanNetworkEvent$1(rootSpan, PerformanceTimingNames$1.DOM_CONTENT_LOADED_EVENT_START, entries);
6595
+ addSpanNetworkEvent$1(rootSpan, PerformanceTimingNames$1.DOM_CONTENT_LOADED_EVENT_END, entries);
6596
+ addSpanNetworkEvent$1(rootSpan, PerformanceTimingNames$1.DOM_COMPLETE, entries);
6597
+ addSpanNetworkEvent$1(rootSpan, PerformanceTimingNames$1.LOAD_EVENT_START, entries);
6598
+ addSpanNetworkEvent$1(rootSpan, PerformanceTimingNames$1.LOAD_EVENT_END, entries);
6760
6599
  }
6761
6600
  if (!this.getConfig().ignorePerformancePaintEvents) {
6762
6601
  addSpanPerformancePaintEvents(rootSpan);
6763
6602
  }
6764
6603
  this._addCustomAttributesOnSpan(rootSpan, this.getConfig().applyCustomAttributesOnSpan?.documentLoad);
6765
- this._endSpan(rootSpan, PerformanceTimingNames.LOAD_EVENT_END, entries);
6604
+ this._endSpan(rootSpan, PerformanceTimingNames$1.LOAD_EVENT_END, entries);
6766
6605
  });
6767
6606
  }
6768
6607
  /**
@@ -6774,7 +6613,7 @@ class DocumentLoadInstrumentation extends InstrumentationBase {
6774
6613
  _endSpan(span, performanceName, entries) {
6775
6614
  // span can be undefined when entries are missing the certain performance - the span will not be created
6776
6615
  if (span) {
6777
- if (hasKey(entries, performanceName)) {
6616
+ if (hasKey$1(entries, performanceName)) {
6778
6617
  span.end(entries[performanceName]);
6779
6618
  }
6780
6619
  else {
@@ -6789,12 +6628,12 @@ class DocumentLoadInstrumentation extends InstrumentationBase {
6789
6628
  * @param parentSpan
6790
6629
  */
6791
6630
  _initResourceSpan(resource, parentSpan) {
6792
- const span = this._startSpan(AttributeNames.RESOURCE_FETCH, PerformanceTimingNames.FETCH_START, resource, parentSpan);
6631
+ const span = this._startSpan(AttributeNames.RESOURCE_FETCH, PerformanceTimingNames$1.FETCH_START, resource, parentSpan);
6793
6632
  if (span) {
6794
6633
  span.setAttribute(ATTR_URL_FULL, resource.name);
6795
- addSpanNetworkEvents(span, resource, this.getConfig().ignoreNetworkEvents);
6634
+ addSpanNetworkEvents$1(span, resource, this.getConfig().ignoreNetworkEvents);
6796
6635
  this._addCustomAttributesOnResourceSpan(span, resource, this.getConfig().applyCustomAttributesOnSpan?.resourceFetch);
6797
- this._endSpan(span, PerformanceTimingNames.RESPONSE_END, resource);
6636
+ this._endSpan(span, PerformanceTimingNames$1.RESPONSE_END, resource);
6798
6637
  }
6799
6638
  }
6800
6639
  /**
@@ -6805,7 +6644,7 @@ class DocumentLoadInstrumentation extends InstrumentationBase {
6805
6644
  * @param parentSpan
6806
6645
  */
6807
6646
  _startSpan(spanName, performanceName, entries, parentSpan) {
6808
- if (hasKey(entries, performanceName) &&
6647
+ if (hasKey$1(entries, performanceName) &&
6809
6648
  typeof entries[performanceName] === 'number') {
6810
6649
  const span = this.tracer.startSpan(spanName, {
6811
6650
  startTime: entries[performanceName],
@@ -6869,6 +6708,257 @@ class DocumentLoadInstrumentation extends InstrumentationBase {
6869
6708
  }
6870
6709
  }
6871
6710
 
6711
+ /*
6712
+ * Copyright The OpenTelemetry Authors
6713
+ * SPDX-License-Identifier: Apache-2.0
6714
+ */
6715
+ /**
6716
+ * @deprecated See https://github.com/open-telemetry/opentelemetry-js/issues/3174
6717
+ */
6718
+ var PerformanceTimingNames;
6719
+ (function (PerformanceTimingNames) {
6720
+ PerformanceTimingNames["CONNECT_END"] = "connectEnd";
6721
+ PerformanceTimingNames["CONNECT_START"] = "connectStart";
6722
+ PerformanceTimingNames["DECODED_BODY_SIZE"] = "decodedBodySize";
6723
+ PerformanceTimingNames["DOM_COMPLETE"] = "domComplete";
6724
+ PerformanceTimingNames["DOM_CONTENT_LOADED_EVENT_END"] = "domContentLoadedEventEnd";
6725
+ PerformanceTimingNames["DOM_CONTENT_LOADED_EVENT_START"] = "domContentLoadedEventStart";
6726
+ PerformanceTimingNames["DOM_INTERACTIVE"] = "domInteractive";
6727
+ PerformanceTimingNames["DOMAIN_LOOKUP_END"] = "domainLookupEnd";
6728
+ PerformanceTimingNames["DOMAIN_LOOKUP_START"] = "domainLookupStart";
6729
+ PerformanceTimingNames["ENCODED_BODY_SIZE"] = "encodedBodySize";
6730
+ PerformanceTimingNames["FETCH_START"] = "fetchStart";
6731
+ PerformanceTimingNames["LOAD_EVENT_END"] = "loadEventEnd";
6732
+ PerformanceTimingNames["LOAD_EVENT_START"] = "loadEventStart";
6733
+ PerformanceTimingNames["NAVIGATION_START"] = "navigationStart";
6734
+ PerformanceTimingNames["REDIRECT_END"] = "redirectEnd";
6735
+ PerformanceTimingNames["REDIRECT_START"] = "redirectStart";
6736
+ PerformanceTimingNames["REQUEST_START"] = "requestStart";
6737
+ PerformanceTimingNames["RESPONSE_END"] = "responseEnd";
6738
+ PerformanceTimingNames["RESPONSE_START"] = "responseStart";
6739
+ PerformanceTimingNames["SECURE_CONNECTION_START"] = "secureConnectionStart";
6740
+ PerformanceTimingNames["START_TIME"] = "startTime";
6741
+ PerformanceTimingNames["UNLOAD_EVENT_END"] = "unloadEventEnd";
6742
+ PerformanceTimingNames["UNLOAD_EVENT_START"] = "unloadEventStart";
6743
+ })(PerformanceTimingNames || (PerformanceTimingNames = {}));
6744
+
6745
+ /*
6746
+ * Copyright The OpenTelemetry Authors
6747
+ * SPDX-License-Identifier: Apache-2.0
6748
+ */
6749
+ // Used to normalize relative URLs
6750
+ let urlNormalizingAnchor;
6751
+ function getUrlNormalizingAnchor() {
6752
+ if (!urlNormalizingAnchor) {
6753
+ urlNormalizingAnchor = document.createElement('a');
6754
+ }
6755
+ return urlNormalizingAnchor;
6756
+ }
6757
+ /**
6758
+ * Helper function to be able to use enum as typed key in type and in interface when using forEach
6759
+ * @param obj
6760
+ * @param key
6761
+ * @deprecated See https://github.com/open-telemetry/opentelemetry-js/issues/3174
6762
+ */
6763
+ function hasKey(obj, key) {
6764
+ return key in obj;
6765
+ }
6766
+ /**
6767
+ * Helper function for starting an event on span based on {@link PerformanceEntries}
6768
+ * @param span
6769
+ * @param performanceName name of performance entry for time start
6770
+ * @param entries
6771
+ * @param ignoreZeros
6772
+ * @deprecated See https://github.com/open-telemetry/opentelemetry-js/issues/3174
6773
+ */
6774
+ function addSpanNetworkEvent(span, performanceName, entries, ignoreZeros = true) {
6775
+ if (hasKey(entries, performanceName) &&
6776
+ typeof entries[performanceName] === 'number' &&
6777
+ !(ignoreZeros && entries[performanceName] === 0)) {
6778
+ return span.addEvent(performanceName, entries[performanceName]);
6779
+ }
6780
+ return undefined;
6781
+ }
6782
+ /**
6783
+ * Helper function for adding network events and content length attributes.
6784
+ * @deprecated See https://github.com/open-telemetry/opentelemetry-js/issues/3174
6785
+ */
6786
+ function addSpanNetworkEvents(span, resource, ignoreNetworkEvents = false, ignoreZeros) {
6787
+ if (ignoreZeros === undefined) {
6788
+ ignoreZeros = resource[PerformanceTimingNames.START_TIME] !== 0;
6789
+ }
6790
+ if (!ignoreNetworkEvents) {
6791
+ addSpanNetworkEvent(span, PerformanceTimingNames.FETCH_START, resource, ignoreZeros);
6792
+ addSpanNetworkEvent(span, PerformanceTimingNames.DOMAIN_LOOKUP_START, resource, ignoreZeros);
6793
+ addSpanNetworkEvent(span, PerformanceTimingNames.DOMAIN_LOOKUP_END, resource, ignoreZeros);
6794
+ addSpanNetworkEvent(span, PerformanceTimingNames.CONNECT_START, resource, ignoreZeros);
6795
+ addSpanNetworkEvent(span, PerformanceTimingNames.SECURE_CONNECTION_START, resource, ignoreZeros);
6796
+ addSpanNetworkEvent(span, PerformanceTimingNames.CONNECT_END, resource, ignoreZeros);
6797
+ addSpanNetworkEvent(span, PerformanceTimingNames.REQUEST_START, resource, ignoreZeros);
6798
+ addSpanNetworkEvent(span, PerformanceTimingNames.RESPONSE_START, resource, ignoreZeros);
6799
+ addSpanNetworkEvent(span, PerformanceTimingNames.RESPONSE_END, resource, ignoreZeros);
6800
+ }
6801
+ }
6802
+ /**
6803
+ * sort resources by startTime
6804
+ * @param filteredResources
6805
+ * @deprecated See https://github.com/open-telemetry/opentelemetry-js/issues/3174
6806
+ */
6807
+ function sortResources(filteredResources) {
6808
+ return filteredResources.slice().sort((a, b) => {
6809
+ const valueA = a[PerformanceTimingNames.FETCH_START];
6810
+ const valueB = b[PerformanceTimingNames.FETCH_START];
6811
+ if (valueA > valueB) {
6812
+ return 1;
6813
+ }
6814
+ else if (valueA < valueB) {
6815
+ return -1;
6816
+ }
6817
+ return 0;
6818
+ });
6819
+ }
6820
+ /** Returns the origin if present (if in browser context). */
6821
+ function getOrigin() {
6822
+ return typeof location !== 'undefined' ? location.origin : undefined;
6823
+ }
6824
+ /**
6825
+ * Get closest performance resource ignoring the resources that have been
6826
+ * already used.
6827
+ * @param spanUrl
6828
+ * @param startTimeHR
6829
+ * @param endTimeHR
6830
+ * @param resources
6831
+ * @param ignoredResources
6832
+ * @param initiatorType
6833
+ * @deprecated See https://github.com/open-telemetry/opentelemetry-js/issues/3174
6834
+ */
6835
+ function getResource(spanUrl, startTimeHR, endTimeHR, resources, ignoredResources = new WeakSet(), initiatorType) {
6836
+ // de-relativize the URL before usage (does no harm to absolute URLs)
6837
+ const parsedSpanUrl = parseUrl(spanUrl);
6838
+ spanUrl = parsedSpanUrl.toString();
6839
+ const filteredResources = filterResourcesForSpan(spanUrl, startTimeHR, endTimeHR, resources, ignoredResources, initiatorType);
6840
+ if (filteredResources.length === 0) {
6841
+ return {
6842
+ mainRequest: undefined,
6843
+ };
6844
+ }
6845
+ if (filteredResources.length === 1) {
6846
+ return {
6847
+ mainRequest: filteredResources[0],
6848
+ };
6849
+ }
6850
+ const sorted = sortResources(filteredResources);
6851
+ if (parsedSpanUrl.origin !== getOrigin() && sorted.length > 1) {
6852
+ let corsPreFlightRequest = sorted[0];
6853
+ let mainRequest = findMainRequest(sorted, corsPreFlightRequest[PerformanceTimingNames.RESPONSE_END], endTimeHR);
6854
+ const responseEnd = corsPreFlightRequest[PerformanceTimingNames.RESPONSE_END];
6855
+ const fetchStart = mainRequest[PerformanceTimingNames.FETCH_START];
6856
+ // no corsPreFlightRequest
6857
+ if (fetchStart < responseEnd) {
6858
+ mainRequest = corsPreFlightRequest;
6859
+ corsPreFlightRequest = undefined;
6860
+ }
6861
+ return {
6862
+ corsPreFlightRequest,
6863
+ mainRequest,
6864
+ };
6865
+ }
6866
+ else {
6867
+ return {
6868
+ mainRequest: filteredResources[0],
6869
+ };
6870
+ }
6871
+ }
6872
+ /**
6873
+ * Will find the main request skipping the cors pre flight requests
6874
+ * @param resources
6875
+ * @param corsPreFlightRequestEndTime
6876
+ * @param spanEndTimeHR
6877
+ */
6878
+ function findMainRequest(resources, corsPreFlightRequestEndTime, spanEndTimeHR) {
6879
+ const spanEndTime = hrTimeToNanoseconds(spanEndTimeHR);
6880
+ const minTime = hrTimeToNanoseconds(timeInputToHrTime(corsPreFlightRequestEndTime));
6881
+ let mainRequest = resources[1];
6882
+ let bestGap;
6883
+ const length = resources.length;
6884
+ for (let i = 1; i < length; i++) {
6885
+ const resource = resources[i];
6886
+ const resourceStartTime = hrTimeToNanoseconds(timeInputToHrTime(resource[PerformanceTimingNames.FETCH_START]));
6887
+ const resourceEndTime = hrTimeToNanoseconds(timeInputToHrTime(resource[PerformanceTimingNames.RESPONSE_END]));
6888
+ const currentGap = spanEndTime - resourceEndTime;
6889
+ if (resourceStartTime >= minTime && (!bestGap || currentGap < bestGap)) {
6890
+ bestGap = currentGap;
6891
+ mainRequest = resource;
6892
+ }
6893
+ }
6894
+ return mainRequest;
6895
+ }
6896
+ /**
6897
+ * Filter all resources that has started and finished according to span start time and end time.
6898
+ * It will return the closest resource to a start time
6899
+ * @param spanUrl
6900
+ * @param startTimeHR
6901
+ * @param endTimeHR
6902
+ * @param resources
6903
+ * @param ignoredResources
6904
+ */
6905
+ function filterResourcesForSpan(spanUrl, startTimeHR, endTimeHR, resources, ignoredResources, initiatorType) {
6906
+ const startTime = hrTimeToNanoseconds(startTimeHR);
6907
+ const endTime = hrTimeToNanoseconds(endTimeHR);
6908
+ let filteredResources = resources.filter(resource => {
6909
+ const resourceStartTime = hrTimeToNanoseconds(timeInputToHrTime(resource[PerformanceTimingNames.FETCH_START]));
6910
+ const resourceEndTime = hrTimeToNanoseconds(timeInputToHrTime(resource[PerformanceTimingNames.RESPONSE_END]));
6911
+ return (resource.initiatorType.toLowerCase() ===
6912
+ (initiatorType || 'xmlhttprequest') &&
6913
+ resource.name === spanUrl &&
6914
+ resourceStartTime >= startTime &&
6915
+ resourceEndTime <= endTime);
6916
+ });
6917
+ if (filteredResources.length > 0) {
6918
+ filteredResources = filteredResources.filter(resource => {
6919
+ return !ignoredResources.has(resource);
6920
+ });
6921
+ }
6922
+ return filteredResources;
6923
+ }
6924
+ /**
6925
+ * Parses url using URL constructor or fallback to anchor element.
6926
+ * @param url
6927
+ * @deprecated See https://github.com/open-telemetry/opentelemetry-js/issues/3174
6928
+ */
6929
+ function parseUrl(url) {
6930
+ if (typeof URL === 'function') {
6931
+ return new URL(url, typeof document !== 'undefined'
6932
+ ? document.baseURI
6933
+ : typeof location !== 'undefined' // Some JS runtimes (e.g. Deno) don't define this
6934
+ ? location.href
6935
+ : undefined);
6936
+ }
6937
+ const element = getUrlNormalizingAnchor();
6938
+ element.href = url;
6939
+ return element;
6940
+ }
6941
+ /**
6942
+ * Checks if trace headers should be propagated
6943
+ * @param spanUrl
6944
+ * @private
6945
+ * @deprecated See https://github.com/open-telemetry/opentelemetry-js/issues/3174
6946
+ */
6947
+ function shouldPropagateTraceHeaders(spanUrl, propagateTraceHeaderCorsUrls) {
6948
+ let propagateTraceHeaderUrls = propagateTraceHeaderCorsUrls || [];
6949
+ if (typeof propagateTraceHeaderUrls === 'string' ||
6950
+ propagateTraceHeaderUrls instanceof RegExp) {
6951
+ propagateTraceHeaderUrls = [propagateTraceHeaderUrls];
6952
+ }
6953
+ const parsedSpanUrl = parseUrl(spanUrl);
6954
+ if (parsedSpanUrl.origin === getOrigin()) {
6955
+ return true;
6956
+ }
6957
+ else {
6958
+ return propagateTraceHeaderUrls.some(propagateTraceHeaderUrl => urlMatches(spanUrl, propagateTraceHeaderUrl));
6959
+ }
6960
+ }
6961
+
6872
6962
  /*
6873
6963
  * Copyright The OpenTelemetry Authors
6874
6964
  * SPDX-License-Identifier: Apache-2.0
@@ -7088,7 +7178,7 @@ function serverPortFromUrl$1(url) {
7088
7178
  * SPDX-License-Identifier: Apache-2.0
7089
7179
  */
7090
7180
  // this is autogenerated file, see scripts/version-update.js
7091
- const VERSION$1 = '0.222.0';
7181
+ const VERSION$1 = '0.223.0';
7092
7182
 
7093
7183
  /*
7094
7184
  * Copyright The OpenTelemetry Authors
@@ -7122,7 +7212,7 @@ class FetchInstrumentation extends InstrumentationBase {
7122
7212
  const childSpan = this.tracer.startSpan('CORS Preflight', {
7123
7213
  startTime: corsPreFlightRequest[PerformanceTimingNames.FETCH_START],
7124
7214
  }, trace.setSpan(context.active(), span));
7125
- addSpanNetworkEvents(childSpan, corsPreFlightRequest, this.getConfig().ignoreNetworkEvents, undefined, true);
7215
+ addSpanNetworkEvents(childSpan, corsPreFlightRequest, this.getConfig().ignoreNetworkEvents, undefined);
7126
7216
  childSpan.end(corsPreFlightRequest[PerformanceTimingNames.RESPONSE_END]);
7127
7217
  }
7128
7218
  /**
@@ -7235,7 +7325,7 @@ class FetchInstrumentation extends InstrumentationBase {
7235
7325
  this._addChildSpan(span, corsPreFlightRequest);
7236
7326
  this._markResourceAsUsed(corsPreFlightRequest);
7237
7327
  }
7238
- addSpanNetworkEvents(span, mainRequest, this.getConfig().ignoreNetworkEvents, undefined, true);
7328
+ addSpanNetworkEvents(span, mainRequest, this.getConfig().ignoreNetworkEvents, undefined);
7239
7329
  }
7240
7330
  }
7241
7331
  /**
@@ -7260,7 +7350,7 @@ class FetchInstrumentation extends InstrumentationBase {
7260
7350
  // https://github.com/open-telemetry/semantic-conventions/blob/main/docs/http/http-spans.md#status
7261
7351
  if (response.status >= 400) {
7262
7352
  span.setStatus({ code: SpanStatusCode.ERROR });
7263
- span.setAttribute(ATTR_ERROR_TYPE$1, String(response.status));
7353
+ span.setAttribute(ATTR_ERROR_TYPE, String(response.status));
7264
7354
  }
7265
7355
  setTimeout(() => {
7266
7356
  spanData.observer?.disconnect();
@@ -7640,7 +7730,7 @@ function serverPortFromUrl(url) {
7640
7730
  * SPDX-License-Identifier: Apache-2.0
7641
7731
  */
7642
7732
  // this is autogenerated file, see scripts/version-update.js
7643
- const VERSION = '0.222.0';
7733
+ const VERSION = '0.223.0';
7644
7734
 
7645
7735
  /*
7646
7736
  * Copyright The OpenTelemetry Authors
@@ -7698,7 +7788,7 @@ class XMLHttpRequestInstrumentation extends InstrumentationBase {
7698
7788
  const childSpan = this.tracer.startSpan('CORS Preflight', {
7699
7789
  startTime: corsPreFlightRequest[PerformanceTimingNames.FETCH_START],
7700
7790
  });
7701
- addSpanNetworkEvents(childSpan, corsPreFlightRequest, this.getConfig().ignoreNetworkEvents, undefined, true);
7791
+ addSpanNetworkEvents(childSpan, corsPreFlightRequest, this.getConfig().ignoreNetworkEvents, undefined);
7702
7792
  childSpan.end(corsPreFlightRequest[PerformanceTimingNames.RESPONSE_END]);
7703
7793
  });
7704
7794
  }
@@ -7798,7 +7888,7 @@ class XMLHttpRequestInstrumentation extends InstrumentationBase {
7798
7888
  this._addChildSpan(span, corsPreFlightRequest);
7799
7889
  this._markResourceAsUsed(corsPreFlightRequest);
7800
7890
  }
7801
- addSpanNetworkEvents(span, mainRequest, this.getConfig().ignoreNetworkEvents, undefined, true);
7891
+ addSpanNetworkEvents(span, mainRequest, this.getConfig().ignoreNetworkEvents, undefined);
7802
7892
  }
7803
7893
  }
7804
7894
  /**
@@ -7922,12 +8012,12 @@ class XMLHttpRequestInstrumentation extends InstrumentationBase {
7922
8012
  code: SpanStatusCode.ERROR,
7923
8013
  message: errorType,
7924
8014
  });
7925
- span.setAttribute(ATTR_ERROR_TYPE$1, errorType);
8015
+ span.setAttribute(ATTR_ERROR_TYPE, errorType);
7926
8016
  }
7927
8017
  }
7928
8018
  else if (xhrMem.status && xhrMem.status >= 400) {
7929
8019
  span.setStatus({ code: SpanStatusCode.ERROR });
7930
- span.setAttribute(ATTR_ERROR_TYPE$1, String(xhrMem.status));
8020
+ span.setAttribute(ATTR_ERROR_TYPE, String(xhrMem.status));
7931
8021
  }
7932
8022
  }
7933
8023
  const performanceEndTime = hrTime();
@@ -8134,4 +8224,4 @@ function enableDevServerTracing(endpoint) {
8134
8224
  }
8135
8225
 
8136
8226
  export { enableDevServerTracing };
8137
- //# sourceMappingURL=enable-dev-server-tracing-DaQc5M9V.js.map
8227
+ //# sourceMappingURL=enable-dev-server-tracing-GfRoCLxu.js.map