Skip to content

Commit

Permalink
fix: uniteTraceEvents behavior (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
noomorph authored May 20, 2023
1 parent 4754e7f commit 83c4f9c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
2 changes: 2 additions & 0 deletions src/__tests__/end-to-end.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@ describe('end-to-end', () => {
`);
});

// TODO: write a test which will fail on the default highWaterMark

test('should unite trace events', async () => {
const file3 = tempy.file();

Expand Down
12 changes: 8 additions & 4 deletions src/streams/trace-merge/transforms/TraceAnalyze.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
import { Transform } from 'node:stream';
import { Writable } from 'node:stream';
import type { TraceEvent } from 'trace-event-lib';
import type { Resolver } from '../resolvers';
import type { JSONLEntry } from '../../jsonl';

export class TraceAnalyze extends Transform {
export class TraceAnalyze extends Writable {
readonly #resolver: Resolver;

constructor(resolver: Resolver) {
super({ objectMode: true });
super({
objectMode: true,
highWaterMark: Number.MAX_SAFE_INTEGER,
});

this.#resolver = resolver;
}

_transform(
_write(
chunk: unknown,
_encoding: string,
callback: (error?: Error | null, data?: unknown) => void,
Expand Down
6 changes: 5 additions & 1 deletion src/streams/trace-merge/transforms/TraceMerge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ export class TraceMerge extends Transform {
#resolver?: Resolver;

constructor(resolverPromise: Promise<Resolver>) {
super({ objectMode: true });
super({
objectMode: true,
highWaterMark: Number.MAX_SAFE_INTEGER,
});

this.#resolverPromise = resolverPromise;
}

Expand Down

0 comments on commit 83c4f9c

Please sign in to comment.