Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions experimental/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ For notes on migrating to 2.x / 0.200.x see [the upgrade guide](doc/upgrade-to-2

### :boom: Breaking Changes

* fix(otlp-exporter-base)!: remove xhr transport [#6317](https://github.com/open-telemetry/opentelemetry-js/pull/6317) @cjihrig
* (user-facing) The deprecated XHR-based transport has been removed and replaced with `fetch()`. This change affects users who relied on `XmlHttpRequest` instead of `fetch()` for sending headers with OTLP exports. To maintain compatibility on browsers without a `fetch()` implementation, include a `fetch()` polyfill.

### :rocket: Features

* feat(sdk-logs): export event name from ConsoleLogRecordExporter [#6310](https://github.com/open-telemetry/opentelemetry-js/pull/6310) @aicest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import { ISerializer } from '@opentelemetry/otlp-transformer';
import {
createOtlpFetchExportDelegate,
createOtlpSendBeaconExportDelegate,
createOtlpXhrExportDelegate,
} from '../otlp-browser-http-export-delegate';
import { convertLegacyBrowserHttpOptions } from './convert-legacy-browser-http-options';
import { IOtlpExportDelegate } from '../otlp-export-delegate';
Expand Down Expand Up @@ -52,9 +51,7 @@ export function inferExportDelegateToUse(
) {
if (!configHeaders && typeof navigator.sendBeacon === 'function') {
return createOtlpSendBeaconExportDelegate;
} else if (typeof globalThis.fetch !== 'undefined') {
return createOtlpFetchExportDelegate;
} else {
return createOtlpXhrExportDelegate;
}

return createOtlpFetchExportDelegate;
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@
* limitations under the License.
*/

export {
createOtlpXhrExportDelegate,
createOtlpSendBeaconExportDelegate,
} from './otlp-browser-http-export-delegate';
export { createOtlpSendBeaconExportDelegate } from './otlp-browser-http-export-delegate';

export { convertLegacyBrowserHttpOptions } from './configuration/convert-legacy-browser-http-options';
export { createLegacyOtlpBrowserExportDelegate } from './configuration/create-legacy-browser-delegate';
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,10 @@ import { OtlpHttpConfiguration } from './configuration/otlp-http-configuration';
import { ISerializer } from '@opentelemetry/otlp-transformer';
import { IOtlpExportDelegate } from './otlp-export-delegate';
import { createRetryingTransport } from './retrying-transport';
import { createXhrTransport } from './transport/xhr-transport';
import { createSendBeaconTransport } from './transport/send-beacon-transport';
import { createOtlpNetworkExportDelegate } from './otlp-network-export-delegate';
import { createFetchTransport } from './transport/fetch-transport';

/**
* @deprecated use {@link createOtlpFetchExportDelegate}
*/
export function createOtlpXhrExportDelegate<Internal, Response>(
options: OtlpHttpConfiguration,
serializer: ISerializer<Internal, Response>
): IOtlpExportDelegate<Internal> {
return createOtlpNetworkExportDelegate(
options,
serializer,
createRetryingTransport({
transport: createXhrTransport(options),
})
);
}

export function createOtlpFetchExportDelegate<Internal, Response>(
options: OtlpHttpConfiguration,
serializer: ISerializer<Internal, Response>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import { inferExportDelegateToUse } from '../../src/configuration/create-legacy-
import {
createOtlpFetchExportDelegate,
createOtlpSendBeaconExportDelegate,
createOtlpXhrExportDelegate,
} from '../../src/otlp-browser-http-export-delegate';

describe('createLegacyBrowserDelegate', function () {
Expand Down Expand Up @@ -51,43 +50,5 @@ describe('createLegacyBrowserDelegate', function () {
assert.equal(delegate, createOtlpFetchExportDelegate);
});
});

describe('when fetch is unavailable', function () {
const fetch = window.fetch;
beforeEach(function () {
// fake fetch being unavailable
(window as any).fetch = undefined;
});
afterEach(() => {
window.fetch = fetch;
});

it('uses xhr delegate', function () {
const delegate = inferExportDelegateToUse(undefined);
assert.equal(delegate, createOtlpXhrExportDelegate);
});
});
});

describe('when fetch is unavailable but beacon and xhr are', function () {
const fetch = window.fetch;
beforeEach(function () {
// fake fetch being unavailable
(window as any).fetch = undefined;
});
afterEach(function () {
window.fetch = fetch;
});

it('uses xhr when beacon is available but headers are provided', function () {
const fetch = window.fetch;
// @ts-expect-error one should not be able to mutate the window but this is a test.
window.fetch = undefined;

const delegate = inferExportDelegateToUse({ foo: 'bar' });
assert.equal(delegate, createOtlpXhrExportDelegate);

window.fetch = fetch;
});
});
});
Loading