diff --git a/sentry-jcache/src/main/java/io/sentry/jcache/SentryJCacheWrapper.java b/sentry-jcache/src/main/java/io/sentry/jcache/SentryJCacheWrapper.java index 81f84f4d7d..831394e75f 100644 --- a/sentry-jcache/src/main/java/io/sentry/jcache/SentryJCacheWrapper.java +++ b/sentry-jcache/src/main/java/io/sentry/jcache/SentryJCacheWrapper.java @@ -51,7 +51,7 @@ public SentryJCacheWrapper(final @NotNull Cache delegate, final @NotNull I @Override public V get(final K key) { - final ISpan span = startSpan("cache.get", key, "get"); + final ISpan span = startSpan(key, "get"); if (span == null) { return delegate.get(key); } @@ -71,7 +71,7 @@ public V get(final K key) { @Override public Map getAll(final Set keys) { - final ISpan span = startSpanForKeys("cache.get", keys, "getAll"); + final ISpan span = startSpanForKeys(keys, "getAll"); if (span == null) { return delegate.getAll(keys); } @@ -98,7 +98,7 @@ public boolean containsKey(final K key) { @Override public void put(final K key, final V value) { - final ISpan span = startSpan("cache.put", key, "put"); + final ISpan span = startSpan(key, "put"); if (span == null) { delegate.put(key, value); return; @@ -117,7 +117,7 @@ public void put(final K key, final V value) { @Override public V getAndPut(final K key, final V value) { - final ISpan span = startSpan("cache.put", key, "getAndPut"); + final ISpan span = startSpan(key, "getAndPut"); if (span == null) { return delegate.getAndPut(key, value); } @@ -136,7 +136,7 @@ public V getAndPut(final K key, final V value) { @Override public void putAll(final Map map) { - final ISpan span = startSpanForKeys("cache.put", map.keySet(), "putAll"); + final ISpan span = startSpanForKeys(map.keySet(), "putAll"); if (span == null) { delegate.putAll(map); return; @@ -155,7 +155,7 @@ public void putAll(final Map map) { @Override public boolean putIfAbsent(final K key, final V value) { - final ISpan span = startSpan("cache.put", key, "putIfAbsent"); + final ISpan span = startSpan(key, "putIfAbsent"); if (span == null) { return delegate.putIfAbsent(key, value); } @@ -174,7 +174,7 @@ public boolean putIfAbsent(final K key, final V value) { @Override public boolean replace(final K key, final V oldValue, final V newValue) { - final ISpan span = startSpan("cache.put", key, "replace"); + final ISpan span = startSpan(key, "replace"); if (span == null) { return delegate.replace(key, oldValue, newValue); } @@ -193,7 +193,7 @@ public boolean replace(final K key, final V oldValue, final V newValue) { @Override public boolean replace(final K key, final V value) { - final ISpan span = startSpan("cache.put", key, "replace"); + final ISpan span = startSpan(key, "replace"); if (span == null) { return delegate.replace(key, value); } @@ -212,7 +212,7 @@ public boolean replace(final K key, final V value) { @Override public V getAndReplace(final K key, final V value) { - final ISpan span = startSpan("cache.put", key, "getAndReplace"); + final ISpan span = startSpan(key, "getAndReplace"); if (span == null) { return delegate.getAndReplace(key, value); } @@ -233,7 +233,7 @@ public V getAndReplace(final K key, final V value) { @Override public boolean remove(final K key) { - final ISpan span = startSpan("cache.remove", key, "remove"); + final ISpan span = startSpan(key, "remove"); if (span == null) { return delegate.remove(key); } @@ -252,7 +252,7 @@ public boolean remove(final K key) { @Override public boolean remove(final K key, final V oldValue) { - final ISpan span = startSpan("cache.remove", key, "remove"); + final ISpan span = startSpan(key, "remove"); if (span == null) { return delegate.remove(key, oldValue); } @@ -271,7 +271,7 @@ public boolean remove(final K key, final V oldValue) { @Override public V getAndRemove(final K key) { - final ISpan span = startSpan("cache.remove", key, "getAndRemove"); + final ISpan span = startSpan(key, "getAndRemove"); if (span == null) { return delegate.getAndRemove(key); } @@ -290,7 +290,7 @@ public V getAndRemove(final K key) { @Override public void removeAll(final Set keys) { - final ISpan span = startSpanForKeys("cache.remove", keys, "removeAll"); + final ISpan span = startSpanForKeys(keys, "removeAll"); if (span == null) { delegate.removeAll(keys); return; @@ -309,7 +309,7 @@ public void removeAll(final Set keys) { @Override public void removeAll() { - final ISpan span = startSpan("cache.flush", null, "removeAll"); + final ISpan span = startSpan(null, "removeAll"); if (span == null) { delegate.removeAll(); return; @@ -330,7 +330,7 @@ public void removeAll() { @Override public void clear() { - final ISpan span = startSpan("cache.flush", null, "clear"); + final ISpan span = startSpan(null, "clear"); if (span == null) { delegate.clear(); return; @@ -358,7 +358,7 @@ public void close() { public T invoke( final K key, final EntryProcessor entryProcessor, final Object... arguments) throws EntryProcessorException { - final ISpan span = startSpan("cache.get", key, "invoke"); + final ISpan span = startSpan(key, "invoke"); if (span == null) { return delegate.invoke(key, entryProcessor, arguments); } @@ -380,7 +380,7 @@ public Map> invokeAll( final Set keys, final EntryProcessor entryProcessor, final Object... arguments) { - final ISpan span = startSpanForKeys("cache.get", keys, "invokeAll"); + final ISpan span = startSpanForKeys(keys, "invokeAll"); if (span == null) { return delegate.invokeAll(keys, entryProcessor, arguments); } @@ -453,9 +453,7 @@ public Iterator> iterator() { // -- span helpers -- private @Nullable ISpan startSpan( - final @NotNull String operation, - final @Nullable Object key, - final @NotNull String operationName) { + final @Nullable Object key, final @NotNull String operationName) { if (!scopes.getOptions().isEnableCacheTracing()) { return null; } @@ -468,7 +466,7 @@ public Iterator> iterator() { final SpanOptions spanOptions = new SpanOptions(); spanOptions.setOrigin(TRACE_ORIGIN); final String keyString = key != null ? String.valueOf(key) : null; - final ISpan span = activeSpan.startChild(operation, keyString, spanOptions); + final ISpan span = activeSpan.startChild("cache." + operationName, keyString, spanOptions); if (span.isNoOp()) { return null; } @@ -480,9 +478,7 @@ public Iterator> iterator() { } private @Nullable ISpan startSpanForKeys( - final @NotNull String operation, - final @NotNull Set keys, - final @NotNull String operationName) { + final @NotNull Set keys, final @NotNull String operationName) { if (!scopes.getOptions().isEnableCacheTracing()) { return null; } @@ -494,7 +490,8 @@ public Iterator> iterator() { final SpanOptions spanOptions = new SpanOptions(); spanOptions.setOrigin(TRACE_ORIGIN); - final ISpan span = activeSpan.startChild(operation, delegate.getName(), spanOptions); + final ISpan span = + activeSpan.startChild("cache." + operationName, delegate.getName(), spanOptions); if (span.isNoOp()) { return null; } diff --git a/sentry-jcache/src/test/kotlin/io/sentry/jcache/SentryJCacheWrapperTest.kt b/sentry-jcache/src/test/kotlin/io/sentry/jcache/SentryJCacheWrapperTest.kt index a0d6548121..7b3692bbdd 100644 --- a/sentry-jcache/src/test/kotlin/io/sentry/jcache/SentryJCacheWrapperTest.kt +++ b/sentry-jcache/src/test/kotlin/io/sentry/jcache/SentryJCacheWrapperTest.kt @@ -94,7 +94,7 @@ class SentryJCacheWrapperTest { assertEquals(mapOf("k1" to "v1"), result) assertEquals(1, tx.spans.size) val span = tx.spans.first() - assertEquals("cache.get", span.operation) + assertEquals("cache.getAll", span.operation) assertEquals("testCache", span.description) assertEquals(true, span.getData(SpanDataConvention.CACHE_HIT_KEY)) val cacheKeys = span.getData(SpanDataConvention.CACHE_KEY_KEY) as List<*> @@ -144,7 +144,7 @@ class SentryJCacheWrapperTest { assertEquals("oldValue", result) assertEquals(1, tx.spans.size) - assertEquals("cache.put", tx.spans.first().operation) + assertEquals("cache.getAndPut", tx.spans.first().operation) assertEquals("getAndPut", tx.spans.first().getData("db.operation.name")) } @@ -161,7 +161,7 @@ class SentryJCacheWrapperTest { verify(delegate).putAll(entries) assertEquals(1, tx.spans.size) val span = tx.spans.first() - assertEquals("cache.put", span.operation) + assertEquals("cache.putAll", span.operation) assertEquals("testCache", span.description) val cacheKeys = span.getData(SpanDataConvention.CACHE_KEY_KEY) as List<*> assertTrue(cacheKeys.containsAll(listOf("k1", "k2"))) @@ -182,7 +182,7 @@ class SentryJCacheWrapperTest { verify(delegate).putIfAbsent("myKey", "myValue") assertEquals(1, tx.spans.size) val span = tx.spans.first() - assertEquals("cache.put", span.operation) + assertEquals("cache.putIfAbsent", span.operation) assertEquals(SpanStatus.OK, span.status) assertEquals(listOf("myKey"), span.getData(SpanDataConvention.CACHE_KEY_KEY)) assertEquals("putIfAbsent", span.getData("db.operation.name")) @@ -202,7 +202,7 @@ class SentryJCacheWrapperTest { verify(delegate).replace("myKey", "old", "new") assertEquals(1, tx.spans.size) val span = tx.spans.first() - assertEquals("cache.put", span.operation) + assertEquals("cache.replace", span.operation) assertEquals(SpanStatus.OK, span.status) assertEquals("replace", span.getData("db.operation.name")) } @@ -219,7 +219,7 @@ class SentryJCacheWrapperTest { verify(delegate).replace("myKey", "value") assertEquals(1, tx.spans.size) val span = tx.spans.first() - assertEquals("cache.put", span.operation) + assertEquals("cache.replace", span.operation) assertEquals(SpanStatus.OK, span.status) assertEquals("replace", span.getData("db.operation.name")) } @@ -238,7 +238,7 @@ class SentryJCacheWrapperTest { verify(delegate).getAndReplace("myKey", "newValue") assertEquals(1, tx.spans.size) val span = tx.spans.first() - assertEquals("cache.put", span.operation) + assertEquals("cache.getAndReplace", span.operation) assertEquals(SpanStatus.OK, span.status) assertEquals("getAndReplace", span.getData("db.operation.name")) } @@ -289,7 +289,7 @@ class SentryJCacheWrapperTest { assertEquals("value", result) assertEquals(1, tx.spans.size) - assertEquals("cache.remove", tx.spans.first().operation) + assertEquals("cache.getAndRemove", tx.spans.first().operation) assertEquals("getAndRemove", tx.spans.first().getData("db.operation.name")) } @@ -306,7 +306,7 @@ class SentryJCacheWrapperTest { verify(delegate).removeAll(keys) assertEquals(1, tx.spans.size) val span = tx.spans.first() - assertEquals("cache.remove", span.operation) + assertEquals("cache.removeAll", span.operation) assertEquals("testCache", span.description) assertEquals("removeAll", span.getData("db.operation.name")) } @@ -322,7 +322,7 @@ class SentryJCacheWrapperTest { verify(delegate).removeAll() assertEquals(1, tx.spans.size) - assertEquals("cache.flush", tx.spans.first().operation) + assertEquals("cache.removeAll", tx.spans.first().operation) assertEquals("removeAll", tx.spans.first().getData("db.operation.name")) } @@ -338,7 +338,7 @@ class SentryJCacheWrapperTest { verify(delegate).clear() assertEquals(1, tx.spans.size) val span = tx.spans.first() - assertEquals("cache.flush", span.operation) + assertEquals("cache.clear", span.operation) assertEquals(SpanStatus.OK, span.status) assertNull(span.getData(SpanDataConvention.CACHE_KEY_KEY)) assertEquals("clear", span.getData("db.operation.name")) @@ -357,7 +357,7 @@ class SentryJCacheWrapperTest { assertEquals("result", result) assertEquals(1, tx.spans.size) - assertEquals("cache.get", tx.spans.first().operation) + assertEquals("cache.invoke", tx.spans.first().operation) assertEquals("invoke", tx.spans.first().getData("db.operation.name")) } @@ -376,7 +376,7 @@ class SentryJCacheWrapperTest { assertEquals(resultMap, result) assertEquals(1, tx.spans.size) - assertEquals("cache.get", tx.spans.first().operation) + assertEquals("cache.invokeAll", tx.spans.first().operation) assertEquals("invokeAll", tx.spans.first().getData("db.operation.name")) } diff --git a/sentry-spring-7/src/main/java/io/sentry/spring7/cache/SentryCacheWrapper.java b/sentry-spring-7/src/main/java/io/sentry/spring7/cache/SentryCacheWrapper.java index 58b803d40e..114eb97979 100644 --- a/sentry-spring-7/src/main/java/io/sentry/spring7/cache/SentryCacheWrapper.java +++ b/sentry-spring-7/src/main/java/io/sentry/spring7/cache/SentryCacheWrapper.java @@ -42,7 +42,7 @@ public SentryCacheWrapper(final @NotNull Cache delegate, final @NotNull IScopes @Override public @Nullable ValueWrapper get(final @NotNull Object key) { - final ISpan span = startSpan("cache.get", key, "get"); + final ISpan span = startSpan(key, "get"); if (span == null) { return delegate.get(key); } @@ -62,7 +62,7 @@ public SentryCacheWrapper(final @NotNull Cache delegate, final @NotNull IScopes @Override public @Nullable T get(final @NotNull Object key, final @Nullable Class type) { - final ISpan span = startSpan("cache.get", key, "get"); + final ISpan span = startSpan(key, "get"); if (span == null) { return delegate.get(key, type); } @@ -83,7 +83,7 @@ public SentryCacheWrapper(final @NotNull Cache delegate, final @NotNull IScopes @Override public @Nullable T get(final @NotNull Object key, final @NotNull Callable valueLoader) { - final ISpan span = startSpan("cache.get", key, "get"); + final ISpan span = startSpan(key, "get"); if (span == null) { return delegate.get(key, valueLoader); } @@ -110,7 +110,7 @@ public SentryCacheWrapper(final @NotNull Cache delegate, final @NotNull IScopes @Override public @Nullable CompletableFuture retrieve(final @NotNull Object key) { - final ISpan span = startSpan("cache.get", key, "retrieve"); + final ISpan span = startSpan(key, "retrieve"); if (span == null) { return delegate.retrieve(key); } @@ -145,7 +145,7 @@ public SentryCacheWrapper(final @NotNull Cache delegate, final @NotNull IScopes @Override public CompletableFuture retrieve( final @NotNull Object key, final @NotNull Supplier> valueLoader) { - final ISpan span = startSpan("cache.get", key, "retrieve"); + final ISpan span = startSpan(key, "retrieve"); if (span == null) { return delegate.retrieve(key, valueLoader); } @@ -180,7 +180,7 @@ public CompletableFuture retrieve( @Override public void put(final @NotNull Object key, final @Nullable Object value) { - final ISpan span = startSpan("cache.put", key, "put"); + final ISpan span = startSpan(key, "put"); if (span == null) { delegate.put(key, value); return; @@ -200,7 +200,7 @@ public void put(final @NotNull Object key, final @Nullable Object value) { @Override public @Nullable ValueWrapper putIfAbsent( final @NotNull Object key, final @Nullable Object value) { - final ISpan span = startSpan("cache.put", key, "putIfAbsent"); + final ISpan span = startSpan(key, "putIfAbsent"); if (span == null) { return delegate.putIfAbsent(key, value); } @@ -219,7 +219,7 @@ public void put(final @NotNull Object key, final @Nullable Object value) { @Override public void evict(final @NotNull Object key) { - final ISpan span = startSpan("cache.remove", key, "evict"); + final ISpan span = startSpan(key, "evict"); if (span == null) { delegate.evict(key); return; @@ -238,7 +238,7 @@ public void evict(final @NotNull Object key) { @Override public boolean evictIfPresent(final @NotNull Object key) { - final ISpan span = startSpan("cache.remove", key, "evictIfPresent"); + final ISpan span = startSpan(key, "evictIfPresent"); if (span == null) { return delegate.evictIfPresent(key); } @@ -257,7 +257,7 @@ public boolean evictIfPresent(final @NotNull Object key) { @Override public void clear() { - final ISpan span = startSpan("cache.flush", null, "clear"); + final ISpan span = startSpan(null, "clear"); if (span == null) { delegate.clear(); return; @@ -276,7 +276,7 @@ public void clear() { @Override public boolean invalidate() { - final ISpan span = startSpan("cache.flush", null, "invalidate"); + final ISpan span = startSpan(null, "invalidate"); if (span == null) { return delegate.invalidate(); } @@ -294,9 +294,7 @@ public boolean invalidate() { } private @Nullable ISpan startSpan( - final @NotNull String operation, - final @Nullable Object key, - final @NotNull String operationName) { + final @Nullable Object key, final @NotNull String operationName) { if (!scopes.getOptions().isEnableCacheTracing()) { return null; } @@ -309,7 +307,7 @@ public boolean invalidate() { final SpanOptions spanOptions = new SpanOptions(); spanOptions.setOrigin(TRACE_ORIGIN); final String keyString = key != null ? String.valueOf(key) : null; - final ISpan span = activeSpan.startChild(operation, keyString, spanOptions); + final ISpan span = activeSpan.startChild("cache." + operationName, keyString, spanOptions); if (span.isNoOp()) { return null; } diff --git a/sentry-spring-7/src/test/kotlin/io/sentry/spring7/cache/SentryCacheWrapperTest.kt b/sentry-spring-7/src/test/kotlin/io/sentry/spring7/cache/SentryCacheWrapperTest.kt index d42fcabaeb..f6e4d75a0a 100644 --- a/sentry-spring-7/src/test/kotlin/io/sentry/spring7/cache/SentryCacheWrapperTest.kt +++ b/sentry-spring-7/src/test/kotlin/io/sentry/spring7/cache/SentryCacheWrapperTest.kt @@ -187,7 +187,7 @@ class SentryCacheWrapperTest { assertEquals("value", result!!.get()) assertEquals(1, tx.spans.size) val span = tx.spans.first() - assertEquals("cache.get", span.operation) + assertEquals("cache.retrieve", span.operation) assertEquals("myKey", span.description) assertEquals(SpanStatus.OK, span.status) assertEquals(true, span.getData(SpanDataConvention.CACHE_HIT_KEY)) @@ -373,7 +373,7 @@ class SentryCacheWrapperTest { verify(delegate).putIfAbsent("myKey", "myValue") assertEquals(1, tx.spans.size) val span = tx.spans.first() - assertEquals("cache.put", span.operation) + assertEquals("cache.putIfAbsent", span.operation) assertEquals(SpanStatus.OK, span.status) assertEquals(listOf("myKey"), span.getData(SpanDataConvention.CACHE_KEY_KEY)) assertEquals("putIfAbsent", span.getData("db.operation.name")) @@ -391,7 +391,7 @@ class SentryCacheWrapperTest { verify(delegate).evict("myKey") assertEquals(1, tx.spans.size) val span = tx.spans.first() - assertEquals("cache.remove", span.operation) + assertEquals("cache.evict", span.operation) assertEquals(SpanStatus.OK, span.status) assertEquals("evict", span.getData("db.operation.name")) } @@ -408,7 +408,7 @@ class SentryCacheWrapperTest { assertTrue(result) assertEquals(1, tx.spans.size) - assertEquals("cache.remove", tx.spans.first().operation) + assertEquals("cache.evictIfPresent", tx.spans.first().operation) assertEquals("evictIfPresent", tx.spans.first().getData("db.operation.name")) } @@ -424,7 +424,7 @@ class SentryCacheWrapperTest { verify(delegate).clear() assertEquals(1, tx.spans.size) val span = tx.spans.first() - assertEquals("cache.flush", span.operation) + assertEquals("cache.clear", span.operation) assertEquals(SpanStatus.OK, span.status) assertNull(span.getData(SpanDataConvention.CACHE_KEY_KEY)) assertEquals("clear", span.getData("db.operation.name")) @@ -442,7 +442,7 @@ class SentryCacheWrapperTest { assertTrue(result) assertEquals(1, tx.spans.size) - assertEquals("cache.flush", tx.spans.first().operation) + assertEquals("cache.invalidate", tx.spans.first().operation) assertEquals("invalidate", tx.spans.first().getData("db.operation.name")) } diff --git a/sentry-spring-jakarta/src/main/java/io/sentry/spring/jakarta/cache/SentryCacheWrapper.java b/sentry-spring-jakarta/src/main/java/io/sentry/spring/jakarta/cache/SentryCacheWrapper.java index 79ea227dbe..cb6d4b5039 100644 --- a/sentry-spring-jakarta/src/main/java/io/sentry/spring/jakarta/cache/SentryCacheWrapper.java +++ b/sentry-spring-jakarta/src/main/java/io/sentry/spring/jakarta/cache/SentryCacheWrapper.java @@ -42,7 +42,7 @@ public SentryCacheWrapper(final @NotNull Cache delegate, final @NotNull IScopes @Override public @Nullable ValueWrapper get(final @NotNull Object key) { - final ISpan span = startSpan("cache.get", key, "get"); + final ISpan span = startSpan(key, "get"); if (span == null) { return delegate.get(key); } @@ -62,7 +62,7 @@ public SentryCacheWrapper(final @NotNull Cache delegate, final @NotNull IScopes @Override public @Nullable T get(final @NotNull Object key, final @Nullable Class type) { - final ISpan span = startSpan("cache.get", key, "get"); + final ISpan span = startSpan(key, "get"); if (span == null) { return delegate.get(key, type); } @@ -83,7 +83,7 @@ public SentryCacheWrapper(final @NotNull Cache delegate, final @NotNull IScopes @Override public @Nullable T get(final @NotNull Object key, final @NotNull Callable valueLoader) { - final ISpan span = startSpan("cache.get", key, "get"); + final ISpan span = startSpan(key, "get"); if (span == null) { return delegate.get(key, valueLoader); } @@ -110,7 +110,7 @@ public SentryCacheWrapper(final @NotNull Cache delegate, final @NotNull IScopes @Override public @Nullable CompletableFuture retrieve(final @NotNull Object key) { - final ISpan span = startSpan("cache.get", key, "retrieve"); + final ISpan span = startSpan(key, "retrieve"); if (span == null) { return delegate.retrieve(key); } @@ -145,7 +145,7 @@ public SentryCacheWrapper(final @NotNull Cache delegate, final @NotNull IScopes @Override public CompletableFuture retrieve( final @NotNull Object key, final @NotNull Supplier> valueLoader) { - final ISpan span = startSpan("cache.get", key, "retrieve"); + final ISpan span = startSpan(key, "retrieve"); if (span == null) { return delegate.retrieve(key, valueLoader); } @@ -180,7 +180,7 @@ public CompletableFuture retrieve( @Override public void put(final @NotNull Object key, final @Nullable Object value) { - final ISpan span = startSpan("cache.put", key, "put"); + final ISpan span = startSpan(key, "put"); if (span == null) { delegate.put(key, value); return; @@ -200,7 +200,7 @@ public void put(final @NotNull Object key, final @Nullable Object value) { @Override public @Nullable ValueWrapper putIfAbsent( final @NotNull Object key, final @Nullable Object value) { - final ISpan span = startSpan("cache.put", key, "putIfAbsent"); + final ISpan span = startSpan(key, "putIfAbsent"); if (span == null) { return delegate.putIfAbsent(key, value); } @@ -219,7 +219,7 @@ public void put(final @NotNull Object key, final @Nullable Object value) { @Override public void evict(final @NotNull Object key) { - final ISpan span = startSpan("cache.remove", key, "evict"); + final ISpan span = startSpan(key, "evict"); if (span == null) { delegate.evict(key); return; @@ -238,7 +238,7 @@ public void evict(final @NotNull Object key) { @Override public boolean evictIfPresent(final @NotNull Object key) { - final ISpan span = startSpan("cache.remove", key, "evictIfPresent"); + final ISpan span = startSpan(key, "evictIfPresent"); if (span == null) { return delegate.evictIfPresent(key); } @@ -257,7 +257,7 @@ public boolean evictIfPresent(final @NotNull Object key) { @Override public void clear() { - final ISpan span = startSpan("cache.flush", null, "clear"); + final ISpan span = startSpan(null, "clear"); if (span == null) { delegate.clear(); return; @@ -276,7 +276,7 @@ public void clear() { @Override public boolean invalidate() { - final ISpan span = startSpan("cache.flush", null, "invalidate"); + final ISpan span = startSpan(null, "invalidate"); if (span == null) { return delegate.invalidate(); } @@ -294,9 +294,7 @@ public boolean invalidate() { } private @Nullable ISpan startSpan( - final @NotNull String operation, - final @Nullable Object key, - final @NotNull String operationName) { + final @Nullable Object key, final @NotNull String operationName) { if (!scopes.getOptions().isEnableCacheTracing()) { return null; } @@ -309,7 +307,7 @@ public boolean invalidate() { final SpanOptions spanOptions = new SpanOptions(); spanOptions.setOrigin(TRACE_ORIGIN); final String keyString = key != null ? String.valueOf(key) : null; - final ISpan span = activeSpan.startChild(operation, keyString, spanOptions); + final ISpan span = activeSpan.startChild("cache." + operationName, keyString, spanOptions); if (span.isNoOp()) { return null; } diff --git a/sentry-spring-jakarta/src/test/kotlin/io/sentry/spring/jakarta/cache/SentryCacheWrapperTest.kt b/sentry-spring-jakarta/src/test/kotlin/io/sentry/spring/jakarta/cache/SentryCacheWrapperTest.kt index 62cb26a5af..8bbcf0186b 100644 --- a/sentry-spring-jakarta/src/test/kotlin/io/sentry/spring/jakarta/cache/SentryCacheWrapperTest.kt +++ b/sentry-spring-jakarta/src/test/kotlin/io/sentry/spring/jakarta/cache/SentryCacheWrapperTest.kt @@ -187,7 +187,7 @@ class SentryCacheWrapperTest { assertEquals("value", result!!.get()) assertEquals(1, tx.spans.size) val span = tx.spans.first() - assertEquals("cache.get", span.operation) + assertEquals("cache.retrieve", span.operation) assertEquals("myKey", span.description) assertEquals(SpanStatus.OK, span.status) assertEquals(true, span.getData(SpanDataConvention.CACHE_HIT_KEY)) @@ -373,7 +373,7 @@ class SentryCacheWrapperTest { verify(delegate).putIfAbsent("myKey", "myValue") assertEquals(1, tx.spans.size) val span = tx.spans.first() - assertEquals("cache.put", span.operation) + assertEquals("cache.putIfAbsent", span.operation) assertEquals(SpanStatus.OK, span.status) assertEquals(listOf("myKey"), span.getData(SpanDataConvention.CACHE_KEY_KEY)) assertEquals("putIfAbsent", span.getData("db.operation.name")) @@ -391,7 +391,7 @@ class SentryCacheWrapperTest { verify(delegate).evict("myKey") assertEquals(1, tx.spans.size) val span = tx.spans.first() - assertEquals("cache.remove", span.operation) + assertEquals("cache.evict", span.operation) assertEquals(SpanStatus.OK, span.status) assertEquals("evict", span.getData("db.operation.name")) } @@ -408,7 +408,7 @@ class SentryCacheWrapperTest { assertTrue(result) assertEquals(1, tx.spans.size) - assertEquals("cache.remove", tx.spans.first().operation) + assertEquals("cache.evictIfPresent", tx.spans.first().operation) assertEquals("evictIfPresent", tx.spans.first().getData("db.operation.name")) } @@ -424,7 +424,7 @@ class SentryCacheWrapperTest { verify(delegate).clear() assertEquals(1, tx.spans.size) val span = tx.spans.first() - assertEquals("cache.flush", span.operation) + assertEquals("cache.clear", span.operation) assertEquals(SpanStatus.OK, span.status) assertNull(span.getData(SpanDataConvention.CACHE_KEY_KEY)) assertEquals("clear", span.getData("db.operation.name")) @@ -442,7 +442,7 @@ class SentryCacheWrapperTest { assertTrue(result) assertEquals(1, tx.spans.size) - assertEquals("cache.flush", tx.spans.first().operation) + assertEquals("cache.invalidate", tx.spans.first().operation) assertEquals("invalidate", tx.spans.first().getData("db.operation.name")) } diff --git a/sentry-spring/src/main/java/io/sentry/spring/cache/SentryCacheWrapper.java b/sentry-spring/src/main/java/io/sentry/spring/cache/SentryCacheWrapper.java index 1b895deea5..d0cac9304f 100644 --- a/sentry-spring/src/main/java/io/sentry/spring/cache/SentryCacheWrapper.java +++ b/sentry-spring/src/main/java/io/sentry/spring/cache/SentryCacheWrapper.java @@ -40,7 +40,7 @@ public SentryCacheWrapper(final @NotNull Cache delegate, final @NotNull IScopes @Override public @Nullable ValueWrapper get(final @NotNull Object key) { - final ISpan span = startSpan("cache.get", key, "get"); + final ISpan span = startSpan(key, "get"); if (span == null) { return delegate.get(key); } @@ -60,7 +60,7 @@ public SentryCacheWrapper(final @NotNull Cache delegate, final @NotNull IScopes @Override public @Nullable T get(final @NotNull Object key, final @Nullable Class type) { - final ISpan span = startSpan("cache.get", key, "get"); + final ISpan span = startSpan(key, "get"); if (span == null) { return delegate.get(key, type); } @@ -81,7 +81,7 @@ public SentryCacheWrapper(final @NotNull Cache delegate, final @NotNull IScopes @Override public @Nullable T get(final @NotNull Object key, final @NotNull Callable valueLoader) { - final ISpan span = startSpan("cache.get", key, "get"); + final ISpan span = startSpan(key, "get"); if (span == null) { return delegate.get(key, valueLoader); } @@ -108,7 +108,7 @@ public SentryCacheWrapper(final @NotNull Cache delegate, final @NotNull IScopes @Override public void put(final @NotNull Object key, final @Nullable Object value) { - final ISpan span = startSpan("cache.put", key, "put"); + final ISpan span = startSpan(key, "put"); if (span == null) { delegate.put(key, value); return; @@ -128,7 +128,7 @@ public void put(final @NotNull Object key, final @Nullable Object value) { @Override public @Nullable ValueWrapper putIfAbsent( final @NotNull Object key, final @Nullable Object value) { - final ISpan span = startSpan("cache.put", key, "putIfAbsent"); + final ISpan span = startSpan(key, "putIfAbsent"); if (span == null) { return delegate.putIfAbsent(key, value); } @@ -147,7 +147,7 @@ public void put(final @NotNull Object key, final @Nullable Object value) { @Override public void evict(final @NotNull Object key) { - final ISpan span = startSpan("cache.remove", key, "evict"); + final ISpan span = startSpan(key, "evict"); if (span == null) { delegate.evict(key); return; @@ -166,7 +166,7 @@ public void evict(final @NotNull Object key) { @Override public boolean evictIfPresent(final @NotNull Object key) { - final ISpan span = startSpan("cache.remove", key, "evictIfPresent"); + final ISpan span = startSpan(key, "evictIfPresent"); if (span == null) { return delegate.evictIfPresent(key); } @@ -185,7 +185,7 @@ public boolean evictIfPresent(final @NotNull Object key) { @Override public void clear() { - final ISpan span = startSpan("cache.flush", null, "clear"); + final ISpan span = startSpan(null, "clear"); if (span == null) { delegate.clear(); return; @@ -204,7 +204,7 @@ public void clear() { @Override public boolean invalidate() { - final ISpan span = startSpan("cache.flush", null, "invalidate"); + final ISpan span = startSpan(null, "invalidate"); if (span == null) { return delegate.invalidate(); } @@ -222,9 +222,7 @@ public boolean invalidate() { } private @Nullable ISpan startSpan( - final @NotNull String operation, - final @Nullable Object key, - final @NotNull String operationName) { + final @Nullable Object key, final @NotNull String operationName) { if (!scopes.getOptions().isEnableCacheTracing()) { return null; } @@ -237,7 +235,7 @@ public boolean invalidate() { final SpanOptions spanOptions = new SpanOptions(); spanOptions.setOrigin(TRACE_ORIGIN); final String keyString = key != null ? String.valueOf(key) : null; - final ISpan span = activeSpan.startChild(operation, keyString, spanOptions); + final ISpan span = activeSpan.startChild("cache." + operationName, keyString, spanOptions); if (span.isNoOp()) { return null; } diff --git a/sentry-spring/src/test/kotlin/io/sentry/spring/cache/SentryCacheWrapperTest.kt b/sentry-spring/src/test/kotlin/io/sentry/spring/cache/SentryCacheWrapperTest.kt index 74af2721b7..35bf2b30d0 100644 --- a/sentry-spring/src/test/kotlin/io/sentry/spring/cache/SentryCacheWrapperTest.kt +++ b/sentry-spring/src/test/kotlin/io/sentry/spring/cache/SentryCacheWrapperTest.kt @@ -204,7 +204,7 @@ class SentryCacheWrapperTest { verify(delegate).putIfAbsent("myKey", "myValue") assertEquals(1, tx.spans.size) val span = tx.spans.first() - assertEquals("cache.put", span.operation) + assertEquals("cache.putIfAbsent", span.operation) assertEquals(SpanStatus.OK, span.status) assertEquals(listOf("myKey"), span.getData(SpanDataConvention.CACHE_KEY_KEY)) assertEquals("putIfAbsent", span.getData("db.operation.name")) @@ -222,7 +222,7 @@ class SentryCacheWrapperTest { verify(delegate).evict("myKey") assertEquals(1, tx.spans.size) val span = tx.spans.first() - assertEquals("cache.remove", span.operation) + assertEquals("cache.evict", span.operation) assertEquals(SpanStatus.OK, span.status) assertEquals("evict", span.getData("db.operation.name")) } @@ -239,7 +239,7 @@ class SentryCacheWrapperTest { assertTrue(result) assertEquals(1, tx.spans.size) - assertEquals("cache.remove", tx.spans.first().operation) + assertEquals("cache.evictIfPresent", tx.spans.first().operation) assertEquals("evictIfPresent", tx.spans.first().getData("db.operation.name")) } @@ -255,7 +255,7 @@ class SentryCacheWrapperTest { verify(delegate).clear() assertEquals(1, tx.spans.size) val span = tx.spans.first() - assertEquals("cache.flush", span.operation) + assertEquals("cache.clear", span.operation) assertEquals(SpanStatus.OK, span.status) assertNull(span.getData(SpanDataConvention.CACHE_KEY_KEY)) assertEquals("clear", span.getData("db.operation.name")) @@ -273,7 +273,7 @@ class SentryCacheWrapperTest { assertTrue(result) assertEquals(1, tx.spans.size) - assertEquals("cache.flush", tx.spans.first().operation) + assertEquals("cache.invalidate", tx.spans.first().operation) assertEquals("invalidate", tx.spans.first().getData("db.operation.name")) }