diff --git a/experimental/packages/opentelemetry-instrumentation/src/platform/browser/index.ts b/experimental/packages/opentelemetry-instrumentation/src/platform/browser/index.ts index abf8f2bdfe..4ad5c8f063 100644 --- a/experimental/packages/opentelemetry-instrumentation/src/platform/browser/index.ts +++ b/experimental/packages/opentelemetry-instrumentation/src/platform/browser/index.ts @@ -15,4 +15,4 @@ */ export { InstrumentationBase } from './instrumentation'; -export { normalize } from './throwing-normalize'; +export { normalize } from './noop-normalize'; diff --git a/experimental/packages/opentelemetry-instrumentation/src/platform/browser/throwing-normalize.ts b/experimental/packages/opentelemetry-instrumentation/src/platform/browser/noop-normalize.ts similarity index 63% rename from experimental/packages/opentelemetry-instrumentation/src/platform/browser/throwing-normalize.ts rename to experimental/packages/opentelemetry-instrumentation/src/platform/browser/noop-normalize.ts index afd314552d..7b8aa40000 100644 --- a/experimental/packages/opentelemetry-instrumentation/src/platform/browser/throwing-normalize.ts +++ b/experimental/packages/opentelemetry-instrumentation/src/platform/browser/noop-normalize.ts @@ -14,16 +14,22 @@ * limitations under the License. */ +import { diag } from '@opentelemetry/api'; + /** * Placeholder normalize function to replace the node variant in browser runtimes, - * this should never be called and will throw if it is called. + * this should never be called and will perform a no-op and warn if it is called regardless. * * This is a workaround to fix https://github.com/open-telemetry/opentelemetry-js/issues/4373 until the instrumentation * package can be made node-only. * - * @param _path unused input path + * @param path input path + * @return unmodified path * @internal */ -export function normalize(_path: string): string { - throw new Error('Not implemented'); +export function normalize(path: string): string { + diag.warn( + 'Path normalization is not implemented for this platform. To silence this warning, ensure no node-specific instrumentations are loaded, and node-specific types (e.g. InstrumentationNodeModuleFile), are not used in a browser context)' + ); + return path; } diff --git a/experimental/packages/opentelemetry-instrumentation/test/browser/throwing-normalize.test.ts b/experimental/packages/opentelemetry-instrumentation/test/browser/noop-normalize.test.ts similarity index 81% rename from experimental/packages/opentelemetry-instrumentation/test/browser/throwing-normalize.test.ts rename to experimental/packages/opentelemetry-instrumentation/test/browser/noop-normalize.test.ts index 08be79cc49..aedcb975e7 100644 --- a/experimental/packages/opentelemetry-instrumentation/test/browser/throwing-normalize.test.ts +++ b/experimental/packages/opentelemetry-instrumentation/test/browser/noop-normalize.test.ts @@ -17,8 +17,8 @@ import * as assert from 'assert'; import { normalize } from '../../src/platform/browser'; -describe('throwing-normalize', () => { - assert.throws(() => { - normalize('foo'); +describe('noop-normalize', function () { + it('should not normalize input', function () { + assert.strictEqual(normalize('/tmp/foo/../bar'), '/tmp/foo/../bar'); }); });