Skip to content

Commit 422efcd

Browse files
HazATkamilogorek
authored andcommitted
meta: beta.4
1 parent 4b35daf commit 422efcd

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

packages/hub/src/hub.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -452,11 +452,11 @@ export class Hub implements HubInterface {
452452

453453
// TODO: if sampled do what?
454454

455-
const finishedSpans = passedSpan.finishedSpans.filter(s => s !== span);
455+
const finishedSpans = passedSpan.finishedSpans.filter(s => s !== passedSpan);
456456

457457
const eventId = this.captureEvent({
458458
contexts: { trace: passedSpan.getTraceContext() },
459-
spans: finishedSpans,
459+
spans: finishedSpans.length > 0 ? finishedSpans : undefined,
460460
start_timestamp: passedSpan.startTimestamp,
461461
timestamp: passedSpan.timestamp,
462462
transaction: passedSpan.transaction,

packages/hub/test/hub.test.ts

+12
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,18 @@ describe('Hub', () => {
323323
const span = hub.startSpan({ transaction: 'test' }, true) as any;
324324
expect(hub.finishSpan(span)).toBeDefined();
325325
expect(spy).toHaveBeenCalled();
326+
expect(spy.mock.calls[0][0].spans).toBeUndefined();
327+
});
328+
329+
test('finish a scope span with transaction + child span', () => {
330+
const myScope = new Scope();
331+
const hub = new Hub(clientFn, myScope);
332+
const spy = jest.spyOn(hub as any, 'captureEvent');
333+
const span = hub.startSpan({ transaction: 'test' }, true) as any;
334+
hub.finishSpan(hub.startSpan());
335+
expect(hub.finishSpan(span)).toBeDefined();
336+
expect(spy).toHaveBeenCalled();
337+
expect(spy.mock.calls[0][0].spans).toHaveLength(1);
326338
});
327339
});
328340
});

0 commit comments

Comments
 (0)