Skip to content

Commit 4efd8c8

Browse files
fix(dotnet): caching example used deprecated API
`SetExtra` was deprecated. Relates to: * getsentry/sentry-dotnet#4336 Co-authored-by: Cursor Agent <[email protected]>
1 parent 0a90e2a commit 4efd8c8

File tree

1 file changed

+10
-10
lines changed
  • docs/platforms/dotnet/common/tracing/instrumentation/custom-instrumentation

1 file changed

+10
-10
lines changed

docs/platforms/dotnet/common/tracing/instrumentation/custom-instrumentation/caches-module.mdx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,14 @@ public class MyCachingService
5454
var cacheSpan = SentrySdk.GetSpan()?.StartChild("cache.put");
5555

5656
// Describe the cache server you are accessing
57-
cacheSpan?.SetExtra("network.peer.address", "cache.example.com/supercache");
58-
cacheSpan?.SetExtra("network.peer.port", 9000);
57+
cacheSpan?.SetData("network.peer.address", "cache.example.com/supercache");
58+
cacheSpan?.SetData("network.peer.port", 9000);
5959

6060
// Set the key you're going to use to add to the cache
61-
cacheSpan?.SetExtra("cache.key", cacheKey);
61+
cacheSpan?.SetData("cache.key", cacheKey);
6262

6363
// Optional: You can also provide the cached item's size
64-
// cacheSpan?.SetExtra("cache.item_size", /* item size in bytes */);
64+
// cacheSpan?.SetData("cache.item_size", /* item size in bytes */);
6565
6666
// Add an item to your cache
6767
_cache.Set(cacheKey, value);
@@ -74,28 +74,28 @@ public class MyCachingService
7474
var cacheSpan = SentrySdk.GetSpan()?.StartChild("cache.get");
7575

7676
// Describe the cache server you are accessing
77-
cacheSpan?.SetExtra("network.peer.address", "cache.example.com/supercache");
78-
cacheSpan?.SetExtra("network.peer.port", 9000);
77+
cacheSpan?.SetData("network.peer.address", "cache.example.com/supercache");
78+
cacheSpan?.SetData("network.peer.port", 9000);
7979

8080
// Set the key you're going to use to retrieve from the cache
81-
cacheSpan?.SetExtra("cache.key", cacheKey);
81+
cacheSpan?.SetData("cache.key", cacheKey);
8282

8383
// Attempt to retrieve the cached item
8484
if (_cache.TryGetValue(cacheKey, out var cachedValue))
8585
{
8686
// If you retrieved a value, the cache was hit
87-
cacheSpan?.SetExtra("cache.hit", true);
87+
cacheSpan?.SetData("cache.hit", true);
8888

8989
// Optional: You can also provide the cached item's size
90-
// cacheSpan.SetExtra("cache.item_size", /* item size in bytes */);
90+
// cacheSpan.SetData("cache.item_size", /* item size in bytes */);
9191
9292
cacheSpan?.Finish();
9393

9494
return cachedValue;
9595
}
9696

9797
// If you could not retrieve a value, it was a miss
98-
cacheSpan?.SetExtra("cache.hit", false);
98+
cacheSpan?.SetData("cache.hit", false);
9999
cacheSpan?.Finish();
100100
return null;
101101
}

0 commit comments

Comments
 (0)