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;