Update spymemcached-2.12 to new agent api
This commit is contained in:
parent
f0c29adb61
commit
05e6544ded
|
@ -1,12 +1,13 @@
|
|||
package datadog.trace.instrumentation.spymemcached;
|
||||
|
||||
import io.opentracing.Span;
|
||||
import datadog.trace.instrumentation.api.AgentSpan;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import net.spy.memcached.MemcachedConnection;
|
||||
import net.spy.memcached.internal.BulkGetFuture;
|
||||
|
||||
public class BulkGetCompletionListener extends CompletionListener<BulkGetFuture<?>>
|
||||
implements net.spy.memcached.internal.BulkGetCompletionListener {
|
||||
|
||||
public BulkGetCompletionListener(final MemcachedConnection connection, final String methodName) {
|
||||
super(connection, methodName);
|
||||
}
|
||||
|
@ -17,7 +18,7 @@ public class BulkGetCompletionListener extends CompletionListener<BulkGetFuture<
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void processResult(final Span span, final BulkGetFuture<?> future)
|
||||
protected void processResult(final AgentSpan span, final BulkGetFuture<?> future)
|
||||
throws ExecutionException, InterruptedException {
|
||||
/*
|
||||
Note: for now we do not have an affective way of representing results of bulk operations,
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
package datadog.trace.instrumentation.spymemcached;
|
||||
|
||||
import static datadog.trace.instrumentation.api.AgentTracer.activateSpan;
|
||||
import static datadog.trace.instrumentation.api.AgentTracer.startSpan;
|
||||
import static datadog.trace.instrumentation.spymemcached.MemcacheClientDecorator.DECORATE;
|
||||
|
||||
import io.opentracing.Scope;
|
||||
import io.opentracing.Span;
|
||||
import io.opentracing.util.GlobalTracer;
|
||||
import datadog.trace.instrumentation.api.AgentScope;
|
||||
import datadog.trace.instrumentation.api.AgentSpan;
|
||||
import java.util.concurrent.CancellationException;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
@ -25,12 +26,12 @@ public abstract class CompletionListener<T> {
|
|||
static final String MISS = "miss";
|
||||
|
||||
private final MemcachedConnection connection;
|
||||
private final Span span;
|
||||
private final AgentSpan span;
|
||||
|
||||
public CompletionListener(final MemcachedConnection connection, final String methodName) {
|
||||
this.connection = connection;
|
||||
span = GlobalTracer.get().buildSpan(OPERATION_NAME).start();
|
||||
try (final Scope scope = GlobalTracer.get().scopeManager().activate(span, false)) {
|
||||
span = startSpan(OPERATION_NAME);
|
||||
try (final AgentScope scope = activateSpan(span, false)) {
|
||||
DECORATE.afterStart(span);
|
||||
DECORATE.onConnection(span, connection);
|
||||
DECORATE.onOperation(span, methodName);
|
||||
|
@ -38,7 +39,7 @@ public abstract class CompletionListener<T> {
|
|||
}
|
||||
|
||||
protected void closeAsyncSpan(final T future) {
|
||||
try (final Scope scope = GlobalTracer.get().scopeManager().activate(span, false)) {
|
||||
try (final AgentScope scope = activateSpan(span, false)) {
|
||||
try {
|
||||
processResult(span, future);
|
||||
} catch (final CancellationException e) {
|
||||
|
@ -66,17 +67,17 @@ public abstract class CompletionListener<T> {
|
|||
}
|
||||
|
||||
protected void closeSyncSpan(final Throwable thrown) {
|
||||
try (final Scope scope = GlobalTracer.get().scopeManager().activate(span, false)) {
|
||||
try (final AgentScope scope = activateSpan(span, false)) {
|
||||
DECORATE.onError(span, thrown);
|
||||
DECORATE.beforeFinish(span);
|
||||
span.finish();
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract void processResult(Span span, T future)
|
||||
protected abstract void processResult(AgentSpan span, T future)
|
||||
throws ExecutionException, InterruptedException;
|
||||
|
||||
protected void setResultTag(final Span span, final boolean hit) {
|
||||
protected void setResultTag(final AgentSpan span, final boolean hit) {
|
||||
span.setTag(MEMCACHED_RESULT, hit ? HIT : MISS);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package datadog.trace.instrumentation.spymemcached;
|
||||
|
||||
import io.opentracing.Span;
|
||||
import datadog.trace.instrumentation.api.AgentSpan;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import net.spy.memcached.MemcachedConnection;
|
||||
import net.spy.memcached.internal.GetFuture;
|
||||
|
@ -17,7 +17,7 @@ public class GetCompletionListener extends CompletionListener<GetFuture<?>>
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void processResult(final Span span, final GetFuture<?> future)
|
||||
protected void processResult(final AgentSpan span, final GetFuture<?> future)
|
||||
throws ExecutionException, InterruptedException {
|
||||
final Object result = future.get();
|
||||
setResultTag(span, result != null);
|
||||
|
|
|
@ -3,7 +3,7 @@ package datadog.trace.instrumentation.spymemcached;
|
|||
import datadog.trace.agent.decorator.DatabaseClientDecorator;
|
||||
import datadog.trace.api.DDSpanTypes;
|
||||
import datadog.trace.api.DDTags;
|
||||
import io.opentracing.Span;
|
||||
import datadog.trace.instrumentation.api.AgentSpan;
|
||||
import net.spy.memcached.MemcachedConnection;
|
||||
|
||||
public class MemcacheClientDecorator extends DatabaseClientDecorator<MemcachedConnection> {
|
||||
|
@ -44,7 +44,7 @@ public class MemcacheClientDecorator extends DatabaseClientDecorator<MemcachedCo
|
|||
return null;
|
||||
}
|
||||
|
||||
public Span onOperation(final Span span, final String methodName) {
|
||||
public AgentSpan onOperation(final AgentSpan span, final String methodName) {
|
||||
|
||||
final char[] chars =
|
||||
methodName
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package datadog.trace.instrumentation.spymemcached;
|
||||
|
||||
import io.opentracing.Span;
|
||||
import datadog.trace.instrumentation.api.AgentSpan;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import net.spy.memcached.MemcachedConnection;
|
||||
import net.spy.memcached.internal.OperationFuture;
|
||||
|
@ -19,7 +19,7 @@ public class OperationCompletionListener
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void processResult(final Span span, final OperationFuture<? extends Object> future)
|
||||
protected void processResult(final AgentSpan span, final OperationFuture<? extends Object> future)
|
||||
throws ExecutionException, InterruptedException {
|
||||
future.get();
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package datadog.trace.instrumentation.spymemcached;
|
||||
|
||||
import io.opentracing.Span;
|
||||
import datadog.trace.instrumentation.api.AgentSpan;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.spy.memcached.MemcachedConnection;
|
||||
|
@ -12,7 +12,7 @@ public class SyncCompletionListener extends CompletionListener<Void> {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void processResult(final Span span, final Void future)
|
||||
protected void processResult(final AgentSpan span, final Void future)
|
||||
throws ExecutionException, InterruptedException {
|
||||
log.error("processResult was called on SyncCompletionListener. This should never happen. ");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue