File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed
Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -54,7 +54,14 @@ export function setupMongoMetrics(client: MongoClient): void {
5454
5555 if ( startTime ) {
5656 const duration = ( Date . now ( ) - startTime ) / 1000 ;
57- const collection = event . command ?. collection || event . command ?. [ event . commandName ] || 'unknown' ;
57+
58+ /**
59+ * Extract collection name from the command
60+ * For most commands, the collection name is the value of the command name key
61+ * e.g., { find: "users" } -> collection is "users"
62+ */
63+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
64+ const collection = ( event . command as any ) [ event . commandName ] || 'unknown' ;
5865 const db = event . databaseName || 'unknown' ;
5966
6067 mongoCommandDuration
@@ -74,7 +81,14 @@ export function setupMongoMetrics(client: MongoClient): void {
7481
7582 if ( startTime ) {
7683 const duration = ( Date . now ( ) - startTime ) / 1000 ;
77- const collection = event . command ?. collection || event . command ?. [ event . commandName ] || 'unknown' ;
84+
85+ /**
86+ * Extract collection name from the command
87+ * For most commands, the collection name is the value of the command name key
88+ * e.g., { find: "users" } -> collection is "users"
89+ */
90+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
91+ const collection = ( event . command as any ) [ event . commandName ] || 'unknown' ;
7892 const db = event . databaseName || 'unknown' ;
7993
8094 mongoCommandDuration
You can’t perform that action at this time.
0 commit comments