Skip to content

Commit 55b26fe

Browse files
committed
refactor: wip
1 parent 6bee2c7 commit 55b26fe

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

packages/utils/src/lib/profiler/profiler-node.ts

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ export class NodejsProfiler<
110110
*/
111111

112112
constructor(options: NodejsProfilerOptions<DomainEvents, Tracks>) {
113-
// Pick ProfilerBufferOptions
113+
// Pick ProfilerBufferOptions
114114
const {
115115
captureBufferedEntries,
116116
flushThreshold,
@@ -130,7 +130,6 @@ export class NodejsProfiler<
130130
super({ ...profilerOptions, enabled, debug });
131131

132132
const { encodePerfEntry, ...format } = profilerFormat;
133-
134133
this.#sharder = new ShardedWal<DomainEvents>({
135134
debug,
136135
dir: process.env[PROFILER_OUT_DIR_ENV_VAR] ?? outDir,
@@ -139,7 +138,6 @@ export class NodejsProfiler<
139138
measureNameEnvVar: PROFILER_MEASURE_NAME_ENV_VAR,
140139
groupId: measureName,
141140
});
142-
143141
this.#shard = this.#sharder.shard();
144142
this.#performanceObserverSink = new PerformanceObserverSink({
145143
sink: this.#shard,
@@ -149,22 +147,15 @@ export class NodejsProfiler<
149147
maxQueueSize,
150148
debug: this.isDebugMode(),
151149
});
152-
153150
this.#unsubscribeExitHandlers = subscribeProcessExit({
154151
onError: (
155152
error: unknown,
156153
kind: 'uncaughtException' | 'unhandledRejection',
157-
) => {
158-
this.#handleFatalError(error, kind);
159-
},
160-
onExit: (_code: number) => {
161-
this.close();
162-
},
154+
) => this.#handleFatalError(error, kind),
155+
onExit: (_code: number) => this.close(),
163156
});
164157

165-
const initialEnabled =
166-
options.enabled ?? isEnvVarEnabled(PROFILER_ENABLED_ENV_VAR);
167-
if (initialEnabled) {
158+
if (options.enabled ?? isEnvVarEnabled(PROFILER_ENABLED_ENV_VAR)) {
168159
this.transition('running');
169160
}
170161
}
@@ -309,7 +300,7 @@ export class NodejsProfiler<
309300
sharderState,
310301
...sharderStats,
311302
isCoordinator,
312-
shardOpen: this.#shard?.isClosed(),
303+
shardOpen: !this.#shard?.isClosed(),
313304
shardPath: this.#shard?.getPath(),
314305
...this.#performanceObserverSink?.getStats(),
315306
};

0 commit comments

Comments
 (0)