Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public SentryJCacheWrapper(final @NotNull Cache<K, V> 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);
}
Expand All @@ -71,7 +71,7 @@ public V get(final K key) {

@Override
public Map<K, V> getAll(final Set<? extends K> keys) {
final ISpan span = startSpanForKeys("cache.get", keys, "getAll");
final ISpan span = startSpanForKeys(keys, "getAll");
if (span == null) {
return delegate.getAll(keys);
}
Expand All @@ -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;
Expand All @@ -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);
}
Expand All @@ -136,7 +136,7 @@ public V getAndPut(final K key, final V value) {

@Override
public void putAll(final Map<? extends K, ? extends V> map) {
final ISpan span = startSpanForKeys("cache.put", map.keySet(), "putAll");
final ISpan span = startSpanForKeys(map.keySet(), "putAll");
if (span == null) {
delegate.putAll(map);
return;
Expand All @@ -155,7 +155,7 @@ public void putAll(final Map<? extends K, ? extends V> 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);
}
Expand All @@ -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);
}
Expand All @@ -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);
}
Expand All @@ -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);
}
Expand All @@ -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);
}
Expand All @@ -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);
}
Expand All @@ -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);
}
Expand All @@ -290,7 +290,7 @@ public V getAndRemove(final K key) {

@Override
public void removeAll(final Set<? extends K> keys) {
final ISpan span = startSpanForKeys("cache.remove", keys, "removeAll");
final ISpan span = startSpanForKeys(keys, "removeAll");
if (span == null) {
delegate.removeAll(keys);
return;
Expand All @@ -309,7 +309,7 @@ public void removeAll(final Set<? extends K> 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;
Expand All @@ -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;
Expand Down Expand Up @@ -358,7 +358,7 @@ public void close() {
public <T> T invoke(
final K key, final EntryProcessor<K, V, T> 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);
}
Expand All @@ -380,7 +380,7 @@ public <T> Map<K, EntryProcessorResult<T>> invokeAll(
final Set<? extends K> keys,
final EntryProcessor<K, V, T> 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);
}
Expand Down Expand Up @@ -453,9 +453,7 @@ public Iterator<Entry<K, V>> 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;
}
Expand All @@ -468,7 +466,7 @@ public Iterator<Entry<K, V>> 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;
}
Expand All @@ -480,9 +478,7 @@ public Iterator<Entry<K, V>> 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;
}
Expand All @@ -494,7 +490,8 @@ public Iterator<Entry<K, V>> 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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<*>
Expand Down Expand Up @@ -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"))
}

Expand All @@ -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")))
Expand All @@ -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"))
Expand All @@ -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"))
}
Expand All @@ -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"))
}
Expand All @@ -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"))
}
Expand Down Expand Up @@ -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"))
}

Expand All @@ -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"))
}
Expand All @@ -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"))
}

Expand All @@ -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"))
Expand All @@ -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"))
}

Expand All @@ -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"))
}

Expand Down
Loading
Loading