Skip to content

ci: merge staging to master #53

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 1 commit into from
Apr 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 1 addition & 2 deletions src/bin/cli.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ const options = program.opts();
const sampleMode = options.sample;

async function loadSpans(): Promise<Array<Span>> {
if (!fs.existsSync('spans.jsonl')) return [];
const spans: Array<Span> = [];
const file = await fs.promises.open('testSpans.jsonl', 'r');
const file = await fs.promises.open('span.jsonl', 'r');
for await (const line of file.readLines()) {
spans.push(JSON.parse(line));
}
Expand Down
12 changes: 6 additions & 6 deletions src/lib/Tracer.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
import type { SpanEvent } from './types.js';
import Span from './Span.js';

class Tracer {
protected activeSpans: Map<string, Span> = new Map();
protected queue: Array<Span> = [];
protected queue: Array<SpanEvent> = [];
protected resolveWaitChunksP: (() => void) | undefined;
protected ended: boolean = false;

protected queueSpan(span: Span) {
protected queueSpanEvent(span: SpanEvent) {
this.queue.push(span);
if (this.resolveWaitChunksP != null) this.resolveWaitChunksP();
}

public startSpan(name: string, parentSpanId?: string): string {
const span = new Span(name, parentSpanId);
this.activeSpans.set(span.spanId, span);

if (parentSpanId && this.activeSpans.has(parentSpanId)) {
this.activeSpans.get(parentSpanId)!.children.push(span);
}

this.queueSpanEvent({ type: 'start', span: span.toJSON() });
return span.spanId;
}

Expand All @@ -27,7 +27,7 @@ class Tracer {
if (!span) return;

span.close();
this.queueSpan(span);
this.queueSpanEvent({ type: 'stop', span: span.toJSON() });
return span;
}

Expand Down Expand Up @@ -56,7 +56,7 @@ class Tracer {
this.ended = true;
}

public async *streamEvents(): AsyncGenerator<Span, void, void> {
public async *streamEvents(): AsyncGenerator<SpanEvent, void, void> {
while (true) {
const value = this.queue.shift();
if (value == null) {
Expand Down
7 changes: 6 additions & 1 deletion src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,9 @@ type SpanJSON = {
children: Array<SpanJSON>;
};

export type { SpanJSON };
type SpanEvent = {
type: 'start' | 'stop';
span: SpanJSON;
};

export type { SpanJSON, SpanEvent };
2 changes: 1 addition & 1 deletion tests/asciinemaTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ setInterval(async () => {
}

step++;
process.stderr.write('generated data step');
process.stderr.write('generated data step\n');
}, 500);

await saveToFileP;
Loading