@@ -736,7 +736,10 @@ extension SourceKitServer: MessageHandler {
736
736
messageHandlingQueue. async ( metadata: TaskMetadata ( params) ) {
737
737
signposter. emitEvent ( " Start handling " , id: signpostID)
738
738
739
- await withLoggingScope ( " notification- \( notificationID) " ) {
739
+ // Only use the last two digits of the notification ID for the logging scope to avoid creating too many scopes.
740
+ // See comment in `withLoggingScope`.
741
+ // The last 2 digits should be sufficient to differentiate between multiple concurrently running notifications.
742
+ await withLoggingScope ( " notification- \( notificationID % 100 ) " ) {
740
743
await self . handleImpl ( params, from: clientID)
741
744
signposter. endInterval ( " Notification " , state, " Done " )
742
745
}
@@ -783,7 +786,10 @@ extension SourceKitServer: MessageHandler {
783
786
784
787
let task = messageHandlingQueue. async ( metadata: TaskMetadata ( params) ) {
785
788
signposter. emitEvent ( " Start handling " , id: signpostID)
786
- await withLoggingScope ( " request- \( id) " ) {
789
+ // Only use the last two digits of the request ID for the logging scope to avoid creating too many scopes.
790
+ // See comment in `withLoggingScope`.
791
+ // The last 2 digits should be sufficient to differentiate between multiple concurrently running requests.
792
+ await withLoggingScope ( " request- \( id. numericValue % 100 ) " ) {
787
793
await self . handleImpl ( params, id: id, from: clientID, reply: reply)
788
794
signposter. endInterval ( " Request " , state, " Done " )
789
795
}
@@ -2321,3 +2327,16 @@ extension WorkspaceSymbolItem {
2321
2327
)
2322
2328
}
2323
2329
}
2330
+
2331
+ fileprivate extension RequestID {
2332
+ /// Returns a numeric value for this request ID.
2333
+ ///
2334
+ /// For request IDs that are numbers, this is straightforward. For string-based request IDs, this uses a hash to
2335
+ /// convert the string into a number.
2336
+ var numericValue : Int {
2337
+ switch self {
2338
+ case . number( let number) : return number
2339
+ case . string( let string) : return Int ( string) ?? string. hashValue
2340
+ }
2341
+ }
2342
+ }
0 commit comments