Skip to content

Commit

Permalink
Replace WeakConcurrentMaps with SpanConcurrentHashMaps in simple plug…
Browse files Browse the repository at this point in the history
…ins (#2093)
  • Loading branch information
eyalkoren authored Sep 13, 2021
1 parent 01a1468 commit 2533c5e
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import co.elastic.apm.agent.impl.transaction.Span;
import co.elastic.apm.agent.sdk.DynamicTransformer;
import co.elastic.apm.agent.sdk.ElasticApmInstrumentation;
import co.elastic.apm.agent.sdk.weakmap.WeakMapSupplier;
import co.elastic.apm.agent.util.SpanConcurrentHashMap;
import com.blogspot.mydailyjava.weaklockfree.WeakConcurrentMap;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.method.MethodDescription;
Expand Down Expand Up @@ -55,7 +55,7 @@ public abstract class AbstractAsyncHttpClientInstrumentation extends TracerAware

public static class Helper {

static final WeakConcurrentMap<AsyncHandler<?>, Span> handlerSpanMap = WeakMapSupplier.createMap();
static final WeakConcurrentMap<AsyncHandler<?>, Span> handlerSpanMap = SpanConcurrentHashMap.createWeakMap();

public static final List<Class<? extends ElasticApmInstrumentation>> ASYNC_HANDLER_INSTRUMENTATIONS = Arrays.<Class<? extends ElasticApmInstrumentation>>asList(
AsyncHandlerOnCompletedInstrumentation.class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
package co.elastic.apm.agent.dubbo;

import co.elastic.apm.agent.impl.transaction.AbstractSpan;
import co.elastic.apm.agent.sdk.weakmap.WeakMapSupplier;
import co.elastic.apm.agent.util.SpanConcurrentHashMap;
import com.alibaba.dubbo.remoting.exchange.ResponseCallback;
import com.blogspot.mydailyjava.weaklockfree.WeakConcurrentMap;

public class AlibabaCallbackHolder {
public static final WeakConcurrentMap<ResponseCallback, AbstractSpan<?>> callbackSpanMap = WeakMapSupplier.createMap();
public static final WeakConcurrentMap<ResponseCallback, AbstractSpan<?>> callbackSpanMap = SpanConcurrentHashMap.createWeakMap();
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import co.elastic.apm.agent.impl.transaction.AbstractSpan;
import co.elastic.apm.agent.impl.transaction.Outcome;
import co.elastic.apm.agent.impl.transaction.Span;
import co.elastic.apm.agent.sdk.weakmap.WeakMapSupplier;
import co.elastic.apm.agent.util.SpanConcurrentHashMap;
import com.blogspot.mydailyjava.weaklockfree.WeakConcurrentMap;

import javax.annotation.Nonnull;
Expand All @@ -33,7 +33,7 @@
*/
class ProcessHelper {

private static final ProcessHelper INSTANCE = new ProcessHelper(WeakMapSupplier.<Process, Span>createMap());
private static final ProcessHelper INSTANCE = new ProcessHelper(SpanConcurrentHashMap.<Process, Span>createWeakMap());

private final WeakConcurrentMap<Process, Span> inFlightSpans;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import co.elastic.apm.agent.bci.TracerAwareInstrumentation;
import co.elastic.apm.agent.impl.transaction.Span;
import co.elastic.apm.agent.sdk.weakmap.WeakMapSupplier;
import co.elastic.apm.agent.util.SpanConcurrentHashMap;
import com.blogspot.mydailyjava.weaklockfree.WeakConcurrentMap;
import com.lambdaworks.redis.protocol.RedisCommand;
import net.bytebuddy.matcher.ElementMatcher;
Expand All @@ -31,7 +31,8 @@
import static co.elastic.apm.agent.bci.bytebuddy.CustomElementMatchers.classLoaderCanLoadClass;

public abstract class Lettuce34Instrumentation extends TracerAwareInstrumentation {
static final WeakConcurrentMap<RedisCommand<?, ?, ?>, Span> commandToSpan = WeakMapSupplier.createMap();

static final WeakConcurrentMap<RedisCommand<?, ?, ?>, Span> commandToSpan = SpanConcurrentHashMap.createWeakMap();

/**
* We don't support Lettuce up to version 3.3, as the {@link RedisCommand#getType()} method is missing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import co.elastic.apm.agent.bci.TracerAwareInstrumentation;
import co.elastic.apm.agent.impl.transaction.Span;
import co.elastic.apm.agent.redis.RedisSpanUtils;
import co.elastic.apm.agent.sdk.weakmap.WeakMapSupplier;
import co.elastic.apm.agent.util.SpanConcurrentHashMap;
import com.blogspot.mydailyjava.weaklockfree.WeakConcurrentMap;
import io.lettuce.core.protocol.RedisCommand;
import net.bytebuddy.asm.Advice;
Expand All @@ -46,7 +46,7 @@
*/
public class Lettuce5StartSpanInstrumentation extends TracerAwareInstrumentation {

static final WeakConcurrentMap<RedisCommand<?, ?, ?>, Span> commandToSpan = WeakMapSupplier.createMap();
static final WeakConcurrentMap<RedisCommand<?, ?, ?>, Span> commandToSpan = SpanConcurrentHashMap.createWeakMap();

@Override
public ElementMatcher<? super TypeDescription> getTypeMatcher() {
Expand Down

0 comments on commit 2533c5e

Please sign in to comment.