@@ -82,7 +82,6 @@ export class ShardedWal<T extends object = object> {
8282 readonly #dir: string = process . cwd ( ) ;
8383 readonly #coordinatorIdEnvVar: string ;
8484 #state: 'active' | 'finalized' | 'cleaned' = 'active' ;
85- #filename?: string ;
8685
8786 /**
8887 * Initialize the origin PID environment variable if not already set.
@@ -121,24 +120,16 @@ export class ShardedWal<T extends object = object> {
121120 * @param opt.groupId - Group ID for sharding (defaults to generated group ID)
122121 * @param opt.coordinatorIdEnvVar - Environment variable name for storing coordinator ID (defaults to CP_SHARDED_WAL_COORDINATOR_ID)
123122 * @param opt.measureNameEnvVar - Environment variable name for coordinating groupId across processes (optional)
124- * @param opt.filename - Filename to use for final output file (optional)
125123 */
126124 constructor ( opt : {
127125 dir ?: string ;
128126 format : Partial < WalFormat < T > > ;
129127 groupId ?: string ;
130128 coordinatorIdEnvVar : string ;
131129 measureNameEnvVar ?: string ;
132- filename ?: string ;
133130 } ) {
134- const {
135- dir,
136- format,
137- groupId,
138- coordinatorIdEnvVar,
139- measureNameEnvVar,
140- filename,
141- } = opt ;
131+ const { dir, format, groupId, coordinatorIdEnvVar, measureNameEnvVar } =
132+ opt ;
142133
143134 // Determine groupId: use provided, then env var, or generate
144135 let resolvedGroupId : string ;
@@ -165,7 +156,6 @@ export class ShardedWal<T extends object = object> {
165156 }
166157 this . #format = parseWalFormat < T > ( format ) ;
167158 this . #coordinatorIdEnvVar = coordinatorIdEnvVar ;
168- this . #filename = filename ;
169159 }
170160
171161 /**
@@ -257,31 +247,24 @@ export class ShardedWal<T extends object = object> {
257247
258248 /**
259249 * Generates a filename for the final merged output file.
260- * Uses the stored filename if available, otherwise falls back to groupId .
250+ * Uses the groupId as the identifier in the final filename .
261251 *
262252 * Example with baseName "trace" and groupId "20240101-120000-000":
263253 * Filename: trace.20240101-120000-000.json
264254 *
265- * Example with baseName "trace" and filename "custom-trace.json ":
266- * Filename: trace.custom-trace .json
255+ * Example with baseName "trace" and groupId "measureName ":
256+ * Filename: trace.measureName .json
267257 *
268258 * @returns The filename for the final merged output file
269259 */
270260 getFinalFilePath ( ) {
271261 const groupIdDir = path . join ( this . #dir, this . groupId ) ;
272262 const { baseName, finalExtension } = this . #format;
273263
274- // Use stored filename if available, otherwise use groupId
275- let identifier : string ;
276- if ( this . #filename) {
277- // Extract basename if it's a full path, and remove extension
278- const basename = path . basename ( this . #filename) ;
279- identifier = basename . replace ( / \. [ ^ . ] * $ / , '' ) ; // Remove extension
280- } else {
281- identifier = this . groupId ;
282- }
283-
284- return path . join ( groupIdDir , `${ baseName } .${ identifier } ${ finalExtension } ` ) ;
264+ return path . join (
265+ groupIdDir ,
266+ `${ baseName } .${ this . groupId } ${ finalExtension } ` ,
267+ ) ;
285268 }
286269
287270 shard ( ) {
0 commit comments