@@ -52,7 +52,7 @@ func getStaleFreshTime(now time.Time, freshDuration time.Duration, staleDuration
52
52
}
53
53
54
54
func (t tieredCache [T ]) Get (ctx context.Context , ns types.TNamespace , key string ) (* types.TValue , bool , error ) {
55
- ctx , span := telemetry .NewSpan (ctx , "tiered.get-many " )
55
+ ctx , span := telemetry .NewSpan (ctx , "tiered.get" )
56
56
defer span .End ()
57
57
58
58
if len (t .stores ) == 0 {
@@ -80,7 +80,7 @@ func (t tieredCache[T]) Get(ctx context.Context, ns types.TNamespace, key string
80
80
continue
81
81
}
82
82
83
- _ , span := telemetry .NewSpan (ctx , store .Name ()+ ".set" )
83
+ _ , span := telemetry .NewSpan (ctx , lowerStore .Name ()+ ".set" )
84
84
defer span .End ()
85
85
telemetry .WithAttributes (span ,
86
86
telemetry.AttributeKV {Key : "key" , Value : key },
@@ -167,7 +167,7 @@ func (t tieredCache[T]) GetMany(ctx context.Context, ns types.TNamespace, keys [
167
167
continue
168
168
}
169
169
170
- _ , span := telemetry .NewSpan (ctx , store .Name ()+ ".set-many" )
170
+ _ , span := telemetry .NewSpan (ctx , lowerStore .Name ()+ ".set-many" )
171
171
defer span .End ()
172
172
telemetry .WithAttributes (span ,
173
173
telemetry.AttributeKV {Key : "keys" , Value : keysToFind },
@@ -204,6 +204,7 @@ func (t tieredCache[T]) GetMany(ctx context.Context, ns types.TNamespace, keys [
204
204
func (t tieredCache [T ]) Set (ctx context.Context , ns types.TNamespace , key string , value * T , opts * types.SetOptions ) error {
205
205
ctx , span := telemetry .NewSpan (ctx , "tiered.set" )
206
206
defer span .End ()
207
+
207
208
telemetry .WithAttributes (span ,
208
209
telemetry.AttributeKV {Key : "key" , Value : key },
209
210
telemetry.AttributeKV {Key : "namespace" , Value : string (ns )},
@@ -215,9 +216,9 @@ func (t tieredCache[T]) Set(ctx context.Context, ns types.TNamespace, key string
215
216
216
217
fresh , stale := getStaleFreshTime (time .Now (), t .fresh , t .stale , opts )
217
218
for _ , store := range t .stores {
218
- _ , span := telemetry .NewSpan (ctx , store .Name ()+ ".set" )
219
- defer span .End ()
220
- telemetry .WithAttributes (span ,
219
+ _ , span2 := telemetry .NewSpan (ctx , store .Name ()+ ".set" )
220
+ defer span2 .End ()
221
+ telemetry .WithAttributes (span2 ,
221
222
telemetry.AttributeKV {Key : "key" , Value : key },
222
223
telemetry.AttributeKV {Key : "namespace" , Value : string (ns )},
223
224
telemetry.AttributeKV {Key : "fresh" , Value : fresh .String ()},
@@ -230,10 +231,10 @@ func (t tieredCache[T]) Set(ctx context.Context, ns types.TNamespace, key string
230
231
StaleUntil : stale ,
231
232
Key : key ,
232
233
}); err != nil {
233
- telemetry .RecordError (span , err )
234
+ telemetry .RecordError (span2 , err )
234
235
return fault .Wrap (err , fmsg .With (store .Name ()+ " failed to set key: " + key ))
235
236
}
236
- span .End ()
237
+ span2 .End ()
237
238
}
238
239
239
240
return nil
@@ -263,16 +264,17 @@ func (t *tieredCache[T]) SetMany(ctx context.Context, ns types.TNamespace, value
263
264
}
264
265
265
266
for _ , store := range t .stores {
266
- _ , span := telemetry .NewSpan (ctx , store .Name ()+ ".set-many" )
267
- defer span .End ()
268
- telemetry .WithAttributes (span ,
267
+ _ , span2 := telemetry .NewSpan (ctx , store .Name ()+ ".set-many" )
268
+ defer span2 .End ()
269
+ telemetry .WithAttributes (span2 ,
269
270
telemetry.AttributeKV {Key : "namespace" , Value : string (ns )},
270
271
)
271
272
272
273
if err := store .SetMany (t .ns , valuesToSet , opts ); err != nil {
273
- telemetry .RecordError (span , err )
274
+ telemetry .RecordError (span2 , err )
274
275
return fault .Wrap (err , fmsg .With (store .Name ()+ " failed to set keys: " ))
275
276
}
277
+ span2 .End ()
276
278
}
277
279
278
280
return nil
@@ -287,17 +289,18 @@ func (t *tieredCache[T]) Remove(ctx context.Context, ns types.TNamespace, keys [
287
289
}
288
290
289
291
for _ , store := range t .stores {
290
- _ , span := telemetry .NewSpan (ctx , store .Name ()+ ".remove" )
291
- defer span .End ()
292
- telemetry .WithAttributes (span ,
292
+ _ , span2 := telemetry .NewSpan (ctx , store .Name ()+ ".remove" )
293
+ defer span2 .End ()
294
+ telemetry .WithAttributes (span2 ,
293
295
telemetry.AttributeKV {Key : "key" , Value : keys },
294
296
telemetry.AttributeKV {Key : "namespace" , Value : string (ns )},
295
297
)
296
298
297
299
if err := store .Remove (t .ns , keys ); err != nil {
298
- telemetry .RecordError (span , err )
300
+ telemetry .RecordError (span2 , err )
299
301
return fault .Wrap (err , fmsg .With (store .Name ()+ " failed to remove key(s): " + strings .Join (keys , "," )))
300
302
}
303
+ span2 .End ()
301
304
}
302
305
303
306
return nil
0 commit comments