From 5cf9d606a7fd093fac9742943aed416867c27c9b Mon Sep 17 00:00:00 2001 From: Ivan Senic Date: Thu, 30 Apr 2020 12:17:00 +0200 Subject: [PATCH 1/3] fix(opentelemetry-plugin-xml-http-request): define span kind as CLIENT for xmlhttprequests --- packages/opentelemetry-plugin-xml-http-request/src/xhr.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/opentelemetry-plugin-xml-http-request/src/xhr.ts b/packages/opentelemetry-plugin-xml-http-request/src/xhr.ts index b4009d6861..88eec64ae6 100644 --- a/packages/opentelemetry-plugin-xml-http-request/src/xhr.ts +++ b/packages/opentelemetry-plugin-xml-http-request/src/xhr.ts @@ -316,6 +316,7 @@ export class XMLHttpRequestPlugin extends BasePlugin { } const currentSpan = this._tracer.startSpan(url, { + kind: api.SpanKind.CLIENT, attributes: { [AttributeNames.COMPONENT]: this.component, [AttributeNames.HTTP_METHOD]: method, From 54d9b3d907b87213fe997fd9a878e5ed49b3f92f Mon Sep 17 00:00:00 2001 From: Ivan Senic Date: Fri, 1 May 2020 20:45:52 +0200 Subject: [PATCH 2/3] added test --- .../opentelemetry-plugin-xml-http-request/test/xhr.test.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/opentelemetry-plugin-xml-http-request/test/xhr.test.ts b/packages/opentelemetry-plugin-xml-http-request/test/xhr.test.ts index 52693d840a..3bd341019f 100644 --- a/packages/opentelemetry-plugin-xml-http-request/test/xhr.test.ts +++ b/packages/opentelemetry-plugin-xml-http-request/test/xhr.test.ts @@ -210,6 +210,11 @@ describe('xhr', () => { assert.strictEqual(span.name, url, 'span has wrong name'); }); + it('span should have correct kind', () => { + const span: tracing.ReadableSpan = exportSpy.args[0][0][0]; + assert.strictEqual(span.kind, types.SpanKind.CLIENT, 'span has wrong kind'); + }); + it('span should have correct attributes', () => { const span: tracing.ReadableSpan = exportSpy.args[0][0][0]; const attributes = span.attributes; From b13b01599b61232d6261ec2942cf968faba25f45 Mon Sep 17 00:00:00 2001 From: Ivan Senic Date: Fri, 1 May 2020 21:14:56 +0200 Subject: [PATCH 3/3] lint fix --- .../opentelemetry-plugin-xml-http-request/test/xhr.test.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/opentelemetry-plugin-xml-http-request/test/xhr.test.ts b/packages/opentelemetry-plugin-xml-http-request/test/xhr.test.ts index 3bd341019f..270762ca21 100644 --- a/packages/opentelemetry-plugin-xml-http-request/test/xhr.test.ts +++ b/packages/opentelemetry-plugin-xml-http-request/test/xhr.test.ts @@ -212,7 +212,11 @@ describe('xhr', () => { it('span should have correct kind', () => { const span: tracing.ReadableSpan = exportSpy.args[0][0][0]; - assert.strictEqual(span.kind, types.SpanKind.CLIENT, 'span has wrong kind'); + assert.strictEqual( + span.kind, + types.SpanKind.CLIENT, + 'span has wrong kind' + ); }); it('span should have correct attributes', () => {