Skip to content

Commit

Permalink
chore(opentelemetry-instrumentation-fetch): Merge main and fix the co…
Browse files Browse the repository at this point in the history
…nflicts for the fetch.test.ts file

Signed-off-by: patricklafrance <[email protected]>
  • Loading branch information
patricklafrance committed Jan 30, 2025
2 parents 19bd801 + 29d0da5 commit 9dfe87d
Show file tree
Hide file tree
Showing 82 changed files with 4,049 additions and 6,253 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,19 @@ For semantic convention package changes, see the [semconv CHANGELOG](packages/se
* (user-facing): deprecated `AlwaysOffSampler` has moved to `@opentelemetry/sdk-trace-base`
* (user-facing): deprecated `TraceIdRatioSampler` has moved to `@opentelemetry/sdk-trace-base`
* (user-facing): deprecated `TraceIdRatioSampler` has moved to `@opentelemetry/sdk-trace-base`
* feat(sdk-trace-base)!: drop ability to instantiate propagators beyond defaults [#5355](https://github.com/open-telemetry/opentelemetry-js/pull/5355) @pichlermarc
* (user-facing): only a non-env-var based default is now used on `BasicTracerProvider#register()`.
* propagators can now not be configured via `OTEL_PROPAGATORS` or `window.OTEL_PROPAGATORS` anymore, please pass the propagator to `NodeTracerProvider#register()` instead.
* if not configured directly via code, `BasicTracerProvider#register()` will now fall back to defaults (`tracecontext` and `baggage`)
* feat(sdk-trace-node)!: drop ability to instantiate propagators beyond defaults [#5355](https://github.com/open-telemetry/opentelemetry-js/pull/5355) @pichlermarc
* (user-facing): only a non-env-var based default is now used on `NodeTracerProvider#register()`.
* propagators can now not be configured via `OTEL_PROPAGATORS` anymore, please pass the propagator to `NodeTracerProvider#register()` instead.
* if not configured via code, `NodeTracerProvider#register()` will now fall back to the defaults (`tracecontext` and `baggage`)
* if autoconfiguration based on enviornment variables is needed, please use `NodeSDK` from `@opentelemetry/sdk-node`.
* feat(sdk-trace-web)!: drop ability to instantiate propagators beyond defaults [#5355](https://github.com/open-telemetry/opentelemetry-js/pull/5355) @pichlermarc
* (user-facing): only a non-env-var based default is now used on `WebTracerProvider#register()`.
* propagators can now not be configured via `window.OTEL_PROPAGATORS` anymore, please pass the propagator to `WebTracerProvider#register()` instead.
* if not configured via code, `WebTracerProvider#register()` will now fall back to defaults (`tracecontext` and `baggage`)

### :rocket: (Enhancement)

Expand All @@ -61,6 +74,7 @@ For semantic convention package changes, see the [semconv CHANGELOG](packages/se

### :bug: (Bug Fix)

* fix(exporter-zipkin): remove usages of deprecated `url.parse` from `node:url` [#5390](https://github.com/open-telemetry/opentelemetry-js/pull/5390) @chancancode
* fix(sdk-metrics): do not export from `PeriodicExportingMetricReader` when there are no metrics to export. [#5288](https://github.com/open-telemetry/opentelemetry-js/pull/5288) @jacksonweber

### :books: (Refine Doc)
Expand Down
2 changes: 1 addition & 1 deletion api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
"karma-webpack": "5.0.1",
"lerna": "6.6.2",
"memfs": "3.5.3",
"mocha": "10.8.2",
"mocha": "11.1.0",
"nyc": "17.1.0",
"sinon": "15.1.2",
"ts-loader": "9.5.2",
Expand Down
2 changes: 2 additions & 0 deletions experimental/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ All notable changes to experimental packages in this project will be documented

* fix(instrumentation-grpc): monitor error events with events.errorMonitor [#5369](https://github.com/open-telemetry/opentelemetry-js/pull/5369) @cjihrig
* fix(exporter-metrics-otlp-http): browser OTLPMetricExporter was not passing config to OTLPMetricExporterBase super class [#5331](https://github.com/open-telemetry/opentelemetry-js/pull/5331) @trentm
* fix(instrumentation-fetch, instrumentation-xhr): Ignore network events with zero-timings [#5332](https://github.com/open-telemetry/opentelemetry-js/pull/5332) @chancancode

### :books: (Refine Doc)

Expand All @@ -33,6 +34,7 @@ All notable changes to experimental packages in this project will be documented
* chore(instrumentation-grpc): remove unused findIndex() function [#5372](https://github.com/open-telemetry/opentelemetry-js/pull/5372) @cjihrig
* refactor(otlp-exporter-base): remove unnecessary isNaN() checks [#5374](https://github.com/open-telemetry/opentelemetry-js/pull/5374) @cjihrig
* refactor(exporter-prometheus): remove unnecessary isNaN() check [#5377](https://github.com/open-telemetry/opentelemetry-js/pull/5377) @cjihrig
* refactor(sdk-node): move code to auto-instantiate propagators into utils [#5355](https://github.com/open-telemetry/opentelemetry-js/pull/5355) @pichlermarc

## 0.57.0

Expand Down
2 changes: 1 addition & 1 deletion experimental/packages/api-events/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
"karma-spec-reporter": "0.0.36",
"karma-webpack": "5.0.1",
"lerna": "6.6.2",
"mocha": "10.8.2",
"mocha": "11.1.0",
"nyc": "17.1.0",
"ts-loader": "9.5.2",
"typescript": "5.0.4",
Expand Down
2 changes: 1 addition & 1 deletion experimental/packages/api-logs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
"karma-spec-reporter": "0.0.36",
"karma-webpack": "5.0.1",
"lerna": "6.6.2",
"mocha": "10.8.2",
"mocha": "11.1.0",
"nyc": "17.1.0",
"ts-loader": "9.5.2",
"typescript": "5.0.4",
Expand Down
2 changes: 1 addition & 1 deletion experimental/packages/exporter-logs-otlp-grpc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"@types/sinon": "17.0.3",
"cross-var": "1.1.0",
"lerna": "6.6.2",
"mocha": "10.8.2",
"mocha": "11.1.0",
"nyc": "17.1.0",
"sinon": "15.1.2",
"ts-loader": "9.5.2",
Expand Down
2 changes: 1 addition & 1 deletion experimental/packages/exporter-logs-otlp-grpc/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
/* eslint no-restricted-syntax: ["warn", "ExportAllDeclaration"] --
* TODO: Replace wildcard export with named exports before next major version
*/
export * from './OTLPLogExporter';
export { OTLPLogExporter } from './OTLPLogExporter';
2 changes: 1 addition & 1 deletion experimental/packages/exporter-logs-otlp-http/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
"karma-spec-reporter": "0.0.36",
"karma-webpack": "5.0.1",
"lerna": "6.6.2",
"mocha": "10.8.2",
"mocha": "11.1.0",
"nyc": "17.1.0",
"sinon": "15.1.2",
"ts-loader": "9.5.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"karma-spec-reporter": "0.0.36",
"karma-webpack": "5.0.1",
"lerna": "6.6.2",
"mocha": "10.8.2",
"mocha": "11.1.0",
"nyc": "17.1.0",
"sinon": "15.1.2",
"ts-loader": "9.5.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"@types/sinon": "17.0.3",
"cross-var": "1.1.0",
"lerna": "6.6.2",
"mocha": "10.8.2",
"mocha": "11.1.0",
"nyc": "17.1.0",
"sinon": "15.1.2",
"ts-loader": "9.5.2",
Expand Down
5 changes: 1 addition & 4 deletions experimental/packages/exporter-trace-otlp-grpc/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,4 @@
* limitations under the License.
*/

/* eslint no-restricted-syntax: ["warn", "ExportAllDeclaration"] --
* TODO: Replace wildcard export with named exports before next major version
*/
export * from './OTLPTraceExporter';
export { OTLPTraceExporter } from './OTLPTraceExporter';
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
"karma-spec-reporter": "0.0.36",
"karma-webpack": "5.0.1",
"lerna": "6.6.2",
"mocha": "10.8.2",
"mocha": "11.1.0",
"nyc": "17.1.0",
"sinon": "15.1.2",
"ts-loader": "9.5.2",
Expand Down
5 changes: 1 addition & 4 deletions experimental/packages/exporter-trace-otlp-http/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,4 @@
* limitations under the License.
*/

/* eslint no-restricted-syntax: ["warn", "ExportAllDeclaration"] --
* TODO: Replace wildcard export with named exports before next major version
*/
export * from './platform';
export { OTLPTraceExporter } from './platform';
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,4 @@
* limitations under the License.
*/

/* eslint no-restricted-syntax: ["warn", "ExportAllDeclaration"] --
* TODO: Replace wildcard export with named exports before next major version
*/
export * from './OTLPTraceExporter';
export { OTLPTraceExporter } from './OTLPTraceExporter';
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,4 @@
* limitations under the License.
*/

/* eslint no-restricted-syntax: ["warn", "ExportAllDeclaration"] --
* TODO: Replace wildcard export with named exports before next major version
*/
export * from './node';
export { OTLPTraceExporter } from './node';
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,4 @@
* limitations under the License.
*/

/* eslint no-restricted-syntax: ["warn", "ExportAllDeclaration"] --
* TODO: Replace wildcard export with named exports before next major version
*/
export * from './OTLPTraceExporter';
export { OTLPTraceExporter } from './OTLPTraceExporter';
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
"karma-spec-reporter": "0.0.36",
"karma-webpack": "5.0.1",
"lerna": "6.6.2",
"mocha": "10.8.2",
"mocha": "11.1.0",
"nyc": "17.1.0",
"sinon": "15.1.2",
"ts-loader": "9.5.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"karma-spec-reporter": "0.0.36",
"karma-webpack": "5.0.1",
"lerna": "6.6.2",
"mocha": "10.8.2",
"mocha": "11.1.0",
"nyc": "17.1.0",
"sinon": "15.1.2",
"ts-loader": "9.5.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ class BrowserDetector implements Detector {
// Add Browser related attributes to resources
function getBrowserAttributes(): Attributes {
const browserAttribs: Attributes = {};
const userAgentData: UserAgentData | undefined = (navigator as any)
.userAgentData;
const userAgentData = (
navigator as Navigator & { userAgentData?: UserAgentData }
).userAgentData;
if (userAgentData) {
browserAttribs[BROWSER_ATTRIBUTES.PLATFORM] = userAgentData.platform;
browserAttribs[BROWSER_ATTRIBUTES.BRANDS] = userAgentData.brands.map(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"@types/sinon": "17.0.3",
"cross-var": "1.1.0",
"lerna": "6.6.2",
"mocha": "10.8.2",
"mocha": "11.1.0",
"nyc": "17.1.0",
"sinon": "15.1.2",
"ts-loader": "9.5.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,4 @@
* limitations under the License.
*/

/* eslint no-restricted-syntax: ["warn", "ExportAllDeclaration"] --
* TODO: Replace wildcard export with named exports before next major version
*/
export * from './OTLPMetricExporter';
export { OTLPMetricExporter } from './OTLPMetricExporter';
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
"karma-spec-reporter": "0.0.36",
"karma-webpack": "5.0.1",
"lerna": "6.6.2",
"mocha": "10.8.2",
"mocha": "11.1.0",
"nyc": "17.1.0",
"sinon": "15.1.2",
"ts-loader": "9.5.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,18 +111,14 @@ function chooseTemporalitySelector(
return chooseTemporalitySelectorFromEnvironment();
}

const DEFAULT_AGGREGATION = Object.freeze({
type: AggregationType.DEFAULT,
});

function chooseAggregationSelector(
config: OTLPMetricExporterOptions | undefined
) {
if (config?.aggregationPreference) {
return config.aggregationPreference;
} else {
return (_instrumentType: any) => {
return {
type: AggregationType.DEFAULT,
};
};
}
): AggregationSelector {
return config?.aggregationPreference ?? (() => DEFAULT_AGGREGATION);
}

export class OTLPMetricExporterBase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"@types/sinon": "17.0.3",
"cross-var": "1.1.0",
"lerna": "6.6.2",
"mocha": "10.8.2",
"mocha": "11.1.0",
"nyc": "17.1.0",
"sinon": "15.1.2",
"ts-loader": "9.5.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,4 @@
* limitations under the License.
*/

/* eslint no-restricted-syntax: ["warn", "ExportAllDeclaration"] --
* TODO: Replace wildcard export with named exports before next major version
*/
export * from './OTLPMetricExporter';
export { OTLPMetricExporter } from './OTLPMetricExporter';
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"@types/sinon": "17.0.3",
"cross-var": "1.1.0",
"lerna": "6.6.2",
"mocha": "10.8.2",
"mocha": "11.1.0",
"nyc": "17.1.0",
"sinon": "15.1.2",
"typescript": "5.0.4"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ const karmaBaseConfig = require('../../../karma.base');

module.exports = (config) => {
config.set(Object.assign({}, karmaBaseConfig, {
webpack: karmaWebpackConfig
proxies: {
'/mockServiceWorker.js': '/base/test/mockServiceWorker.js',
},
files: [...karmaBaseConfig.files, 'test/mockServiceWorker.js'],
webpack: karmaWebpackConfig,
}))
};
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@
"karma-spec-reporter": "0.0.36",
"karma-webpack": "5.0.1",
"lerna": "6.6.2",
"mocha": "10.8.2",
"mocha": "11.1.0",
"msw": "^2.7.0",
"nyc": "17.1.0",
"sinon": "15.1.2",
"ts-loader": "9.5.2",
Expand All @@ -92,5 +93,10 @@
"@opentelemetry/semantic-conventions": "1.28.0"
},
"homepage": "https://github.com/open-telemetry/opentelemetry-js/tree/main/experimental/packages/opentelemetry-instrumentation-fetch",
"sideEffects": false
"sideEffects": false,
"msw": {
"workerDirectory": [
"test"
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ function _getBodyNonDestructively(body: ReadableStream) {
};
}

function isDocument(value: unknown): value is Document {
return typeof Document !== 'undefined' && value instanceof Document;
}

/**
* Helper function to determine payload content length for XHR requests
* @param body
Expand All @@ -125,17 +129,17 @@ function _getBodyNonDestructively(body: ReadableStream) {
export function getXHRBodyLength(
body: Document | XMLHttpRequestBodyInit
): number | undefined {
if (typeof Document !== 'undefined' && body instanceof Document) {
if (isDocument(body)) {
return new XMLSerializer().serializeToString(document).length;
}

// XMLHttpRequestBodyInit expands to the following:
if (body instanceof Blob) {
return body.size;
if (typeof body === 'string') {
return getByteLength(body);
}

// ArrayBuffer | ArrayBufferView
if ((body as any).byteLength !== undefined) {
return (body as any).byteLength as number;
if (body instanceof Blob) {
return body.size;
}

if (body instanceof FormData) {
Expand All @@ -146,8 +150,9 @@ export function getXHRBodyLength(
return getByteLength(body.toString());
}

if (typeof body === 'string') {
return getByteLength(body);
// ArrayBuffer | ArrayBufferView
if (body.byteLength !== undefined) {
return body.byteLength;
}

DIAG_LOGGER.warn('unknown body type');
Expand Down
Loading

0 comments on commit 9dfe87d

Please sign in to comment.