From 6cf5406caf9db2bf0a27302388b43ce6a39c9465 Mon Sep 17 00:00:00 2001 From: Ivan Senic Date: Fri, 1 May 2020 21:21:27 +0200 Subject: [PATCH] fix(opentelemetry-plugin-xml-http-request): define span kind as CLIENT for xmlhttprequests (#1002) --- .../opentelemetry-plugin-xml-http-request/src/xhr.ts | 1 + .../test/xhr.test.ts | 9 +++++++++ 2 files changed, 10 insertions(+) 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, 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..270762ca21 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,15 @@ 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;