-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Send a list of request ids to monorail
- Loading branch information
1 parent
720ad9c
commit dda7c7a
Showing
4 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/** | ||
* Manages collection of request IDs during command execution | ||
*/ | ||
export class RequestIDCollection { | ||
private static instance: RequestIDCollection | ||
|
||
static getInstance(): RequestIDCollection { | ||
if (!RequestIDCollection.instance) { | ||
RequestIDCollection.instance = new RequestIDCollection() | ||
} | ||
return RequestIDCollection.instance | ||
} | ||
|
||
// We only report the last 1000 request IDs. | ||
private readonly maxRequestIds = 1000 | ||
private requestIds: string[] = [] | ||
|
||
private constructor() {} | ||
|
||
/** | ||
* Add a request ID to the collection | ||
*/ | ||
addRequestId(requestId: string | undefined | null) { | ||
if (requestId) { | ||
this.requestIds.push(requestId) | ||
} | ||
} | ||
|
||
/** | ||
* Get all collected request IDs as a comma-separated string | ||
*/ | ||
getRequestIds(): string[] { | ||
return this.requestIds.slice(-this.maxRequestIds) | ||
} | ||
|
||
/** | ||
* Clear all stored request IDs | ||
*/ | ||
clear() { | ||
this.requestIds = [] | ||
} | ||
} | ||
|
||
export const requestIdsCollection = RequestIDCollection.getInstance() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.