Skip to content

Commit 6cf5406

Browse files
authored
fix(opentelemetry-plugin-xml-http-request): define span kind as CLIENT for xmlhttprequests (open-telemetry#1002)
1 parent d246c54 commit 6cf5406

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

packages/opentelemetry-plugin-xml-http-request/src/xhr.ts

+1
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,7 @@ export class XMLHttpRequestPlugin extends BasePlugin<XMLHttpRequest> {
316316
}
317317

318318
const currentSpan = this._tracer.startSpan(url, {
319+
kind: api.SpanKind.CLIENT,
319320
attributes: {
320321
[AttributeNames.COMPONENT]: this.component,
321322
[AttributeNames.HTTP_METHOD]: method,

packages/opentelemetry-plugin-xml-http-request/test/xhr.test.ts

+9
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,15 @@ describe('xhr', () => {
210210
assert.strictEqual(span.name, url, 'span has wrong name');
211211
});
212212

213+
it('span should have correct kind', () => {
214+
const span: tracing.ReadableSpan = exportSpy.args[0][0][0];
215+
assert.strictEqual(
216+
span.kind,
217+
types.SpanKind.CLIENT,
218+
'span has wrong kind'
219+
);
220+
});
221+
213222
it('span should have correct attributes', () => {
214223
const span: tracing.ReadableSpan = exportSpy.args[0][0][0];
215224
const attributes = span.attributes;

0 commit comments

Comments
 (0)