Skip to content

Commit

Permalink
fix(instrumentation-xml-http-request): use previous parseUrl approach…
Browse files Browse the repository at this point in the history
… as the new approach throws on relative paths.
  • Loading branch information
pichlermarc committed Apr 4, 2022
1 parent 97fe596 commit a3078b6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ import { SemanticAttributes } from '@opentelemetry/semantic-conventions';
import {
addSpanNetworkEvents,
getResource,
parseUrl,
PerformanceTimingNames as PTN,
shouldPropagateTraceHeaders,
URLLike
} from '@opentelemetry/sdk-trace-web';
import { EventNames } from './enums/EventNames';
import {
Expand All @@ -40,6 +40,12 @@ import {
import { VERSION } from './version';
import { AttributeNames } from './enums/AttributeNames';

function parseUrl(url: string): URLLike {
const element = document.createElement('a');
element.href = url;
return element;
}

// how long to wait for observer to collect information about resources
// this is needed as event "load" is called before observer
// hard to say how long it should really wait, seems like 300ms is
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { SemanticAttributes } from '@opentelemetry/semantic-conventions';
import {
PerformanceTimingNames as PTN,
WebTracerProvider,
parseUrl,
URLLike,
} from '@opentelemetry/sdk-trace-web';
import * as assert from 'assert';
import * as sinon from 'sinon';
Expand All @@ -48,6 +48,12 @@ class DummySpanExporter implements tracing.SpanExporter {
}
}

function parseUrl(url: string): URLLike {
const element = document.createElement('a');
element.href = url;
return element;
}

const XHR_TIMEOUT = 2000;

const getData = (
Expand Down

0 comments on commit a3078b6

Please sign in to comment.