From f660f8363048e2c47aa65a41f854c02d9a1496e3 Mon Sep 17 00:00:00 2001 From: t2t2 Date: Thu, 25 Aug 2022 14:55:30 +0300 Subject: [PATCH 1/3] fix(instrumentation-xhr): http.url attribute should be absolute --- .../test/fetch.test.ts | 11 +++++++++++ .../src/xhr.ts | 2 +- .../test/xhr.test.ts | 11 +++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/experimental/packages/opentelemetry-instrumentation-fetch/test/fetch.test.ts b/experimental/packages/opentelemetry-instrumentation-fetch/test/fetch.test.ts index e4ce4f9f5a..dd43849087 100644 --- a/experimental/packages/opentelemetry-instrumentation-fetch/test/fetch.test.ts +++ b/experimental/packages/opentelemetry-instrumentation-fetch/test/fetch.test.ts @@ -837,6 +837,17 @@ describe('fetch', () => { `event ${PTN.REQUEST_START} is not defined` ); }); + + it('should have an absolute http.url attribute', () => { + const span: tracing.ReadableSpan = exportSpy.args[0][0][0]; + const attributes = span.attributes; + + assert.strictEqual( + attributes[SemanticAttributes.HTTP_URL], + location.origin + '/get', + `attributes ${SemanticAttributes.HTTP_URL} is wrong` + ); + }) }); describe('when PerformanceObserver is undefined', () => { diff --git a/experimental/packages/opentelemetry-instrumentation-xml-http-request/src/xhr.ts b/experimental/packages/opentelemetry-instrumentation-xml-http-request/src/xhr.ts index 062d6fde4a..59d03b9c85 100644 --- a/experimental/packages/opentelemetry-instrumentation-xml-http-request/src/xhr.ts +++ b/experimental/packages/opentelemetry-instrumentation-xml-http-request/src/xhr.ts @@ -339,7 +339,7 @@ export class XMLHttpRequestInstrumentation extends InstrumentationBase { `event ${PTN.REQUEST_START} is not defined` ); }); + + it('should have an absolute http.url attribute', () => { + const span: tracing.ReadableSpan = exportSpy.args[0][0][0]; + const attributes = span.attributes; + + assert.strictEqual( + attributes[SemanticAttributes.HTTP_URL], + location.origin + '/get', + `attributes ${SemanticAttributes.HTTP_URL} is wrong` + ); + }) }); }); From 5be64261042a6cae08781fa6cf44df24f48e04d6 Mon Sep 17 00:00:00 2001 From: t2t2 Date: Thu, 25 Aug 2022 15:00:24 +0300 Subject: [PATCH 2/3] lint --- .../opentelemetry-instrumentation-fetch/test/fetch.test.ts | 2 +- .../test/xhr.test.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/experimental/packages/opentelemetry-instrumentation-fetch/test/fetch.test.ts b/experimental/packages/opentelemetry-instrumentation-fetch/test/fetch.test.ts index dd43849087..439ca17cc8 100644 --- a/experimental/packages/opentelemetry-instrumentation-fetch/test/fetch.test.ts +++ b/experimental/packages/opentelemetry-instrumentation-fetch/test/fetch.test.ts @@ -847,7 +847,7 @@ describe('fetch', () => { location.origin + '/get', `attributes ${SemanticAttributes.HTTP_URL} is wrong` ); - }) + }); }); describe('when PerformanceObserver is undefined', () => { diff --git a/experimental/packages/opentelemetry-instrumentation-xml-http-request/test/xhr.test.ts b/experimental/packages/opentelemetry-instrumentation-xml-http-request/test/xhr.test.ts index 040be82f0a..a57d8883d7 100644 --- a/experimental/packages/opentelemetry-instrumentation-xml-http-request/test/xhr.test.ts +++ b/experimental/packages/opentelemetry-instrumentation-xml-http-request/test/xhr.test.ts @@ -797,7 +797,7 @@ describe('xhr', () => { location.origin + '/get', `attributes ${SemanticAttributes.HTTP_URL} is wrong` ); - }) + }); }); }); From 8b254f34a1583b56dc0b0018c8d2b23f5fb4976a Mon Sep 17 00:00:00 2001 From: t2t2 Date: Thu, 25 Aug 2022 15:09:55 +0300 Subject: [PATCH 3/3] changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 48de348db0..bc6d92008d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,8 @@ All notable changes to this project will be documented in this file. ### :bug: (Bug Fix) +* fix(instrumentation-xhr): http.url attribute should be absolute [#3200](https://github.com/open-telemetry/opentelemetry-js/pull/3200) @t2t2 + ### :books: (Refine Doc) ### :house: (Internal)