Skip to content

feat(flags): capture feature flag evaluations on spans #16485

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Jun 17, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Reset unrelated otel test
  • Loading branch information
aliu39 committed Jun 10, 2025
commit 8085ee8b73e13d0a18227cf4741ae1f6b6ab1cd0
Original file line number Diff line number Diff line change
Expand Up @@ -548,57 +548,57 @@ describe('Integration | Transactions', () => {
expect(finishedSpans.length).toBe(0);
});

it('collects child spans that are finished within 5 minutes their parent span has been sent', async () => {
const timeout = 5 * 60 * 1000;
const now = Date.now();
vi.useFakeTimers();
vi.setSystemTime(now);
it('collects child spans that are finished within 5 minutes their parent span has been sent', async () => {
const timeout = 5 * 60 * 1000;
const now = Date.now();
vi.useFakeTimers();
vi.setSystemTime(now);

const logs: unknown[] = [];
vi.spyOn(logger, 'log').mockImplementation(msg => logs.push(msg));
const logs: unknown[] = [];
vi.spyOn(logger, 'log').mockImplementation(msg => logs.push(msg));

const transactions: Event[] = [];
const transactions: Event[] = [];

mockSdkInit({
tracesSampleRate: 1,
beforeSendTransaction: event => {
transactions.push(event);
return null;
},
});
mockSdkInit({
tracesSampleRate: 1,
beforeSendTransaction: event => {
transactions.push(event);
return null;
},
});

const provider = getProvider();
const spanProcessor = getSpanProcessor();
const provider = getProvider();
const spanProcessor = getSpanProcessor();

const exporter = spanProcessor ? spanProcessor['_exporter'] : undefined;
const exporter = spanProcessor ? spanProcessor['_exporter'] : undefined;

if (!exporter) {
throw new Error('No exporter found, aborting test...');
}
if (!exporter) {
throw new Error('No exporter found, aborting test...');
}

startSpanManual({ name: 'test name' }, async span => {
const subSpan = startInactiveSpan({ name: 'inner span 1' });
subSpan.end();
startSpanManual({ name: 'test name' }, async span => {
const subSpan = startInactiveSpan({ name: 'inner span 1' });
subSpan.end();

const subSpan2 = startInactiveSpan({ name: 'inner span 2' });
const subSpan2 = startInactiveSpan({ name: 'inner span 2' });

span.end();
span.end();

setTimeout(() => {
subSpan2.end();
}, timeout - 2);
});
setTimeout(() => {
subSpan2.end();
}, timeout - 2);
});

vi.advanceTimersByTime(timeout - 1);
vi.advanceTimersByTime(timeout - 1);

expect(transactions).toHaveLength(2);
expect(transactions[0]?.spans).toHaveLength(1);
expect(transactions).toHaveLength(2);
expect(transactions[0]?.spans).toHaveLength(1);

const finishedSpans: any = exporter['_finishedSpanBuckets'].flatMap(bucket =>
bucket ? Array.from(bucket.spans) : [],
);
expect(finishedSpans.length).toBe(0);
});
const finishedSpans: any = exporter['_finishedSpanBuckets'].flatMap(bucket =>
bucket ? Array.from(bucket.spans) : [],
);
expect(finishedSpans.length).toBe(0);
});

it('discards child spans that are finished after 5 minutes their parent span has been sent', async () => {
const timeout = 5 * 60 * 1000;
Expand Down