@@ -82,16 +82,18 @@ private SemaphoreSlim GetSemaphore(string cacheName, string cacheInstanceId, str
8282 public async ValueTask < object > AcquireLockAsync ( string cacheName , string cacheInstanceId , string operationId , string key , TimeSpan timeout , ILogger ? logger ,
8383 CancellationToken token )
8484 {
85- using var activity = HzActivities . Source . StartActivityWithCommonTags ( HzActivities . Names . GetSemaphore , HzActivities . Area . HzCacheMemoryLocker , key : key ) ;
85+ using var activity = HzActivities . Source . StartActivityWithCommonTags ( HzActivities . Names . AcquireLock , HzActivities . Area . HzCacheMemoryLocker , key : key ) ;
8686 var semaphore = GetSemaphore ( cacheName , cacheInstanceId , key , logger ) ;
8787
8888 if ( logger ? . IsEnabled ( LogLevel . Trace ) ?? false )
8989 {
9090 logger . Log ( LogLevel . Trace , "HZ [N={CacheName} I={CacheInstanceId}] (O={CacheOperationId} K={CacheKey}): waiting to acquire the LOCK" , cacheName ,
9191 cacheInstanceId , operationId , key ) ;
9292 }
93-
94- var acquired = await semaphore . WaitAsync ( timeout , token ) . ConfigureAwait ( false ) ;
93+ var acquired = false ;
94+ using ( var waitForSemaphore = HzActivities . Source . StartActivityWithCommonTags ( HzActivities . Names . WaitForSemaphore , HzActivities . Area . HzCacheMemoryLocker , key : key ) ) {
95+ acquired = await semaphore . WaitAsync ( timeout , token ) . ConfigureAwait ( false ) ;
96+ }
9597
9698 if ( acquired )
9799 {
@@ -128,8 +130,14 @@ public async ValueTask<object> AcquireLockAsync(string cacheName, string cacheIn
128130 logger . Log ( LogLevel . Trace , "HZ [N={CacheName} I={CacheInstanceId}] (O={CacheOperationId} K={CacheKey}): waiting to acquire the LOCK" , cacheName ,
129131 cacheInstanceId , operationId , key ) ;
130132 }
133+ var acquired = false ;
134+ using ( var waitForSemaphore =
135+ HzActivities . Source . StartActivityWithCommonTags ( HzActivities . Names . WaitForSemaphore ,
136+ HzActivities . Area . HzCacheMemoryLocker , key : key ) )
137+ {
131138
132- var acquired = semaphore . Wait ( timeout , token ) ;
139+ acquired = semaphore . Wait ( timeout , token ) ;
140+ }
133141
134142 if ( acquired )
135143 {
0 commit comments