*/
-public interface Scope extends AutoCloseable {
+public interface Scope extends AutoCloseable, co.elastic.apm.plugin.spi.Scope {
@Override
void close();
diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/Tracer.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/Tracer.java
index 904f26c8a88..dfaa47943c4 100644
--- a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/Tracer.java
+++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/Tracer.java
@@ -28,11 +28,10 @@
import co.elastic.apm.agent.impl.transaction.TextHeaderGetter;
import co.elastic.apm.agent.impl.transaction.Transaction;
import co.elastic.apm.agent.objectpool.ObjectPoolFactory;
-import org.stagemonitor.configuration.ConfigurationOptionProvider;
import javax.annotation.Nullable;
-public interface Tracer {
+public interface Tracer extends co.elastic.apm.plugin.spi.Tracer {
/**
* Starts a trace-root transaction
@@ -191,10 +190,12 @@ Transaction startChildTransaction(@Nullable C headerCarrier, BinaryHeaderGet
void endError(ErrorCapture errorCapture);
- T getConfig(Class configuration);
+ T getConfig(Class configuration);
ObjectPoolFactory getObjectPoolFactory();
+ ServiceInfo autoDetectedServiceName();
+
/**
* An enumeration used to represent the current tracer state.
*/
diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/context/AbstractContext.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/context/AbstractContext.java
index 67d46c115b4..30595686e12 100644
--- a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/context/AbstractContext.java
+++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/context/AbstractContext.java
@@ -25,7 +25,7 @@
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
-public abstract class AbstractContext implements Recyclable {
+public abstract class AbstractContext implements Recyclable, co.elastic.apm.plugin.spi.AbstractContext {
public static final String REDACTED_CONTEXT_STRING = "[REDACTED]";
diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/context/CloudOrigin.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/context/CloudOrigin.java
index 92f474566ac..cfb4024c6ad 100644
--- a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/context/CloudOrigin.java
+++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/context/CloudOrigin.java
@@ -28,7 +28,7 @@
* If a request originated from a cloud component that provides information about the cloud origin,
* the cloud origin interface can be used to collect this information.
*/
-public class CloudOrigin implements Recyclable {
+public class CloudOrigin implements Recyclable, co.elastic.apm.plugin.spi.CloudOrigin {
@Nullable
protected String accountId;
diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/context/Db.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/context/Db.java
index 897312cd533..edc6ba1a53f 100644
--- a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/context/Db.java
+++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/context/Db.java
@@ -34,7 +34,7 @@
/**
* An object containing contextual data for database spans
*/
-public class Db implements Recyclable {
+public class Db implements Recyclable, co.elastic.apm.plugin.spi.Db {
private static final ObjectPool charBufferPool = QueueBasedObjectPool.of(new MpmcAtomicArrayQueue(128), false,
new Allocator() {
diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/context/Destination.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/context/Destination.java
index 1d7faa7e85f..ea8d38001f9 100644
--- a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/context/Destination.java
+++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/context/Destination.java
@@ -28,7 +28,7 @@
/**
* Context information about a destination of outgoing calls.
*/
-public class Destination implements Recyclable {
+public class Destination implements Recyclable, co.elastic.apm.plugin.spi.Destination {
/**
* An IP (v4 or v6) or a host/domain name.
@@ -184,7 +184,7 @@ public Destination withInetAddress(InetAddress inetAddress) {
return this;
}
- public static class Cloud implements Recyclable {
+ public static class Cloud implements Recyclable, co.elastic.apm.plugin.spi.Cloud {
private final StringBuilder region = new StringBuilder();
public Cloud withRegion(@Nullable String region) {
diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/context/Http.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/context/Http.java
index 1262dccedeb..cca4950e794 100644
--- a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/context/Http.java
+++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/context/Http.java
@@ -22,7 +22,7 @@
import javax.annotation.Nullable;
-public class Http implements Recyclable {
+public class Http implements Recyclable, co.elastic.apm.plugin.spi.Http {
/**
* URL used by this HTTP outgoing span
diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/context/Message.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/context/Message.java
index 9a1c79fc62b..f459b89d367 100644
--- a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/context/Message.java
+++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/context/Message.java
@@ -29,7 +29,7 @@
import static co.elastic.apm.agent.impl.context.AbstractContext.REDACTED_CONTEXT_STRING;
-public class Message implements Recyclable {
+public class Message implements Recyclable, co.elastic.apm.plugin.spi.Message {
private static final ObjectPool stringBuilderPool = QueueBasedObjectPool.of(new MpmcAtomicArrayQueue(128), false,
new Allocator() {
diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/context/Request.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/context/Request.java
index 1a85d88d2f9..9628ed9c8b9 100644
--- a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/context/Request.java
+++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/context/Request.java
@@ -40,7 +40,7 @@
*
* If a log record was generated as a result of a http request, the http interface can be used to collect this information.
*/
-public class Request implements Recyclable {
+public class Request implements Recyclable, co.elastic.apm.plugin.spi.Request {
private static final ObjectPool charBufferPool = QueueBasedObjectPool.of(new MpmcAtomicArrayQueue(128), false,
diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/context/Response.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/context/Response.java
index b4f8345f137..459747845ff 100644
--- a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/context/Response.java
+++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/context/Response.java
@@ -24,7 +24,7 @@
import javax.annotation.Nullable;
import java.util.Collection;
-public class Response implements Recyclable {
+public class Response implements Recyclable, co.elastic.apm.plugin.spi.Response {
/**
* A mapping of HTTP headers of the response object
diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/context/ServiceTarget.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/context/ServiceTarget.java
index 9b239adc83b..65c405776a1 100644
--- a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/context/ServiceTarget.java
+++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/context/ServiceTarget.java
@@ -25,7 +25,7 @@
/**
* Represents a target service
*/
-public class ServiceTarget implements Recyclable {
+public class ServiceTarget implements Recyclable, co.elastic.apm.plugin.spi.ServiceTarget {
@Nullable
private String type;
diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/context/Socket.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/context/Socket.java
index c35035ab2bb..ca2507266ac 100644
--- a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/context/Socket.java
+++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/context/Socket.java
@@ -22,7 +22,7 @@
import javax.annotation.Nullable;
-public class Socket implements Recyclable {
+public class Socket implements Recyclable, co.elastic.apm.plugin.spi.Socket {
@Nullable
private String remoteAddress;
diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/context/SpanContext.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/context/SpanContext.java
index b088d3a944b..66f4e7acef3 100644
--- a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/context/SpanContext.java
+++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/context/SpanContext.java
@@ -22,7 +22,7 @@
/**
* Any other arbitrary data captured by the agent, optionally provided by the user
*/
-public class SpanContext extends AbstractContext {
+public class SpanContext extends AbstractContext implements co.elastic.apm.plugin.spi.SpanContext {
/**
* An object containing contextual data for database spans
diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/context/TransactionContext.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/context/TransactionContext.java
index edf55a51cc8..8c9ab9c7fc9 100644
--- a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/context/TransactionContext.java
+++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/context/TransactionContext.java
@@ -28,7 +28,7 @@
*
* Any arbitrary contextual information regarding the event, captured by the agent, optionally provided by the user
*/
-public class TransactionContext extends AbstractContext {
+public class TransactionContext extends AbstractContext implements co.elastic.apm.plugin.spi.TransactionContext {
/**
* A flat mapping of user-defined {@link String} keys and {@link String}, {@link Number} or {@link Boolean} values
diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/context/Url.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/context/Url.java
index 7b82da35e4a..ead8f5fa166 100644
--- a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/context/Url.java
+++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/context/Url.java
@@ -30,7 +30,7 @@
/**
* A complete URL, with scheme, host, port, path and query string.
*/
-public class Url implements Recyclable {
+public class Url implements Recyclable, co.elastic.apm.plugin.spi.Url {
/**
* The full, possibly agent-assembled URL of the request, e.g https://example.com:443/search?q=elasticsearch#top.
@@ -223,6 +223,16 @@ public void fillFrom(URI uri) {
.updateFull();
}
+ @Override
+ public void fillFrom(@Nullable String scheme, @Nullable String serverName, int serverPort, @Nullable String requestURI, @Nullable String queryString) {
+ withProtocol(scheme)
+ .withHostname(hostname)
+ .withPort(normalizePort(port, scheme))
+ .withPathname(pathname)
+ .withSearch(queryString)
+ .updateFull();
+ }
+
/**
* Fills all attributes of Url from {@link URL} instance, also updates full
*
diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/context/User.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/context/User.java
index 90bf8442213..47adc0b63a6 100644
--- a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/context/User.java
+++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/context/User.java
@@ -28,7 +28,7 @@
*
* Describes the authenticated User for a request.
*/
-public class User implements Recyclable {
+public class User implements Recyclable, co.elastic.apm.plugin.spi.User {
/**
* Domain of the logged in user
diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/error/ErrorCapture.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/error/ErrorCapture.java
index 927073d15ed..13d4dec3162 100644
--- a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/error/ErrorCapture.java
+++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/error/ErrorCapture.java
@@ -38,7 +38,7 @@
/**
* Data captured by an agent representing an event occurring in a monitored service
*/
-public class ErrorCapture implements Recyclable {
+public class ErrorCapture implements Recyclable, co.elastic.apm.plugin.spi.ErrorCapture {
private static final Logger logger = LoggerFactory.getLogger(ErrorCapture.class);
diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/AbstractHeaderGetter.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/AbstractHeaderGetter.java
index f48e06135a8..01ef195115d 100644
--- a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/AbstractHeaderGetter.java
+++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/AbstractHeaderGetter.java
@@ -18,9 +18,9 @@
*/
package co.elastic.apm.agent.impl.transaction;
-public abstract class AbstractHeaderGetter implements HeaderGetter {
+public abstract class AbstractHeaderGetter extends co.elastic.apm.plugin.spi.AbstractHeaderGetter implements HeaderGetter {
@Override
- public void forEach(String headerName, C carrier, S state, HeaderConsumer consumer) {
+ public void forEach(String headerName, C carrier, S state, HeaderGetter.HeaderConsumer consumer) {
T firstHeader = getFirstHeader(headerName, carrier);
if (firstHeader != null) {
consumer.accept(firstHeader, state);
diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/AbstractSpan.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/AbstractSpan.java
index 1be9e7c70d3..5e445458c81 100644
--- a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/AbstractSpan.java
+++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/AbstractSpan.java
@@ -29,6 +29,7 @@
import co.elastic.apm.agent.sdk.logging.Logger;
import co.elastic.apm.agent.sdk.logging.LoggerFactory;
import co.elastic.apm.agent.util.LoggerUtils;
+import co.elastic.apm.plugin.spi.HeaderChildContextCreator;
import javax.annotation.Nullable;
import java.util.HashMap;
@@ -38,7 +39,7 @@
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
-public abstract class AbstractSpan> implements Recyclable, ElasticContext {
+public abstract class AbstractSpan> implements Recyclable, ElasticContext, co.elastic.apm.plugin.spi.AbstractSpan {
public static final int PRIO_USER_SUPPLIED = 1000;
public static final int PRIO_HIGH_LEVEL_FRAMEWORK = 100;
public static final int PRIO_METHOD_SIGNATURE = 100;
@@ -139,7 +140,7 @@ public int getReferenceCount() {
*/
public T requestDiscarding() {
this.discardRequested = true;
- return (T) this;
+ return thiz();
}
/**
@@ -521,7 +522,7 @@ public Span createExitSpan() {
public T asExit() {
isExit = true;
- return (T) this;
+ return thiz();
}
public boolean isExit() {
@@ -541,7 +542,7 @@ public T captureException(@Nullable Throwable t) {
if (t != null) {
captureExceptionAndGetErrorId(getTraceContext().getClock().getEpochMicros(), t);
}
- return (T) this;
+ return thiz();
}
public void endExceptionally(@Nullable Throwable t) {
@@ -650,13 +651,13 @@ private boolean hasChildId(Id spanId) {
@Override
public T activate() {
tracer.activate(this);
- return (T) this;
+ return thiz();
}
@Override
public T deactivate() {
tracer.deactivate(this);
- return (T) this;
+ return thiz();
}
@Override
@@ -854,4 +855,62 @@ private String normalizeType(@Nullable String type) {
return type;
}
+ @Override
+ public boolean addSpanLink(HeaderChildContextCreator childContextCreator, final co.elastic.apm.plugin.spi.HeaderGetter headerGetter, @Nullable C carrier) {
+ return addSpanLink(childContextCreator, new HeaderGetter() {
+ @Nullable
+ @Override
+ public H getFirstHeader(String headerName, C carrier) {
+ return headerGetter.getFirstHeader(headerName, carrier);
+ }
+
+ @Override
+ public void forEach(String headerName, C carrier, S state, HeaderConsumer consumer) {
+ headerGetter.forEach(headerName, carrier, state, consumer);
+ }
+
+ @Override
+ public void forEach(String headerName, C carrier, S state, co.elastic.apm.plugin.spi.HeaderGetter.HeaderConsumer consumer) {
+ headerGetter.forEach(headerName, carrier, state, consumer);
+ }
+ }, carrier);
+ }
+
+ @Override
+ public boolean propagateTraceContext(C carrier, final co.elastic.apm.plugin.spi.BinaryHeaderSetter headerSetter) {
+ return propagateTraceContext(carrier, new BinaryHeaderSetter() {
+ @Nullable
+ @Override
+ public byte[] getFixedLengthByteArray(String headerName, int length) {
+ return headerSetter.getFixedLengthByteArray(headerName, length);
+ }
+
+ @Override
+ public void setHeader(String headerName, byte[] headerValue, C carrier) {
+ headerSetter.setHeader(headerName, headerValue, carrier);
+ }
+ });
+ }
+
+ @Override
+ public void propagateTraceContext(C carrier, final co.elastic.apm.plugin.spi.TextHeaderSetter headerSetter) {
+ propagateTraceContext(carrier, new TextHeaderSetter() {
+ @Override
+ public void setHeader(String headerName, String headerValue, C carrier) {
+ headerSetter.setHeader(headerName, headerValue, carrier);
+ }
+ });
+ }
+
+ @Override
+ public T withOutcome(co.elastic.apm.plugin.spi.Outcome outcome) {
+ String name = outcome.name();
+ if (name.equals(Outcome.FAILURE.name())) {
+ return withOutcome(Outcome.FAILURE);
+ } else if (name.equals(Outcome.SUCCESS.name())) {
+ return withOutcome(Outcome.SUCCESS);
+ } else {
+ return withOutcome(Outcome.UNKNOWN);
+ }
+ }
}
diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/BinaryHeaderGetter.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/BinaryHeaderGetter.java
index 7f348044edf..38c01128d9a 100644
--- a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/BinaryHeaderGetter.java
+++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/BinaryHeaderGetter.java
@@ -18,5 +18,5 @@
*/
package co.elastic.apm.agent.impl.transaction;
-public interface BinaryHeaderGetter extends HeaderGetter {
+public interface BinaryHeaderGetter extends HeaderGetter, co.elastic.apm.plugin.spi.BinaryHeaderGetter {
}
diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/BinaryHeaderGetterBridge.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/BinaryHeaderGetterBridge.java
new file mode 100644
index 00000000000..8816f0e9e4d
--- /dev/null
+++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/BinaryHeaderGetterBridge.java
@@ -0,0 +1,30 @@
+package co.elastic.apm.agent.impl.transaction;
+
+import co.elastic.apm.plugin.spi.HeaderGetter;
+
+import javax.annotation.Nullable;
+
+public class BinaryHeaderGetterBridge implements BinaryHeaderGetter {
+
+ private final co.elastic.apm.plugin.spi.BinaryHeaderGetter binaryHeaderGetter;
+
+ public BinaryHeaderGetterBridge(co.elastic.apm.plugin.spi.BinaryHeaderGetter binaryHeaderGetter) {
+ this.binaryHeaderGetter = binaryHeaderGetter;
+ }
+
+ @Nullable
+ @Override
+ public byte[] getFirstHeader(String headerName, C carrier) {
+ return binaryHeaderGetter.getFirstHeader(headerName, carrier);
+ }
+
+ @Override
+ public void forEach(String headerName, C carrier, S state, co.elastic.apm.agent.impl.transaction.HeaderGetter.HeaderConsumer consumer) {
+ binaryHeaderGetter.forEach(headerName, carrier, state, consumer);
+ }
+
+ @Override
+ public void forEach(String headerName, C carrier, S state, HeaderGetter.HeaderConsumer consumer) {
+ binaryHeaderGetter.forEach(headerName, carrier, state, consumer);
+ }
+}
diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/BinaryHeaderSetter.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/BinaryHeaderSetter.java
index 8efccc96a42..4dcbed9a767 100644
--- a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/BinaryHeaderSetter.java
+++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/BinaryHeaderSetter.java
@@ -20,7 +20,7 @@
import javax.annotation.Nullable;
-public interface BinaryHeaderSetter extends HeaderSetter {
+public interface BinaryHeaderSetter extends HeaderSetter, co.elastic.apm.plugin.spi.BinaryHeaderSetter {
/**
* Since the implementation itself knows the intrinsics of the headers and carrier lifecycle and handling, it should
diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/ElasticContext.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/ElasticContext.java
index 6b9ccf4b2e1..155a149b2db 100644
--- a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/ElasticContext.java
+++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/ElasticContext.java
@@ -22,7 +22,7 @@
import javax.annotation.Nullable;
-public interface ElasticContext> {
+public interface ElasticContext> extends co.elastic.apm.plugin.spi.ElasticContext {
/**
* Makes the context active
diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/Faas.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/Faas.java
index 4068f3604dd..c436c4ea860 100644
--- a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/Faas.java
+++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/Faas.java
@@ -22,7 +22,7 @@
import javax.annotation.Nullable;
-public class Faas implements Recyclable {
+public class Faas implements Recyclable, co.elastic.apm.plugin.spi.Faas {
@Nullable
private String execution;
diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/HeaderConsumerBridge.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/HeaderConsumerBridge.java
new file mode 100644
index 00000000000..012de108567
--- /dev/null
+++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/HeaderConsumerBridge.java
@@ -0,0 +1,17 @@
+package co.elastic.apm.agent.impl.transaction;
+
+import javax.annotation.Nullable;
+
+public class HeaderConsumerBridge implements HeaderGetter.HeaderConsumer {
+
+ private final co.elastic.apm.plugin.spi.HeaderGetter.HeaderConsumer headerConsumer;
+
+ public HeaderConsumerBridge(co.elastic.apm.plugin.spi.HeaderGetter.HeaderConsumer headerConsumer) {
+ this.headerConsumer = headerConsumer;
+ }
+
+ @Override
+ public void accept(@Nullable T headerValue, C state) {
+ headerConsumer.accept(headerValue, state);
+ }
+}
diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/HeaderGetter.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/HeaderGetter.java
index c973af101b6..708079974d5 100644
--- a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/HeaderGetter.java
+++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/HeaderGetter.java
@@ -20,7 +20,7 @@
import javax.annotation.Nullable;
-public interface HeaderGetter {
+public interface HeaderGetter extends co.elastic.apm.plugin.spi.HeaderGetter {
@Nullable
T getFirstHeader(String headerName, C carrier);
@@ -41,7 +41,7 @@ public interface HeaderGetter {
*/
void forEach(String headerName, C carrier, S state, HeaderConsumer consumer);
- interface HeaderConsumer {
+ interface HeaderConsumer extends co.elastic.apm.plugin.spi.HeaderGetter.HeaderConsumer {
void accept(@Nullable T headerValue, S state);
}
}
diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/HeaderGetterBridge.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/HeaderGetterBridge.java
new file mode 100644
index 00000000000..78cab4611da
--- /dev/null
+++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/HeaderGetterBridge.java
@@ -0,0 +1,28 @@
+package co.elastic.apm.agent.impl.transaction;
+
+import javax.annotation.Nullable;
+
+public class HeaderGetterBridge implements HeaderGetter {
+
+ private final co.elastic.apm.plugin.spi.HeaderGetter headerGetter;
+
+ public HeaderGetterBridge(co.elastic.apm.plugin.spi.HeaderGetter headerGetter) {
+ this.headerGetter = headerGetter;
+ }
+
+ @Nullable
+ @Override
+ public T getFirstHeader(String headerName, C carrier) {
+ return headerGetter.getFirstHeader(headerName, carrier);
+ }
+
+ @Override
+ public void forEach(String headerName, C carrier, S state, HeaderConsumer consumer) {
+ headerGetter.forEach(headerName, carrier, state, consumer);
+ }
+
+ @Override
+ public void forEach(String headerName, C carrier, S state, co.elastic.apm.plugin.spi.HeaderGetter.HeaderConsumer consumer) {
+ headerGetter.forEach(headerName, carrier, state, new HeaderConsumerBridge<>(consumer));
+ }
+}
diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/HeaderRemover.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/HeaderRemover.java
index e0f3a2251f9..265f102970a 100644
--- a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/HeaderRemover.java
+++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/HeaderRemover.java
@@ -18,7 +18,7 @@
*/
package co.elastic.apm.agent.impl.transaction;
-public interface HeaderRemover {
+public interface HeaderRemover extends co.elastic.apm.plugin.spi.HeaderRemover {
void remove(String headerName, C carrier);
}
diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/HeaderSetter.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/HeaderSetter.java
index be369d3cf0e..7940e03588a 100644
--- a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/HeaderSetter.java
+++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/HeaderSetter.java
@@ -18,7 +18,7 @@
*/
package co.elastic.apm.agent.impl.transaction;
-public interface HeaderSetter {
+public interface HeaderSetter extends co.elastic.apm.plugin.spi.HeaderSetter {
void setHeader(String headerName, T headerValue, C carrier);
}
diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/Id.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/Id.java
index 166f5979047..8c25277d7c2 100644
--- a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/Id.java
+++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/Id.java
@@ -31,7 +31,7 @@
/**
* A 128 bit globally unique ID of the whole trace forest
*/
-public class Id implements Recyclable {
+public class Id implements Recyclable, co.elastic.apm.plugin.spi.Id {
private final byte[] data;
private boolean empty = true;
diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/MultiValueMapAccessor.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/MultiValueMapAccessor.java
index dd902706640..10bf22372c9 100644
--- a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/MultiValueMapAccessor.java
+++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/MultiValueMapAccessor.java
@@ -37,7 +37,7 @@ public String getFirstHeader(String headerName, PotentiallyMultiValuedMap header
}
@Override
- public void forEach(String headerName, PotentiallyMultiValuedMap headerMap, S state, HeaderConsumer consumer) {
+ public void forEach(String headerName, PotentiallyMultiValuedMap headerMap, S state, HeaderGetter.HeaderConsumer consumer) {
for (String headerValue : headerMap.getAll(headerName)) {
consumer.accept(headerValue, state);
}
diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/Outcome.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/Outcome.java
index c530d46a714..bfdd846032b 100644
--- a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/Outcome.java
+++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/Outcome.java
@@ -18,7 +18,7 @@
*/
package co.elastic.apm.agent.impl.transaction;
-public enum Outcome {
+public enum Outcome implements co.elastic.apm.plugin.spi.Outcome {
SUCCESS("success"),
FAILURE("failure"),
UNKNOWN("unknown");
diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/Span.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/Span.java
index a5e1740dbac..92792a47bbb 100644
--- a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/Span.java
+++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/Span.java
@@ -36,7 +36,7 @@
import java.util.Objects;
import java.util.concurrent.TimeUnit;
-public class Span extends AbstractSpan implements Recyclable {
+public class Span extends AbstractSpan implements Recyclable, co.elastic.apm.plugin.spi.Span {
private static final Logger logger = LoggerFactory.getLogger(Span.class);
public static final long MAX_LOG_INTERVAL_MICRO_SECS = TimeUnit.MINUTES.toMicros(5);
diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/TextHeaderGetter.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/TextHeaderGetter.java
index 88ca8ee8395..0cb46fc82db 100644
--- a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/TextHeaderGetter.java
+++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/TextHeaderGetter.java
@@ -18,5 +18,5 @@
*/
package co.elastic.apm.agent.impl.transaction;
-public interface TextHeaderGetter extends HeaderGetter {
+public interface TextHeaderGetter extends HeaderGetter, co.elastic.apm.plugin.spi.TextHeaderGetter {
}
diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/TextHeaderGetterBridge.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/TextHeaderGetterBridge.java
new file mode 100644
index 00000000000..c1a5828b115
--- /dev/null
+++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/TextHeaderGetterBridge.java
@@ -0,0 +1,28 @@
+package co.elastic.apm.agent.impl.transaction;
+
+import javax.annotation.Nullable;
+
+public class TextHeaderGetterBridge implements TextHeaderGetter {
+
+ private final co.elastic.apm.plugin.spi.TextHeaderGetter textHeadersGetter;
+
+ public TextHeaderGetterBridge(co.elastic.apm.plugin.spi.TextHeaderGetter textHeadersGetter) {
+ this.textHeadersGetter = textHeadersGetter;
+ }
+
+ @Nullable
+ @Override
+ public String getFirstHeader(String headerName, C carrier) {
+ return textHeadersGetter.getFirstHeader(headerName, carrier);
+ }
+
+ @Override
+ public void forEach(String headerName, C carrier, S state, HeaderGetter.HeaderConsumer consumer) {
+ textHeadersGetter.forEach(headerName, carrier, state, consumer);
+ }
+
+ @Override
+ public void forEach(String headerName, C carrier, S state, co.elastic.apm.plugin.spi.HeaderGetter.HeaderConsumer consumer) {
+ textHeadersGetter.forEach(headerName, carrier, state, consumer);
+ }
+}
diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/TextHeaderSetter.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/TextHeaderSetter.java
index 051165e44ad..5f589d53be9 100644
--- a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/TextHeaderSetter.java
+++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/TextHeaderSetter.java
@@ -18,5 +18,5 @@
*/
package co.elastic.apm.agent.impl.transaction;
-public interface TextHeaderSetter extends HeaderSetter {
+public interface TextHeaderSetter extends HeaderSetter, co.elastic.apm.plugin.spi.TextHeaderSetter {
}
diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/TraceContext.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/TraceContext.java
index 75e474fe9c7..bb7518afbf4 100644
--- a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/TraceContext.java
+++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/TraceContext.java
@@ -20,7 +20,6 @@
import co.elastic.apm.agent.configuration.CoreConfiguration;
import co.elastic.apm.agent.impl.ElasticApmTracer;
-import co.elastic.apm.agent.impl.GlobalTracer;
import co.elastic.apm.agent.impl.Tracer;
import co.elastic.apm.agent.impl.sampling.Sampler;
import co.elastic.apm.agent.objectpool.Recyclable;
@@ -67,7 +66,7 @@
* 2, 1]
*
*/
-public class TraceContext implements Recyclable {
+public class TraceContext implements Recyclable, co.elastic.apm.plugin.spi.TraceContext {
public static final String ELASTIC_TRACE_PARENT_TEXTUAL_HEADER_NAME = "elastic-apm-traceparent";
public static final String W3C_TRACE_PARENT_TEXTUAL_HEADER_NAME = "traceparent";
@@ -94,20 +93,20 @@ public class TraceContext implements Recyclable {
private static final Double SAMPLE_RATE_ZERO = 0d;
- private static final ChildContextCreator FROM_PARENT_CONTEXT = new ChildContextCreator() {
+ private static final ChildContextCreator FROM_PARENT_CONTEXT = new ChildContextCreatorBridge(new co.elastic.apm.plugin.spi.ChildContextCreator() {
@Override
- public boolean asChildOf(TraceContext child, TraceContext parent) {
+ public boolean asChildOf(co.elastic.apm.plugin.spi.TraceContext child, TraceContext parent) {
child.asChildOf(parent);
return true;
}
- };
- private static final ChildContextCreator> FROM_PARENT = new ChildContextCreator>() {
+ });
+ private static final ChildContextCreator> FROM_PARENT = new ChildContextCreatorBridge>(new co.elastic.apm.plugin.spi.ChildContextCreator>() {
@Override
- public boolean asChildOf(TraceContext child, AbstractSpan> parent) {
+ public boolean asChildOf(co.elastic.apm.plugin.spi.TraceContext child, AbstractSpan> parent) {
child.asChildOf(parent.getTraceContext());
return true;
}
- };
+ });
private static final HeaderGetter.HeaderConsumer TRACESTATE_HEADER_CONSUMER = new HeaderGetter.HeaderConsumer() {
@Override
public void accept(@Nullable String tracestateHeaderValue, TraceContext state) {
@@ -117,9 +116,9 @@ public void accept(@Nullable String tracestateHeaderValue, TraceContext state) {
}
};
private static final HeaderChildContextCreator FROM_TRACE_CONTEXT_TEXT_HEADERS =
- new HeaderChildContextCreator() {
+ new HeaderChildContextCreatorBridge(new co.elastic.apm.plugin.spi.HeaderChildContextCreator() {
@Override
- public boolean asChildOf(TraceContext child, @Nullable Object carrier, HeaderGetter traceContextHeaderGetter) {
+ public boolean asChildOf(co.elastic.apm.plugin.spi.TraceContext child, @Nullable Object carrier, co.elastic.apm.plugin.spi.HeaderGetter traceContextHeaderGetter) {
if (carrier == null) {
return false;
}
@@ -127,25 +126,25 @@ public boolean asChildOf(TraceContext child, @Nullable Object carrier, HeaderGet
boolean isValid = false;
String traceparent = traceContextHeaderGetter.getFirstHeader(W3C_TRACE_PARENT_TEXTUAL_HEADER_NAME, carrier);
if (traceparent != null) {
- isValid = child.asChildOf(traceparent);
+ isValid = ((TraceContext) child).asChildOf(traceparent);
}
if (!isValid) {
// Look for the legacy Elastic traceparent header (in case this comes from an older agent)
traceparent = traceContextHeaderGetter.getFirstHeader(ELASTIC_TRACE_PARENT_TEXTUAL_HEADER_NAME, carrier);
if (traceparent != null) {
- isValid = child.asChildOf(traceparent);
+ isValid = ((TraceContext) child).asChildOf(traceparent);
}
}
if (isValid) {
// as per spec, the tracestate header can be multi-valued
- traceContextHeaderGetter.forEach(TRACESTATE_HEADER_NAME, carrier, child, TRACESTATE_HEADER_CONSUMER);
+ traceContextHeaderGetter.forEach(TRACESTATE_HEADER_NAME, carrier, ((TraceContext) child), TRACESTATE_HEADER_CONSUMER);
}
return isValid;
}
- };
+ });
private static final HeaderChildContextCreator FROM_TRACE_CONTEXT_BINARY_HEADERS =
new HeaderChildContextCreator() {
@Override
@@ -159,10 +158,15 @@ public boolean asChildOf(TraceContext child, @Nullable Object carrier, HeaderGet
}
return false;
}
+
+ @Override
+ public boolean asChildOf(co.elastic.apm.plugin.spi.TraceContext child, @Nullable Object carrier, co.elastic.apm.plugin.spi.HeaderGetter headerGetter) {
+ return asChildOf((TraceContext) child, carrier, new HeaderGetterBridge(headerGetter));
+ }
};
- private static final ChildContextCreator FROM_ACTIVE = new ChildContextCreator() {
+ private static final ChildContextCreator FROM_ACTIVE = new ChildContextCreatorBridge(new co.elastic.apm.plugin.spi.ChildContextCreator() {
@Override
- public boolean asChildOf(TraceContext child, Tracer tracer) {
+ public boolean asChildOf(co.elastic.apm.plugin.spi.TraceContext child, Tracer tracer) {
final AbstractSpan> active = tracer.getActive();
if (active != null) {
return fromParent().asChildOf(child, active);
@@ -170,14 +174,13 @@ public boolean asChildOf(TraceContext child, Tracer tracer) {
}
return false;
}
- };
- private static final ChildContextCreator
*/
-public class PotentiallyMultiValuedMap implements Recyclable {
+public class PotentiallyMultiValuedMap implements Recyclable, co.elastic.apm.plugin.spi.PotentiallyMultiValuedMap {
private final List keys;
private final List values;
diff --git a/apm-agent-core/src/test/java/co/elastic/apm/agent/impl/BinaryHeaderMapAccessor.java b/apm-agent-core/src/test/java/co/elastic/apm/agent/impl/BinaryHeaderMapAccessor.java
index 1c1c0a8d1f9..01089474f7b 100644
--- a/apm-agent-core/src/test/java/co/elastic/apm/agent/impl/BinaryHeaderMapAccessor.java
+++ b/apm-agent-core/src/test/java/co/elastic/apm/agent/impl/BinaryHeaderMapAccessor.java
@@ -22,6 +22,7 @@
import co.elastic.apm.agent.impl.transaction.BinaryHeaderSetter;
import co.elastic.apm.agent.impl.transaction.HeaderRemover;
import co.elastic.apm.agent.impl.transaction.TraceContext;
+import co.elastic.apm.plugin.spi.HeaderGetter;
import javax.annotation.Nullable;
import java.util.HashMap;
@@ -44,7 +45,15 @@ public byte[] getFirstHeader(String headerName, Map headerMap) {
}
@Override
- public void forEach(String headerName, Map carrier, S state, HeaderConsumer consumer) {
+ public void forEach(String headerName, Map carrier, S state, co.elastic.apm.agent.impl.transaction.HeaderGetter.HeaderConsumer consumer) {
+ byte[] headerValue = carrier.get(headerName);
+ if (headerValue != null) {
+ consumer.accept(headerValue, state);
+ }
+ }
+
+ @Override
+ public void forEach(String headerName, Map carrier, S state, HeaderGetter.HeaderConsumer consumer) {
byte[] headerValue = carrier.get(headerName);
if (headerValue != null) {
consumer.accept(headerValue, state);
diff --git a/apm-agent-core/src/test/java/co/elastic/apm/agent/impl/transaction/AbstractTextHeaderGetterTest.java b/apm-agent-core/src/test/java/co/elastic/apm/agent/impl/transaction/AbstractTextHeaderGetterTest.java
index f1e5bd8ef2b..d77a8d59585 100644
--- a/apm-agent-core/src/test/java/co/elastic/apm/agent/impl/transaction/AbstractTextHeaderGetterTest.java
+++ b/apm-agent-core/src/test/java/co/elastic/apm/agent/impl/transaction/AbstractTextHeaderGetterTest.java
@@ -18,6 +18,7 @@
*/
package co.elastic.apm.agent.impl.transaction;
+import co.elastic.apm.plugin.spi.TextHeaderGetter;
import org.junit.jupiter.api.Test;
import java.util.ArrayList;
diff --git a/apm-agent-plugin-spi/pom.xml b/apm-agent-plugin-spi/pom.xml
new file mode 100644
index 00000000000..112155d86c0
--- /dev/null
+++ b/apm-agent-plugin-spi/pom.xml
@@ -0,0 +1,14 @@
+
+
+ 4.0.0
+
+ co.elastic.apm
+ apm-agent-parent
+ 1.36.1-SNAPSHOT
+
+
+ apm-agent-plugin-spi
+
+
diff --git a/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/AbstractContext.java b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/AbstractContext.java
new file mode 100644
index 00000000000..8455ffc648c
--- /dev/null
+++ b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/AbstractContext.java
@@ -0,0 +1,6 @@
+package co.elastic.apm.plugin.spi;
+
+public interface AbstractContext {
+
+ Message getMessage();
+}
diff --git a/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/AbstractHeaderGetter.java b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/AbstractHeaderGetter.java
new file mode 100644
index 00000000000..fbe3e504940
--- /dev/null
+++ b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/AbstractHeaderGetter.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package co.elastic.apm.plugin.spi;
+
+public abstract class AbstractHeaderGetter implements HeaderGetter {
+ @Override
+ public void forEach(String headerName, C carrier, S state, HeaderConsumer consumer) {
+ T firstHeader = getFirstHeader(headerName, carrier);
+ if (firstHeader != null) {
+ consumer.accept(firstHeader, state);
+ }
+ }
+}
diff --git a/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/AbstractSpan.java b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/AbstractSpan.java
new file mode 100644
index 00000000000..4231446ce6d
--- /dev/null
+++ b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/AbstractSpan.java
@@ -0,0 +1,92 @@
+package co.elastic.apm.plugin.spi;
+
+import javax.annotation.Nullable;
+
+public interface AbstractSpan> extends ElasticContext {
+
+ int PRIO_USER_SUPPLIED = 1000;
+ int PRIO_HIGH_LEVEL_FRAMEWORK = 100;
+ int PRIO_METHOD_SIGNATURE = 100;
+ int PRIO_LOW_LEVEL_FRAMEWORK = 10;
+ int PRIO_DEFAULT = 0;
+ int MAX_ALLOWED_SPAN_LINKS = 1000;
+
+ AbstractContext getContext();
+
+ boolean isDiscarded();
+
+ boolean isReferenced();
+
+ boolean isFinished();
+
+ boolean isSampled();
+
+ @Nullable
+ String getType();
+
+ @Nullable
+ StringBuilder getAndOverrideName(int namePriority);
+
+ @Nullable
+ StringBuilder getAndOverrideName(int namePriority, boolean overrideIfSamePriority);
+
+ void updateName(Class> clazz, String methodName);
+
+ void setNonDiscardable();
+
+ T requestDiscarding();
+
+ T appendToName(CharSequence cs);
+
+ T appendToName(CharSequence cs, int priority);
+
+ T appendToName(CharSequence cs, int priority, int startIndex, int endIndex);
+
+ T withName(@Nullable String name);
+
+ T withName(@Nullable String name, int priority);
+
+ T withName(@Nullable String name, int priority, boolean overrideIfSamePriority);
+
+ T withType(@Nullable String type);
+
+ T withSync(boolean sync);
+
+ TraceContext getTraceContext();
+
+ boolean addSpanLink(
+ HeaderChildContextCreator childContextCreator,
+ HeaderGetter headerGetter,
+ @Nullable C carrier
+ );
+
+ Span> createSpan();
+
+ Span> createSpan(long epochMicros);
+
+ T asExit();
+
+ T captureException(@Nullable Throwable t);
+
+ void endExceptionally(@Nullable Throwable t);
+
+ void end();
+
+ void end(long epochMicros);
+
+ boolean propagateTraceContext(C carrier, BinaryHeaderSetter headerSetter);
+
+ void propagateTraceContext(C carrier, TextHeaderSetter headerSetter);
+
+ Outcome getOutcome();
+
+ T withOutcome(Outcome outcome);
+
+ Span> createExitSpan();
+
+ void incrementReferences();
+
+ void decrementReferences();
+
+ int getReferenceCount();
+}
diff --git a/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/Allocator.java b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/Allocator.java
new file mode 100644
index 00000000000..0b71cf27be0
--- /dev/null
+++ b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/Allocator.java
@@ -0,0 +1,6 @@
+package co.elastic.apm.plugin.spi;
+
+public interface Allocator {
+
+ T createInstance();
+}
diff --git a/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/BinaryHeaderGetter.java b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/BinaryHeaderGetter.java
new file mode 100644
index 00000000000..97e40f827b8
--- /dev/null
+++ b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/BinaryHeaderGetter.java
@@ -0,0 +1,4 @@
+package co.elastic.apm.plugin.spi;
+
+public interface BinaryHeaderGetter extends HeaderGetter {
+}
diff --git a/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/BinaryHeaderSetter.java b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/BinaryHeaderSetter.java
new file mode 100644
index 00000000000..5726da122e7
--- /dev/null
+++ b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/BinaryHeaderSetter.java
@@ -0,0 +1,9 @@
+package co.elastic.apm.plugin.spi;
+
+import javax.annotation.Nullable;
+
+public interface BinaryHeaderSetter extends HeaderSetter {
+
+ @Nullable
+ byte[] getFixedLengthByteArray(String headerName, int length);
+}
diff --git a/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/ChildContextCreator.java b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/ChildContextCreator.java
new file mode 100644
index 00000000000..74a533927ff
--- /dev/null
+++ b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/ChildContextCreator.java
@@ -0,0 +1,5 @@
+package co.elastic.apm.plugin.spi;
+
+public interface ChildContextCreator {
+ boolean asChildOf(TraceContext child, T parent);
+}
diff --git a/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/Cloud.java b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/Cloud.java
new file mode 100644
index 00000000000..ab1584be409
--- /dev/null
+++ b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/Cloud.java
@@ -0,0 +1,8 @@
+package co.elastic.apm.plugin.spi;
+
+import javax.annotation.Nullable;
+
+public interface Cloud {
+
+ Cloud withRegion(@Nullable String region);
+}
diff --git a/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/CloudOrigin.java b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/CloudOrigin.java
new file mode 100644
index 00000000000..7bef6ca32ca
--- /dev/null
+++ b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/CloudOrigin.java
@@ -0,0 +1,14 @@
+package co.elastic.apm.plugin.spi;
+
+import javax.annotation.Nullable;
+
+public interface CloudOrigin {
+
+ CloudOrigin withAccountId(@Nullable String accountId);
+
+ CloudOrigin withProvider(@Nullable String provider);
+
+ CloudOrigin withRegion(@Nullable String region);
+
+ CloudOrigin withServiceName(@Nullable String serviceName);
+}
diff --git a/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/Db.java b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/Db.java
new file mode 100644
index 00000000000..fc4abe33234
--- /dev/null
+++ b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/Db.java
@@ -0,0 +1,19 @@
+package co.elastic.apm.plugin.spi;
+
+import javax.annotation.Nullable;
+import java.nio.CharBuffer;
+
+public interface Db {
+
+ Db withInstance(@Nullable String instance);
+
+ Db withType(@Nullable String type);
+
+ Db withStatement(@Nullable String statement);
+
+ Db withUser(@Nullable String user);
+
+ Db withAffectedRowsCount(long returnValue);
+
+ CharBuffer withStatementBuffer();
+}
diff --git a/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/DefaultOutcome.java b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/DefaultOutcome.java
new file mode 100644
index 00000000000..f0bc3e0de31
--- /dev/null
+++ b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/DefaultOutcome.java
@@ -0,0 +1,7 @@
+package co.elastic.apm.plugin.spi;
+
+public enum DefaultOutcome implements Outcome {
+ SUCCESS,
+ FAILURE,
+ UNKNOWN
+}
diff --git a/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/Destination.java b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/Destination.java
new file mode 100644
index 00000000000..236b4d1a8cc
--- /dev/null
+++ b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/Destination.java
@@ -0,0 +1,23 @@
+package co.elastic.apm.plugin.spi;
+
+import javax.annotation.Nullable;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.net.SocketAddress;
+
+public interface Destination {
+
+ Destination withAddress(@Nullable CharSequence address);
+
+ Destination withInetAddress(InetAddress address);
+
+ Destination withPort(int port);
+
+ Destination withAddressPort(@Nullable String addressPort);
+
+ Destination withInetSocketAddress(InetSocketAddress remoteAddress);
+
+ Destination withSocketAddress(SocketAddress socketAddress);
+
+ Cloud getCloud();
+}
diff --git a/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/ElasticContext.java b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/ElasticContext.java
new file mode 100644
index 00000000000..3fbf58958b5
--- /dev/null
+++ b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/ElasticContext.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package co.elastic.apm.plugin.spi;
+
+import javax.annotation.Nullable;
+
+public interface ElasticContext> {
+
+ T activate();
+
+ T deactivate();
+
+ Scope activateInScope();
+
+ @Nullable
+ AbstractSpan> getSpan();
+
+ @Nullable
+ Transaction> getTransaction();
+}
diff --git a/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/ErrorCapture.java b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/ErrorCapture.java
new file mode 100644
index 00000000000..409008b815b
--- /dev/null
+++ b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/ErrorCapture.java
@@ -0,0 +1,4 @@
+package co.elastic.apm.plugin.spi;
+
+public interface ErrorCapture {
+}
diff --git a/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/Faas.java b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/Faas.java
new file mode 100644
index 00000000000..f103c00b99e
--- /dev/null
+++ b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/Faas.java
@@ -0,0 +1,16 @@
+package co.elastic.apm.plugin.spi;
+
+import javax.annotation.Nullable;
+
+public interface Faas {
+
+ Faas withColdStart(boolean coldStart);
+
+ Faas withId(@Nullable String id);
+
+ Faas withName(@Nullable String name);
+
+ Faas withVersion(@Nullable String version);
+
+ Faas withExecution(@Nullable String execution);
+}
diff --git a/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/GlobalTracer.java b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/GlobalTracer.java
new file mode 100644
index 00000000000..71e598bc18e
--- /dev/null
+++ b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/GlobalTracer.java
@@ -0,0 +1,174 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package co.elastic.apm.plugin.spi;
+
+import javax.annotation.Nullable;
+import java.util.Objects;
+
+public class GlobalTracer implements Tracer {
+
+ private static final GlobalTracer INSTANCE = new GlobalTracer();
+ private volatile Tracer tracer = NoopTracer.INSTANCE;
+
+ private GlobalTracer() {
+ }
+
+ public static Tracer get() {
+ return INSTANCE;
+ }
+
+ @Nullable
+ public static T get(Class type) {
+ Tracer tracer = INSTANCE.tracer;
+ if (type.isInstance(tracer)) {
+ return type.cast(tracer);
+ }
+ return null;
+ }
+
+ public static T require(Class type) {
+ return Objects.requireNonNull(get(type), "Registered tracer is not an instance of " + type.getName());
+ }
+
+ public static synchronized void init(Tracer tracer) {
+ if (!isNoop()) {
+ throw new IllegalStateException("Tracer is already initialized");
+ }
+ INSTANCE.tracer = tracer;
+ }
+
+ public static boolean isNoop() {
+ return INSTANCE.tracer == NoopTracer.INSTANCE;
+ }
+
+ @Nullable
+ public Transaction> startRootTransaction(@Nullable ClassLoader initiatingClassLoader) {
+ return tracer.startRootTransaction(initiatingClassLoader);
+ }
+
+ @Nullable
+ @Override
+ public Transaction> startRootTransaction(@Nullable ClassLoader initiatingClassLoader, long epochMicro) {
+ return tracer.startRootTransaction(initiatingClassLoader, epochMicro);
+ }
+
+ @Nullable
+ public Transaction> startChildTransaction(@Nullable C headerCarrier, TextHeaderGetter textHeadersGetter, @Nullable ClassLoader initiatingClassLoader) {
+ return tracer.startChildTransaction(headerCarrier, textHeadersGetter, initiatingClassLoader);
+ }
+
+ @Nullable
+ @Override
+ public Transaction> startChildTransaction(@Nullable C headerCarrier, TextHeaderGetter textHeadersGetter, @Nullable ClassLoader initiatingClassLoader, long epochMicros) {
+ return tracer.startChildTransaction(headerCarrier, textHeadersGetter, initiatingClassLoader, epochMicros);
+ }
+
+ @Nullable
+ public Transaction> startChildTransaction(@Nullable C headerCarrier, BinaryHeaderGetter binaryHeadersGetter, @Nullable ClassLoader initiatingClassLoader) {
+ return tracer.startChildTransaction(headerCarrier, binaryHeadersGetter, initiatingClassLoader);
+ }
+
+ @Nullable
+ public Transaction> currentTransaction() {
+ return tracer.currentTransaction();
+ }
+
+ @Nullable
+ @Override
+ public AbstractSpan> getActive() {
+ return tracer.getActive();
+ }
+
+ @Nullable
+ @Override
+ public Span> getActiveSpan() {
+ return tracer.getActiveSpan();
+ }
+
+ public void captureAndReportException(@Nullable Throwable e, ClassLoader initiatingClassLoader) {
+ tracer.captureAndReportException(e, initiatingClassLoader);
+ }
+
+ @Nullable
+ public String captureAndReportException(long epochMicros, @Nullable Throwable e, @Nullable AbstractSpan> parent) {
+ return tracer.captureAndReportException(epochMicros, e, parent);
+ }
+
+ @Nullable
+ public ErrorCapture captureException(@Nullable Throwable e, @Nullable AbstractSpan> parent, @Nullable ClassLoader initiatingClassLoader) {
+ return tracer.captureException(e, parent, initiatingClassLoader);
+ }
+
+ @Nullable
+ @Override
+ public Span> getActiveExitSpan() {
+ return tracer.getActiveExitSpan();
+ }
+
+ @Nullable
+ @Override
+ public Span> createExitChildSpan() {
+ return tracer.createExitChildSpan();
+ }
+
+ @Override
+ public void endSpan(Span> span) {
+ tracer.endSpan(span);
+ }
+
+ @Override
+ public void endTransaction(Transaction> transaction) {
+ tracer.endTransaction(transaction);
+ }
+
+ @Override
+ public void endError(ErrorCapture errorCapture) {
+ tracer.endError(errorCapture);
+ }
+
+ @Override
+ public T getConfig(Class configuration) {
+ return tracer.getConfig(configuration);
+ }
+
+ @Override
+ public ObjectPoolFactory getObjectPoolFactory() {
+ return tracer.getObjectPoolFactory();
+ }
+
+ @Override
+ public boolean isRunning() {
+ return tracer.isRunning();
+ }
+
+ @Override
+ public void setServiceInfoForClassLoader(ClassLoader classLoader, ServiceInfo serviceInfo) {
+ tracer.setServiceInfoForClassLoader(classLoader, serviceInfo);
+ }
+
+ @Override
+ public ServiceInfo getServiceInfoForClassLoader(ClassLoader classLoader) {
+ return tracer.getServiceInfoForClassLoader(classLoader);
+ }
+
+ @Override
+ public ServiceInfo autoDetectedServiceName() {
+ return tracer.autoDetectedServiceName();
+ }
+}
diff --git a/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/HeaderChildContextCreator.java b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/HeaderChildContextCreator.java
new file mode 100644
index 00000000000..4a31ddfc52c
--- /dev/null
+++ b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/HeaderChildContextCreator.java
@@ -0,0 +1,7 @@
+package co.elastic.apm.plugin.spi;
+
+import javax.annotation.Nullable;
+
+public interface HeaderChildContextCreator {
+ boolean asChildOf(TraceContext child, @Nullable C carrier, HeaderGetter headerGetter);
+}
diff --git a/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/HeaderGetter.java b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/HeaderGetter.java
new file mode 100644
index 00000000000..04fac5c3719
--- /dev/null
+++ b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/HeaderGetter.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package co.elastic.apm.plugin.spi;
+
+import javax.annotation.Nullable;
+
+public interface HeaderGetter {
+
+ @Nullable
+ T getFirstHeader(String headerName, C carrier);
+
+ void forEach(String headerName, C carrier, S state, HeaderConsumer consumer);
+
+ interface HeaderConsumer {
+ void accept(@Nullable T headerValue, S state);
+ }
+}
diff --git a/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/HeaderRemover.java b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/HeaderRemover.java
new file mode 100644
index 00000000000..8c302d5f129
--- /dev/null
+++ b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/HeaderRemover.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package co.elastic.apm.plugin.spi;
+
+public interface HeaderRemover {
+
+ void remove(String headerName, C carrier);
+}
diff --git a/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/HeaderSetter.java b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/HeaderSetter.java
new file mode 100644
index 00000000000..f56f7bfdd28
--- /dev/null
+++ b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/HeaderSetter.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package co.elastic.apm.plugin.spi;
+
+public interface HeaderSetter {
+
+ void setHeader(String headerName, T headerValue, C carrier);
+}
diff --git a/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/Http.java b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/Http.java
new file mode 100644
index 00000000000..943a183fb44
--- /dev/null
+++ b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/Http.java
@@ -0,0 +1,17 @@
+package co.elastic.apm.plugin.spi;
+
+import javax.annotation.Nullable;
+
+public interface Http {
+
+ Http withUrl(@Nullable String url);
+
+ Http withMethod(String method);
+
+ Http withStatusCode(int statusCode);
+
+ CharSequence getUrl();
+
+ @Nullable
+ String getMethod();
+}
diff --git a/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/Id.java b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/Id.java
new file mode 100644
index 00000000000..7de610830ef
--- /dev/null
+++ b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/Id.java
@@ -0,0 +1,7 @@
+package co.elastic.apm.plugin.spi;
+
+public interface Id {
+ boolean isEmpty();
+
+ void setToRandomValue();
+}
diff --git a/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/Message.java b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/Message.java
new file mode 100644
index 00000000000..10ce40ad6c2
--- /dev/null
+++ b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/Message.java
@@ -0,0 +1,20 @@
+package co.elastic.apm.plugin.spi;
+
+import javax.annotation.Nullable;
+
+public interface Message {
+
+ Message withAge(long age);
+
+ Message withBody(@Nullable String body);
+
+ Message withRoutingKey(String routingKey);
+
+ Message withQueue(@Nullable String queueName);
+
+ Message addHeader(@Nullable String key, @Nullable String value);
+
+ Message addHeader(@Nullable String key, @Nullable byte[] value);
+
+ Message appendToBody(CharSequence bodyContent);
+}
diff --git a/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/NoopTracer.java b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/NoopTracer.java
new file mode 100644
index 00000000000..d292dc0a28a
--- /dev/null
+++ b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/NoopTracer.java
@@ -0,0 +1,128 @@
+package co.elastic.apm.plugin.spi;
+
+import javax.annotation.Nullable;
+
+class NoopTracer implements Tracer {
+
+ static final Tracer INSTANCE = new NoopTracer();
+
+ private NoopTracer() {
+ }
+
+ @Nullable
+ @Override
+ public Transaction> startRootTransaction(@Nullable ClassLoader initiatingClassLoader) {
+ return null;
+ }
+
+ @Nullable
+ @Override
+ public Transaction> startRootTransaction(@Nullable ClassLoader initiatingClassLoader, long epochMicro) {
+ return null;
+ }
+
+ @Nullable
+ @Override
+ public Transaction> startChildTransaction(@Nullable C headerCarrier, TextHeaderGetter textHeadersGetter, @Nullable ClassLoader initiatingClassLoader) {
+ return null;
+ }
+
+ @Nullable
+ @Override
+ public Transaction> startChildTransaction(@Nullable C headerCarrier, TextHeaderGetter textHeadersGetter, @Nullable ClassLoader initiatingClassLoader, long epochMicros) {
+ return null;
+ }
+
+ @Nullable
+ @Override
+ public Transaction> startChildTransaction(@Nullable C headerCarrier, BinaryHeaderGetter binaryHeadersGetter, @Nullable ClassLoader initiatingClassLoader) {
+ return null;
+ }
+
+ @Nullable
+ @Override
+ public Transaction> currentTransaction() {
+ return null;
+ }
+
+ @Nullable
+ @Override
+ public AbstractSpan> getActive() {
+ return null;
+ }
+
+ @Nullable
+ @Override
+ public Span> getActiveSpan() {
+ return null;
+ }
+
+ @Override
+ public void captureAndReportException(@Nullable Throwable e, ClassLoader initiatingClassLoader) {
+ }
+
+ @Nullable
+ @Override
+ public String captureAndReportException(long epochMicros, @Nullable Throwable e, @Nullable AbstractSpan> parent) {
+ return null;
+ }
+
+ @Nullable
+ @Override
+ public ErrorCapture captureException(@Nullable Throwable e, @Nullable AbstractSpan> parent, @Nullable ClassLoader initiatingClassLoader) {
+ return null;
+ }
+
+ @Nullable
+ @Override
+ public Span> getActiveExitSpan() {
+ return null;
+ }
+
+ @Nullable
+ @Override
+ public Span> createExitChildSpan() {
+ return null;
+ }
+
+ @Override
+ public void endSpan(Span> span) {
+ }
+
+ @Override
+ public void endTransaction(Transaction> transaction) {
+ }
+
+ @Override
+ public void endError(ErrorCapture errorCapture) {
+ }
+
+ @Override
+ public T getConfig(Class configuration) {
+ return null;
+ }
+
+ @Override
+ public ObjectPoolFactory getObjectPoolFactory() {
+ return null;
+ }
+
+ @Override
+ public boolean isRunning() {
+ return false;
+ }
+
+ @Override
+ public void setServiceInfoForClassLoader(ClassLoader classLoader, ServiceInfo serviceInfo) {
+ }
+
+ @Override
+ public ServiceInfo getServiceInfoForClassLoader(ClassLoader classLoader) {
+ return null;
+ }
+
+ @Override
+ public ServiceInfo autoDetectedServiceName() {
+ return null;
+ }
+}
diff --git a/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/ObjectPool.java b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/ObjectPool.java
new file mode 100644
index 00000000000..8e6159d1486
--- /dev/null
+++ b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/ObjectPool.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package co.elastic.apm.plugin.spi;
+
+public interface ObjectPool {
+
+ T createInstance();
+
+ void recycle(T obj);
+
+ void clear();
+}
diff --git a/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/ObjectPoolFactory.java b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/ObjectPoolFactory.java
new file mode 100644
index 00000000000..245c332ea4c
--- /dev/null
+++ b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/ObjectPoolFactory.java
@@ -0,0 +1,6 @@
+package co.elastic.apm.plugin.spi;
+
+public interface ObjectPoolFactory {
+
+ ObjectPool createRecyclableObjectPool(int maxCapacity, Allocator allocator);
+}
diff --git a/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/Outcome.java b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/Outcome.java
new file mode 100644
index 00000000000..71976521b40
--- /dev/null
+++ b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/Outcome.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package co.elastic.apm.plugin.spi;
+
+public interface Outcome {
+
+ String name();
+}
diff --git a/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/PotentiallyMultiValuedMap.java b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/PotentiallyMultiValuedMap.java
new file mode 100644
index 00000000000..e63e9c7e84a
--- /dev/null
+++ b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/PotentiallyMultiValuedMap.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package co.elastic.apm.plugin.spi;
+
+import javax.annotation.Nullable;
+import java.util.List;
+
+public interface PotentiallyMultiValuedMap extends Recyclable {
+ void add(String key, String value);
+
+ void set(String key, String... values);
+
+ @Nullable
+ String getFirst(String key);
+
+ @Nullable
+ Object get(String key);
+
+ List getAll(String key);
+
+ boolean isEmpty();
+
+ String getKey(int i);
+
+ Object getValue(int i);
+
+ int size();
+
+ void removeIgnoreCase(String key);
+
+ void set(int index, String value);
+
+ boolean containsIgnoreCase(String key);
+}
diff --git a/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/Recyclable.java b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/Recyclable.java
new file mode 100644
index 00000000000..e26c6c33388
--- /dev/null
+++ b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/Recyclable.java
@@ -0,0 +1,6 @@
+package co.elastic.apm.plugin.spi;
+
+public interface Recyclable {
+
+ void resetState();
+}
diff --git a/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/Request.java b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/Request.java
new file mode 100644
index 00000000000..51e6cab00c6
--- /dev/null
+++ b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/Request.java
@@ -0,0 +1,37 @@
+package co.elastic.apm.plugin.spi;
+
+import javax.annotation.Nullable;
+import java.nio.CharBuffer;
+import java.util.Enumeration;
+
+public interface Request {
+ boolean hasContent();
+
+ Request withMethod(@Nullable String method);
+
+ Socket getSocket();
+
+ Url getUrl();
+
+ PotentiallyMultiValuedMap getHeaders();
+
+ PotentiallyMultiValuedMap getCookies();
+
+ Request withHttpVersion(@Nullable String httpVersion);
+
+ CharBuffer withBodyBuffer();
+
+ void redactBody();
+
+ Request addFormUrlEncodedParameters(String key, String[] values);
+
+ Request addHeader(String headerName, @Nullable Enumeration headerValues);
+
+ Request addCookie(String cookieName, String cookieValue);
+
+ CharBuffer getBodyBuffer();
+
+ void endOfBufferInput();
+
+ void setRawBody(String rawBody);
+}
diff --git a/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/Response.java b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/Response.java
new file mode 100644
index 00000000000..7eb26ba4ed1
--- /dev/null
+++ b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/Response.java
@@ -0,0 +1,17 @@
+package co.elastic.apm.plugin.spi;
+
+import javax.annotation.Nullable;
+import java.util.Collection;
+
+public interface Response {
+
+ PotentiallyMultiValuedMap getHeaders();
+
+ Response withFinished(boolean finished);
+
+ Response withStatusCode(int statusCode);
+
+ Response withHeadersSent(boolean headersSent);
+
+ Response addHeader(String headerName, @Nullable Collection headerValues);
+}
diff --git a/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/ResultUtil.java b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/ResultUtil.java
new file mode 100644
index 00000000000..a47b3f514de
--- /dev/null
+++ b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/ResultUtil.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package co.elastic.apm.plugin.spi;
+
+import javax.annotation.Nullable;
+
+public class ResultUtil {
+
+ @Nullable
+ public static String getResultByHttpStatus(int status) {
+ if (status >= 200 && status < 300) {
+ return "HTTP 2xx";
+ }
+ if (status >= 300 && status < 400) {
+ return "HTTP 3xx";
+ }
+ if (status >= 400 && status < 500) {
+ return "HTTP 4xx";
+ }
+ if (status >= 500 && status < 600) {
+ return "HTTP 5xx";
+ }
+ if (status >= 100 && status < 200) {
+ return "HTTP 1xx";
+ }
+ return null;
+ }
+
+ public static Outcome getOutcomeByHttpClientStatus(int status) {
+ if (status < 100 || status >= 600) {
+ return DefaultOutcome.FAILURE;
+ }
+ return status < 400 ? DefaultOutcome.SUCCESS : DefaultOutcome.FAILURE;
+ }
+
+ public static Outcome getOutcomeByHttpServerStatus(int status) {
+ if (status < 100 || status >= 600) {
+ return DefaultOutcome.FAILURE;
+ }
+ return status < 500 ? DefaultOutcome.SUCCESS : DefaultOutcome.FAILURE;
+ }
+}
diff --git a/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/Scope.java b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/Scope.java
new file mode 100644
index 00000000000..0b44fe59273
--- /dev/null
+++ b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/Scope.java
@@ -0,0 +1,25 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package co.elastic.apm.plugin.spi;
+
+public interface Scope extends AutoCloseable {
+
+ @Override
+ void close();
+}
diff --git a/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/ServiceInfo.java b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/ServiceInfo.java
new file mode 100644
index 00000000000..214f8486651
--- /dev/null
+++ b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/ServiceInfo.java
@@ -0,0 +1,141 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package co.elastic.apm.plugin.spi;
+
+import javax.annotation.Nullable;
+import java.util.Objects;
+import java.util.jar.Attributes;
+import java.util.jar.Manifest;
+
+public class ServiceInfo {
+
+ private static final String DEFAULT_SERVICE_NAME = "unknown-java-service";
+ private static final ServiceInfo EMPTY = new ServiceInfo(null, null);
+
+ protected final String serviceName;
+ @Nullable
+ protected final String serviceVersion;
+ protected final boolean multiServiceContainer;
+
+ public ServiceInfo(@Nullable String serviceName) {
+ this(serviceName, null);
+ }
+
+ private ServiceInfo(@Nullable String serviceName, @Nullable String serviceVersion) {
+ this(serviceName, serviceVersion, false);
+ }
+
+ protected ServiceInfo(@Nullable String serviceName, @Nullable String serviceVersion, boolean multiServiceContainer) {
+ this.multiServiceContainer = multiServiceContainer;
+ if (serviceName == null || serviceName.trim().isEmpty()) {
+ this.serviceName = DEFAULT_SERVICE_NAME;
+ } else {
+ this.serviceName = replaceDisallowedServiceNameChars(serviceName).trim();
+ }
+ this.serviceVersion = serviceVersion;
+ }
+
+ public static ServiceInfo empty() {
+ return EMPTY;
+ }
+
+ public static ServiceInfo of(@Nullable String serviceName) {
+ return of(serviceName, null);
+ }
+
+ public static ServiceInfo of(@Nullable String serviceName, @Nullable String serviceVersion) {
+ if ((serviceName == null || serviceName.isEmpty()) &&
+ (serviceVersion == null || serviceVersion.isEmpty())) {
+ return empty();
+ }
+ return new ServiceInfo(serviceName, serviceVersion);
+ }
+
+ private static String replaceDisallowedServiceNameChars(String serviceName) {
+ return serviceName.replaceAll("[^a-zA-Z0-9 _-]", "-");
+ }
+
+ public static ServiceInfo fromManifest(@Nullable Manifest manifest) {
+ if (manifest == null) {
+ return ServiceInfo.empty();
+ }
+ Attributes mainAttributes = manifest.getMainAttributes();
+ return ServiceInfo.of(
+ mainAttributes.getValue(Attributes.Name.IMPLEMENTATION_TITLE),
+ mainAttributes.getValue(Attributes.Name.IMPLEMENTATION_VERSION));
+ }
+
+ public static ServiceInfo autoDetected() {
+ return null; // TODO
+ }
+
+ public String getServiceName() {
+ return serviceName;
+ }
+
+ @Nullable
+ public String getServiceVersion() {
+ return serviceVersion;
+ }
+
+ /**
+ * Returns true if the service is a container service that can host multiple other applications.
+ * For example, an application server or servlet container.
+ * A standalone application that's built on embedded Tomcat, for example, would return {@code false}.
+ */
+ public boolean isMultiServiceContainer() {
+ return multiServiceContainer;
+ }
+
+ public ServiceInfo withFallback(ServiceInfo fallback) {
+ return ServiceInfo.of(
+ hasServiceName() ? serviceName : fallback.serviceName,
+ serviceVersion != null ? serviceVersion : fallback.serviceVersion);
+ }
+
+ public boolean hasServiceName() {
+ return !serviceName.equals(DEFAULT_SERVICE_NAME);
+ }
+
+ public boolean isEmpty() {
+ return !hasServiceName() && serviceVersion == null;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ ServiceInfo that = (ServiceInfo) o;
+ return multiServiceContainer == that.multiServiceContainer && serviceName.equals(that.serviceName) && Objects.equals(serviceVersion, that.serviceVersion);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(serviceName, serviceVersion, multiServiceContainer);
+ }
+
+ @Override
+ public String toString() {
+ return "ServiceInfo{" +
+ "serviceName='" + serviceName + '\'' +
+ ", serviceVersion='" + serviceVersion + '\'' +
+ ", multiServiceContainer=" + multiServiceContainer +
+ '}';
+ }
+}
diff --git a/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/ServiceTarget.java b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/ServiceTarget.java
new file mode 100644
index 00000000000..5baa307d672
--- /dev/null
+++ b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/ServiceTarget.java
@@ -0,0 +1,15 @@
+package co.elastic.apm.plugin.spi;
+
+import javax.annotation.Nullable;
+
+public interface ServiceTarget {
+ ServiceTarget withType(@Nullable String type);
+
+ ServiceTarget withName(@Nullable CharSequence name);
+
+ ServiceTarget withUserName(@Nullable CharSequence name);
+
+ ServiceTarget withHostPortName(@Nullable CharSequence host, int port);
+
+ ServiceTarget withNameOnlyDestinationResource();
+}
diff --git a/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/Socket.java b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/Socket.java
new file mode 100644
index 00000000000..81af77b1293
--- /dev/null
+++ b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/Socket.java
@@ -0,0 +1,8 @@
+package co.elastic.apm.plugin.spi;
+
+import javax.annotation.Nullable;
+
+public interface Socket {
+
+ Socket withRemoteAddress(@Nullable String remoteAddress);
+}
diff --git a/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/Span.java b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/Span.java
new file mode 100644
index 00000000000..2822c004c7a
--- /dev/null
+++ b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/Span.java
@@ -0,0 +1,26 @@
+package co.elastic.apm.plugin.spi;
+
+import javax.annotation.Nullable;
+import java.util.concurrent.TimeUnit;
+
+public interface Span> extends AbstractSpan {
+
+ long MAX_LOG_INTERVAL_MICRO_SECS = TimeUnit.MINUTES.toMicros(5);
+
+ SpanContext getContext();
+
+ @Nullable
+ String getSubtype();
+
+ boolean isExit();
+
+ @Nullable
+ String getAction();
+
+ T withAction(@Nullable String action);
+
+ T withSubtype(@Nullable String subtype);
+
+ @Deprecated
+ void setType(@Nullable String type, @Nullable String subtype, @Nullable String action);
+}
diff --git a/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/SpanContext.java b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/SpanContext.java
new file mode 100644
index 00000000000..f41509fe601
--- /dev/null
+++ b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/SpanContext.java
@@ -0,0 +1,12 @@
+package co.elastic.apm.plugin.spi;
+
+public interface SpanContext extends AbstractContext {
+
+ ServiceTarget getServiceTarget();
+
+ Destination getDestination();
+
+ Db getDb();
+
+ Http getHttp();
+}
diff --git a/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/TextHeaderGetter.java b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/TextHeaderGetter.java
new file mode 100644
index 00000000000..40481bc3ece
--- /dev/null
+++ b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/TextHeaderGetter.java
@@ -0,0 +1,4 @@
+package co.elastic.apm.plugin.spi;
+
+public interface TextHeaderGetter extends HeaderGetter {
+}
diff --git a/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/TextHeaderSetter.java b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/TextHeaderSetter.java
new file mode 100644
index 00000000000..b35c921001c
--- /dev/null
+++ b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/TextHeaderSetter.java
@@ -0,0 +1,22 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package co.elastic.apm.plugin.spi;
+
+public interface TextHeaderSetter extends HeaderSetter {
+}
diff --git a/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/TraceContext.java b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/TraceContext.java
new file mode 100644
index 00000000000..5863893795d
--- /dev/null
+++ b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/TraceContext.java
@@ -0,0 +1,32 @@
+package co.elastic.apm.plugin.spi;
+
+import javax.annotation.Nullable;
+
+public interface TraceContext {
+
+ String ELASTIC_TRACE_PARENT_TEXTUAL_HEADER_NAME = "elastic-apm-traceparent";
+ String W3C_TRACE_PARENT_TEXTUAL_HEADER_NAME = "traceparent";
+ String TRACESTATE_HEADER_NAME = "tracestate";
+ public static final int SERIALIZED_LENGTH = 42;
+
+ String TRACE_PARENT_BINARY_HEADER_NAME = "elasticapmtraceparent";
+ int BINARY_FORMAT_EXPECTED_LENGTH = 29;
+
+ Id getTraceId();
+
+ Id getId();
+
+ Id getParentId();
+
+ Id getTransactionId();
+
+ void setServiceInfo(@Nullable String serviceName, @Nullable String serviceVersion);
+
+ boolean asChildOf(byte[] parent);
+
+ boolean asChildOf(String parent);
+
+ void asChildOf(TraceContext parent);
+
+ void addTraceState(String header);
+}
diff --git a/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/TraceContextUtil.java b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/TraceContextUtil.java
new file mode 100644
index 00000000000..c10df38d653
--- /dev/null
+++ b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/TraceContextUtil.java
@@ -0,0 +1,145 @@
+package co.elastic.apm.plugin.spi;
+
+import javax.annotation.Nullable;
+
+public class TraceContextUtil {
+
+ private static final ChildContextCreator FROM_PARENT_CONTEXT = new ChildContextCreator() {
+ @Override
+ public boolean asChildOf(TraceContext child, TraceContext parent) {
+ child.asChildOf(parent);
+ return true;
+ }
+ };
+ private static final ChildContextCreator> FROM_PARENT = new ChildContextCreator>() {
+ @Override
+ public boolean asChildOf(TraceContext child, AbstractSpan> parent) {
+ child.asChildOf(parent.getTraceContext());
+ return true;
+ }
+ };
+ private static final HeaderGetter.HeaderConsumer TRACESTATE_HEADER_CONSUMER = new HeaderGetter.HeaderConsumer() {
+ @Override
+ public void accept(@Nullable String tracestateHeaderValue, TraceContext state) {
+ if (tracestateHeaderValue != null) {
+ state.addTraceState(tracestateHeaderValue);
+ }
+ }
+ };
+ private static final HeaderChildContextCreator FROM_TRACE_CONTEXT_TEXT_HEADERS =
+ new HeaderChildContextCreator() {
+ @Override
+ public boolean asChildOf(TraceContext child, @Nullable Object carrier, HeaderGetter traceContextHeaderGetter) {
+ if (carrier == null) {
+ return false;
+ }
+
+ boolean isValid = false;
+ String traceparent = traceContextHeaderGetter.getFirstHeader(TraceContext.W3C_TRACE_PARENT_TEXTUAL_HEADER_NAME, carrier);
+ if (traceparent != null) {
+ isValid = child.asChildOf(traceparent);
+ }
+
+ if (!isValid) {
+ // Look for the legacy Elastic traceparent header (in case this comes from an older agent)
+ traceparent = traceContextHeaderGetter.getFirstHeader(TraceContext.ELASTIC_TRACE_PARENT_TEXTUAL_HEADER_NAME, carrier);
+ if (traceparent != null) {
+ isValid = child.asChildOf(traceparent);
+ }
+ }
+
+ if (isValid) {
+ // as per spec, the tracestate header can be multi-valued
+ traceContextHeaderGetter.forEach(TraceContext.TRACESTATE_HEADER_NAME, carrier, child, TRACESTATE_HEADER_CONSUMER);
+ }
+
+ return isValid;
+ }
+ };
+ private static final HeaderChildContextCreator FROM_TRACE_CONTEXT_BINARY_HEADERS =
+ new HeaderChildContextCreator() {
+ @Override
+ public boolean asChildOf(TraceContext child, @Nullable Object carrier, HeaderGetter traceContextHeaderGetter) {
+ if (carrier == null) {
+ return false;
+ }
+ byte[] traceparent = traceContextHeaderGetter.getFirstHeader(TraceContext.TRACE_PARENT_BINARY_HEADER_NAME, carrier);
+ if (traceparent != null) {
+ return child.asChildOf(traceparent);
+ }
+ return false;
+ }
+ };
+ private static final ChildContextCreator FROM_ACTIVE = new ChildContextCreator() {
+ @Override
+ public boolean asChildOf(TraceContext child, Tracer tracer) {
+ final AbstractSpan> active = tracer.getActive();
+ if (active != null) {
+ return fromParent().asChildOf(child, active);
+
+ }
+ return false;
+ }
+ };
+ private static final ChildContextCreator AS_ROOT = new ChildContextCreator() {
+ @Override
+ public boolean asChildOf(TraceContext child, Object ignore) {
+ return false;
+ }
+ };
+
+ private TraceContextUtil() {
+ }
+
+ @SuppressWarnings("unchecked")
+ public static HeaderChildContextCreator getFromTraceContextTextHeaders() {
+ return (HeaderChildContextCreator) FROM_TRACE_CONTEXT_TEXT_HEADERS;
+ }
+
+ @SuppressWarnings("unchecked")
+ public static HeaderChildContextCreator getFromTraceContextBinaryHeaders() {
+ return (HeaderChildContextCreator) FROM_TRACE_CONTEXT_BINARY_HEADERS;
+ }
+
+ public static ChildContextCreator fromActive() {
+ return FROM_ACTIVE;
+ }
+
+ public static ChildContextCreator fromParentContext() {
+ return FROM_PARENT_CONTEXT;
+ }
+
+ public static ChildContextCreator> fromParent() {
+ return FROM_PARENT;
+ }
+
+ public static ChildContextCreator> asRoot() {
+ return AS_ROOT;
+ }
+
+ public static void copyTraceContextTextHeaders(S source, TextHeaderGetter headerGetter, D destination, TextHeaderSetter headerSetter) {
+ String w3cApmTraceParent = headerGetter.getFirstHeader(TraceContext.W3C_TRACE_PARENT_TEXTUAL_HEADER_NAME, source);
+ if (w3cApmTraceParent != null) {
+ headerSetter.setHeader(TraceContext.W3C_TRACE_PARENT_TEXTUAL_HEADER_NAME, w3cApmTraceParent, destination);
+ }
+ String elasticApmTraceParent = headerGetter.getFirstHeader(TraceContext.ELASTIC_TRACE_PARENT_TEXTUAL_HEADER_NAME, source);
+ if (elasticApmTraceParent != null) {
+ headerSetter.setHeader(TraceContext.ELASTIC_TRACE_PARENT_TEXTUAL_HEADER_NAME, elasticApmTraceParent, destination);
+ }
+ String tracestate = headerGetter.getFirstHeader(TraceContext.TRACESTATE_HEADER_NAME, source);
+ if (tracestate != null) {
+ headerSetter.setHeader(TraceContext.TRACESTATE_HEADER_NAME, tracestate, destination);
+ }
+ }
+
+ public static boolean containsTraceContextTextHeaders(C carrier, TextHeaderGetter headerGetter) {
+ return headerGetter.getFirstHeader(TraceContext.W3C_TRACE_PARENT_TEXTUAL_HEADER_NAME, carrier) != null;
+ }
+
+ public static void removeTraceContextHeaders(C carrier, HeaderRemover headerRemover) {
+ headerRemover.remove(TraceContext.W3C_TRACE_PARENT_TEXTUAL_HEADER_NAME, carrier);
+ headerRemover.remove(TraceContext.ELASTIC_TRACE_PARENT_TEXTUAL_HEADER_NAME, carrier);
+ headerRemover.remove(TraceContext.TRACESTATE_HEADER_NAME, carrier);
+ headerRemover.remove(TraceContext.TRACE_PARENT_BINARY_HEADER_NAME, carrier);
+ }
+}
diff --git a/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/Tracer.java b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/Tracer.java
new file mode 100644
index 00000000000..c91cb04402e
--- /dev/null
+++ b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/Tracer.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package co.elastic.apm.plugin.spi;
+
+import javax.annotation.Nullable;
+
+public interface Tracer {
+
+ @Nullable
+ Transaction> startRootTransaction(@Nullable ClassLoader initiatingClassLoader);
+
+ @Nullable
+ Transaction> startRootTransaction(@Nullable ClassLoader initiatingClassLoader, long epochMicro);
+
+ @Nullable
+ Transaction> startChildTransaction(@Nullable C headerCarrier, TextHeaderGetter textHeadersGetter, @Nullable ClassLoader initiatingClassLoader);
+
+ @Nullable
+ Transaction> startChildTransaction(@Nullable C headerCarrier, TextHeaderGetter textHeadersGetter, @Nullable ClassLoader initiatingClassLoader, long epochMicros);
+
+ @Nullable
+ Transaction> startChildTransaction(@Nullable C headerCarrier, BinaryHeaderGetter binaryHeadersGetter, @Nullable ClassLoader initiatingClassLoader);
+
+ @Nullable
+ Transaction> currentTransaction();
+
+ @Nullable
+ AbstractSpan> getActive();
+
+ @Nullable
+ Span> getActiveSpan();
+
+ void captureAndReportException(@Nullable Throwable e, ClassLoader initiatingClassLoader);
+
+ @Nullable
+ String captureAndReportException(long epochMicros, @Nullable Throwable e, @Nullable AbstractSpan> parent);
+
+ @Nullable
+ ErrorCapture captureException(@Nullable Throwable e, @Nullable AbstractSpan> parent, @Nullable ClassLoader initiatingClassLoader);
+
+ @Nullable
+ Span> getActiveExitSpan();
+
+ @Nullable
+ Span> createExitChildSpan();
+
+ void endSpan(Span> span);
+
+ void endTransaction(Transaction> transaction);
+
+ void endError(ErrorCapture errorCapture);
+
+ T getConfig(Class configuration);
+
+ ObjectPoolFactory getObjectPoolFactory();
+
+ boolean isRunning();
+
+ void setServiceInfoForClassLoader(ClassLoader classLoader, ServiceInfo serviceInfo);
+
+ ServiceInfo getServiceInfoForClassLoader(ClassLoader classLoader);
+
+ ServiceInfo autoDetectedServiceName();
+}
diff --git a/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/Transaction.java b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/Transaction.java
new file mode 100644
index 00000000000..98fc2b5de38
--- /dev/null
+++ b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/Transaction.java
@@ -0,0 +1,38 @@
+package co.elastic.apm.plugin.spi;
+
+import javax.annotation.Nullable;
+
+public interface Transaction> extends AbstractSpan {
+
+ String TYPE_REQUEST = "request";
+
+ TransactionContext getContext();
+
+ boolean isNoop();
+
+ void ignoreTransaction();
+
+ void addCustomContext(String key, String value);
+
+ void addCustomContext(String key, Number value);
+
+ void addCustomContext(String key, Boolean value);
+
+ void setFrameworkName(@Nullable String frameworkName);
+
+ void setUserFrameworkName(@Nullable String frameworkName);
+
+ T captureException(@Nullable Throwable thrown);
+
+ T withResult(@Nullable String result);
+
+ T withResultIfUnset(@Nullable String result);
+
+ String getType();
+
+ void setFrameworkVersion(@Nullable String frameworkVersion);
+
+ Faas getFaas();
+
+ void setUser(String id, String email, String username, String domain);
+}
diff --git a/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/TransactionContext.java b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/TransactionContext.java
new file mode 100644
index 00000000000..384c6786b78
--- /dev/null
+++ b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/TransactionContext.java
@@ -0,0 +1,12 @@
+package co.elastic.apm.plugin.spi;
+
+public interface TransactionContext extends AbstractContext {
+
+ Request getRequest();
+
+ Response getResponse();
+
+ User getUser();
+
+ CloudOrigin getCloudOrigin();
+}
diff --git a/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/Url.java b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/Url.java
new file mode 100644
index 00000000000..406e71e295e
--- /dev/null
+++ b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/Url.java
@@ -0,0 +1,21 @@
+package co.elastic.apm.plugin.spi;
+
+import javax.annotation.Nullable;
+import java.net.URI;
+
+public interface Url {
+
+ void fillFrom(URI uri);
+
+ void fillFrom(@Nullable String scheme, @Nullable String serverName, int serverPort, @Nullable String requestURI, @Nullable String queryString);
+
+ Url withProtocol(@Nullable String protocol);
+
+ Url withHostname(@Nullable String hostname);
+
+ Url withPort(int port);
+
+ Url withPathname(@Nullable String pathname);
+
+ Url withSearch(@Nullable String search);
+}
diff --git a/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/User.java b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/User.java
new file mode 100644
index 00000000000..9d2dd7e6ecf
--- /dev/null
+++ b/apm-agent-plugin-spi/src/main/java/co/elastic/apm/plugin/spi/User.java
@@ -0,0 +1,7 @@
+package co.elastic.apm.plugin.spi;
+
+public interface User {
+ String getUsername();
+
+ User withUsername(String userName);
+}
diff --git a/apm-agent-plugins/apm-apache-httpclient/apm-apache-httpclient3-plugin/src/main/java/co/elastic/apm/agent/httpclient/v3/HttpClient3Instrumentation.java b/apm-agent-plugins/apm-apache-httpclient/apm-apache-httpclient3-plugin/src/main/java/co/elastic/apm/agent/httpclient/v3/HttpClient3Instrumentation.java
index b0614356d83..ecbab16d8d8 100644
--- a/apm-agent-plugins/apm-apache-httpclient/apm-apache-httpclient3-plugin/src/main/java/co/elastic/apm/agent/httpclient/v3/HttpClient3Instrumentation.java
+++ b/apm-agent-plugins/apm-apache-httpclient/apm-apache-httpclient3-plugin/src/main/java/co/elastic/apm/agent/httpclient/v3/HttpClient3Instrumentation.java
@@ -20,10 +20,7 @@
import co.elastic.apm.agent.bci.TracerAwareInstrumentation;
import co.elastic.apm.agent.httpclient.HttpClientHelper;
-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.impl.transaction.TraceContext;
+import co.elastic.apm.plugin.spi.*;
import co.elastic.apm.agent.sdk.logging.Logger;
import co.elastic.apm.agent.sdk.logging.LoggerFactory;
import co.elastic.apm.agent.util.LoggerUtils;
@@ -115,16 +112,16 @@ public static Object onEnter(@Advice.Argument(0) HttpMethod httpMethod,
}
}
- Span span = HttpClientHelper.startHttpClientSpan(parent, httpMethod.getName(), uri, protocol, host, port);
+ Span> span = HttpClientHelper.startHttpClientSpan(parent, httpMethod.getName(), uri, protocol, host, port);
if (span != null) {
span.activate();
}
- if (!TraceContext.containsTraceContextTextHeaders(httpMethod, HttpClient3RequestHeaderAccessor.INSTANCE)) {
+ if (!TraceContextUtil.containsTraceContextTextHeaders(httpMethod, HttpClient3RequestHeaderAccessor.INSTANCE)) {
if (span != null) {
span.propagateTraceContext(httpMethod, HttpClient3RequestHeaderAccessor.INSTANCE);
- } else if (!TraceContext.containsTraceContextTextHeaders(httpMethod, HttpClient3RequestHeaderAccessor.INSTANCE)) {
+ } else if (!TraceContextUtil.containsTraceContextTextHeaders(httpMethod, HttpClient3RequestHeaderAccessor.INSTANCE)) {
// re-adds the header on redirects
parent.propagateTraceContext(httpMethod, HttpClient3RequestHeaderAccessor.INSTANCE);
}
@@ -138,11 +135,11 @@ public static void onExit(@Advice.Thrown @Nullable Throwable thrown,
@Advice.Argument(0) HttpMethod httpMethod,
@Advice.Enter @Nullable Object enterSpan) {
- if (!(enterSpan instanceof Span)) {
+ if (!(enterSpan instanceof Span>)) {
return;
}
- Span span = (Span) enterSpan;
+ Span> span = (Span>) enterSpan;
StatusLine statusLine = httpMethod.getStatusLine();
if (null != statusLine) {
@@ -150,7 +147,7 @@ public static void onExit(@Advice.Thrown @Nullable Throwable thrown,
}
if (thrown instanceof CircularRedirectException) {
- span.withOutcome(Outcome.FAILURE);
+ span.withOutcome(DefaultOutcome.FAILURE);
}
span.captureException(thrown)
diff --git a/apm-agent-plugins/apm-apache-httpclient/apm-apache-httpclient3-plugin/src/main/java/co/elastic/apm/agent/httpclient/v3/HttpClient3RequestHeaderAccessor.java b/apm-agent-plugins/apm-apache-httpclient/apm-apache-httpclient3-plugin/src/main/java/co/elastic/apm/agent/httpclient/v3/HttpClient3RequestHeaderAccessor.java
index 0f02a8a94ae..748e24738cf 100644
--- a/apm-agent-plugins/apm-apache-httpclient/apm-apache-httpclient3-plugin/src/main/java/co/elastic/apm/agent/httpclient/v3/HttpClient3RequestHeaderAccessor.java
+++ b/apm-agent-plugins/apm-apache-httpclient/apm-apache-httpclient3-plugin/src/main/java/co/elastic/apm/agent/httpclient/v3/HttpClient3RequestHeaderAccessor.java
@@ -18,8 +18,8 @@
*/
package co.elastic.apm.agent.httpclient.v3;
-import co.elastic.apm.agent.impl.transaction.TextHeaderGetter;
-import co.elastic.apm.agent.impl.transaction.TextHeaderSetter;
+import co.elastic.apm.plugin.spi.TextHeaderGetter;
+import co.elastic.apm.plugin.spi.TextHeaderSetter;
import org.apache.commons.httpclient.Header;
import org.apache.commons.httpclient.HttpMethod;
diff --git a/apm-agent-plugins/apm-apache-httpclient/apm-apache-httpclient4-plugin/src/main/java/co/elastic/apm/agent/httpclient/v4/ApacheHttpAsyncClientInstrumentation.java b/apm-agent-plugins/apm-apache-httpclient/apm-apache-httpclient4-plugin/src/main/java/co/elastic/apm/agent/httpclient/v4/ApacheHttpAsyncClientInstrumentation.java
index 2cc40830873..12c8898b45d 100644
--- a/apm-agent-plugins/apm-apache-httpclient/apm-apache-httpclient4-plugin/src/main/java/co/elastic/apm/agent/httpclient/v4/ApacheHttpAsyncClientInstrumentation.java
+++ b/apm-agent-plugins/apm-apache-httpclient/apm-apache-httpclient4-plugin/src/main/java/co/elastic/apm/agent/httpclient/v4/ApacheHttpAsyncClientInstrumentation.java
@@ -20,8 +20,8 @@
import co.elastic.apm.agent.httpclient.HttpClientHelper;
import co.elastic.apm.agent.httpclient.v4.helper.ApacheHttpAsyncClientHelper;
-import co.elastic.apm.agent.impl.transaction.AbstractSpan;
-import co.elastic.apm.agent.impl.transaction.Span;
+import co.elastic.apm.plugin.spi.AbstractSpan;
+import co.elastic.apm.plugin.spi.Span;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.asm.Advice.AssignReturned.ToArguments.ToArgument;
import net.bytebuddy.description.NamedElement;
@@ -93,7 +93,7 @@ public static Object[] onBeforeExecute(@Advice.Argument(value = 0) HttpAsyncRequ
if (parent == null) {
return null;
}
- Span span = parent.createExitSpan();
+ Span> span = parent.createExitSpan();
HttpAsyncRequestProducer wrappedProducer = requestProducer;
FutureCallback> wrappedFutureCallback = futureCallback;
boolean responseFutureWrapped = false;
@@ -114,7 +114,7 @@ public static Object[] onBeforeExecute(@Advice.Argument(value = 0) HttpAsyncRequ
@Advice.OnMethodExit(suppress = Throwable.class, onThrowable = Throwable.class, inline = false)
public static void onAfterExecute(@Advice.Enter @Nullable Object[] enter,
@Advice.Thrown @Nullable Throwable t) {
- Span span = enter != null ? (Span) enter[3] : null;
+ Span> span = enter != null ? (Span>) enter[3] : null;
if (span != null) {
// Deactivate in this thread. Span will be ended and reported by the listener
span.deactivate();
diff --git a/apm-agent-plugins/apm-apache-httpclient/apm-apache-httpclient4-plugin/src/main/java/co/elastic/apm/agent/httpclient/v4/ApacheHttpAsyncClientRedirectInstrumentation.java b/apm-agent-plugins/apm-apache-httpclient/apm-apache-httpclient4-plugin/src/main/java/co/elastic/apm/agent/httpclient/v4/ApacheHttpAsyncClientRedirectInstrumentation.java
index aacfb1cdf24..95ba61c23ca 100644
--- a/apm-agent-plugins/apm-apache-httpclient/apm-apache-httpclient4-plugin/src/main/java/co/elastic/apm/agent/httpclient/v4/ApacheHttpAsyncClientRedirectInstrumentation.java
+++ b/apm-agent-plugins/apm-apache-httpclient/apm-apache-httpclient4-plugin/src/main/java/co/elastic/apm/agent/httpclient/v4/ApacheHttpAsyncClientRedirectInstrumentation.java
@@ -19,7 +19,7 @@
package co.elastic.apm.agent.httpclient.v4;
import co.elastic.apm.agent.httpclient.v4.helper.RequestHeaderAccessor;
-import co.elastic.apm.agent.impl.transaction.TraceContext;
+import co.elastic.apm.plugin.spi.TraceContextUtil;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.NamedElement;
import net.bytebuddy.description.method.MethodDescription;
@@ -49,8 +49,8 @@ public static void onAfterExecute(@Advice.Argument(value = 0) HttpRequest origin
return;
}
// org.apache.http.HttpMessage#containsHeader implementations do not allocate iterator since 4.0.1
- if (TraceContext.containsTraceContextTextHeaders(original, RequestHeaderAccessor.INSTANCE) && !TraceContext.containsTraceContextTextHeaders(redirect, RequestHeaderAccessor.INSTANCE)) {
- TraceContext.copyTraceContextTextHeaders(original, RequestHeaderAccessor.INSTANCE, redirect, RequestHeaderAccessor.INSTANCE);
+ if (TraceContextUtil.containsTraceContextTextHeaders(original, RequestHeaderAccessor.INSTANCE) && !TraceContextUtil.containsTraceContextTextHeaders(redirect, RequestHeaderAccessor.INSTANCE)) {
+ TraceContextUtil.copyTraceContextTextHeaders(original, RequestHeaderAccessor.INSTANCE, redirect, RequestHeaderAccessor.INSTANCE);
}
}
}
diff --git a/apm-agent-plugins/apm-apache-httpclient/apm-apache-httpclient4-plugin/src/main/java/co/elastic/apm/agent/httpclient/v4/ApacheHttpClientInstrumentation.java b/apm-agent-plugins/apm-apache-httpclient/apm-apache-httpclient4-plugin/src/main/java/co/elastic/apm/agent/httpclient/v4/ApacheHttpClientInstrumentation.java
index 079b69b11c3..712c725507c 100644
--- a/apm-agent-plugins/apm-apache-httpclient/apm-apache-httpclient4-plugin/src/main/java/co/elastic/apm/agent/httpclient/v4/ApacheHttpClientInstrumentation.java
+++ b/apm-agent-plugins/apm-apache-httpclient/apm-apache-httpclient4-plugin/src/main/java/co/elastic/apm/agent/httpclient/v4/ApacheHttpClientInstrumentation.java
@@ -20,10 +20,7 @@
import co.elastic.apm.agent.httpclient.HttpClientHelper;
import co.elastic.apm.agent.httpclient.v4.helper.RequestHeaderAccessor;
-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.impl.transaction.TraceContext;
+import co.elastic.apm.plugin.spi.*;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.NamedElement;
import net.bytebuddy.description.method.MethodDescription;
@@ -58,16 +55,16 @@ public static Object onBeforeExecute(@Advice.Argument(0) HttpRoute route,
if (parent == null) {
return null;
}
- Span span = HttpClientHelper.startHttpClientSpan(parent, request.getMethod(), request.getURI(), route.getTargetHost().getHostName());
+ Span> span = HttpClientHelper.startHttpClientSpan(parent, request.getMethod(), request.getURI(), route.getTargetHost().getHostName());
if (span != null) {
span.activate();
}
- if (!TraceContext.containsTraceContextTextHeaders(request, RequestHeaderAccessor.INSTANCE)) {
+ if (!TraceContextUtil.containsTraceContextTextHeaders(request, RequestHeaderAccessor.INSTANCE)) {
if (span != null) {
span.propagateTraceContext(request, RequestHeaderAccessor.INSTANCE);
- } else if (!TraceContext.containsTraceContextTextHeaders(request, RequestHeaderAccessor.INSTANCE)) {
+ } else if (!TraceContextUtil.containsTraceContextTextHeaders(request, RequestHeaderAccessor.INSTANCE)) {
// re-adds the header on redirects
parent.propagateTraceContext(request, RequestHeaderAccessor.INSTANCE);
}
@@ -80,7 +77,7 @@ public static Object onBeforeExecute(@Advice.Argument(0) HttpRoute route,
public static void onAfterExecute(@Advice.Return @Nullable CloseableHttpResponse response,
@Advice.Enter @Nullable Object spanObj,
@Advice.Thrown @Nullable Throwable t) {
- Span span = (Span) spanObj;
+ Span> span = (Span>) spanObj;
if (span == null) {
return;
}
@@ -94,7 +91,7 @@ public static void onAfterExecute(@Advice.Return @Nullable CloseableHttpResponse
// in case of circular redirect, we get an exception but status code won't be available without response
// thus we have to deal with span outcome directly
if (t instanceof CircularRedirectException) {
- span.withOutcome(Outcome.FAILURE);
+ span.withOutcome(DefaultOutcome.FAILURE);
}
span.deactivate().end();
diff --git a/apm-agent-plugins/apm-apache-httpclient/apm-apache-httpclient4-plugin/src/main/java/co/elastic/apm/agent/httpclient/v4/LegacyApacheHttpClientInstrumentation.java b/apm-agent-plugins/apm-apache-httpclient/apm-apache-httpclient4-plugin/src/main/java/co/elastic/apm/agent/httpclient/v4/LegacyApacheHttpClientInstrumentation.java
index 4f59480cc13..90e15eed55e 100644
--- a/apm-agent-plugins/apm-apache-httpclient/apm-apache-httpclient4-plugin/src/main/java/co/elastic/apm/agent/httpclient/v4/LegacyApacheHttpClientInstrumentation.java
+++ b/apm-agent-plugins/apm-apache-httpclient/apm-apache-httpclient4-plugin/src/main/java/co/elastic/apm/agent/httpclient/v4/LegacyApacheHttpClientInstrumentation.java
@@ -20,10 +20,7 @@
import co.elastic.apm.agent.httpclient.HttpClientHelper;
import co.elastic.apm.agent.httpclient.v4.helper.RequestHeaderAccessor;
-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.impl.transaction.TraceContext;
+import co.elastic.apm.plugin.spi.*;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.NamedElement;
import net.bytebuddy.description.method.MethodDescription;
@@ -100,16 +97,16 @@ public static Object onBeforeExecute(@Advice.Argument(0) @Nullable HttpHost host
} catch (URISyntaxException ignore) {
}
}
- Span span = HttpClientHelper.startHttpClientSpan(parent, method, uri, hostName);
+ Span> span = HttpClientHelper.startHttpClientSpan(parent, method, uri, hostName);
if (span != null) {
span.activate();
}
- if (!TraceContext.containsTraceContextTextHeaders(request, RequestHeaderAccessor.INSTANCE)) {
+ if (!TraceContextUtil.containsTraceContextTextHeaders(request, RequestHeaderAccessor.INSTANCE)) {
if (span != null) {
span.propagateTraceContext(request, RequestHeaderAccessor.INSTANCE);
- } else if (!TraceContext.containsTraceContextTextHeaders(request, RequestHeaderAccessor.INSTANCE)) {
+ } else if (!TraceContextUtil.containsTraceContextTextHeaders(request, RequestHeaderAccessor.INSTANCE)) {
// re-adds the header on redirects
parent.propagateTraceContext(request, RequestHeaderAccessor.INSTANCE);
}
@@ -122,7 +119,7 @@ public static Object onBeforeExecute(@Advice.Argument(0) @Nullable HttpHost host
public static void onAfterExecute(@Advice.Return @Nullable HttpResponse response,
@Advice.Enter @Nullable Object spanObj,
@Advice.Thrown @Nullable Throwable t) {
- Span span = (Span) spanObj;
+ Span> span = (Span>) spanObj;
if (span == null) {
return;
}
@@ -136,7 +133,7 @@ public static void onAfterExecute(@Advice.Return @Nullable HttpResponse response
// in case of circular redirect, we get an exception but status code won't be available without response
// thus we have to deal with span outcome directly
if (t instanceof CircularRedirectException) {
- span.withOutcome(Outcome.FAILURE);
+ span.withOutcome(DefaultOutcome.FAILURE);
}
span.deactivate().end();
diff --git a/apm-agent-plugins/apm-apache-httpclient/apm-apache-httpclient4-plugin/src/main/java/co/elastic/apm/agent/httpclient/v4/helper/ApacheHttpAsyncClientHelper.java b/apm-agent-plugins/apm-apache-httpclient/apm-apache-httpclient4-plugin/src/main/java/co/elastic/apm/agent/httpclient/v4/helper/ApacheHttpAsyncClientHelper.java
index 39dd0b4b5cd..6d21c5b46a5 100644
--- a/apm-agent-plugins/apm-apache-httpclient/apm-apache-httpclient4-plugin/src/main/java/co/elastic/apm/agent/httpclient/v4/helper/ApacheHttpAsyncClientHelper.java
+++ b/apm-agent-plugins/apm-apache-httpclient/apm-apache-httpclient4-plugin/src/main/java/co/elastic/apm/agent/httpclient/v4/helper/ApacheHttpAsyncClientHelper.java
@@ -18,12 +18,7 @@
*/
package co.elastic.apm.agent.httpclient.v4.helper;
-import co.elastic.apm.agent.impl.GlobalTracer;
-import co.elastic.apm.agent.impl.transaction.AbstractSpan;
-import co.elastic.apm.agent.impl.transaction.Span;
-import co.elastic.apm.agent.objectpool.Allocator;
-import co.elastic.apm.agent.objectpool.ObjectPool;
-import co.elastic.apm.agent.objectpool.ObjectPoolFactory;
+import co.elastic.apm.plugin.spi.*;
import org.apache.http.concurrent.FutureCallback;
import org.apache.http.nio.protocol.HttpAsyncRequestProducer;
import org.apache.http.protocol.HttpContext;
@@ -53,16 +48,17 @@ public HttpAsyncRequestProducerWrapper createInstance() {
private class FutureCallbackWrapperAllocator implements Allocator> {
@Override
public FutureCallbackWrapper> createInstance() {
- return new FutureCallbackWrapper(ApacheHttpAsyncClientHelper.this);
+ return new FutureCallbackWrapper(ApacheHttpAsyncClientHelper.this);
}
}
- public HttpAsyncRequestProducer wrapRequestProducer(HttpAsyncRequestProducer requestProducer, @Nullable Span span,
+ public HttpAsyncRequestProducer wrapRequestProducer(HttpAsyncRequestProducer requestProducer, @Nullable Span> span,
@Nullable AbstractSpan> parent) {
return requestProducerWrapperObjectPool.createInstance().with(requestProducer, span, parent);
}
- public FutureCallback wrapFutureCallback(FutureCallback futureCallback, HttpContext context, Span span) {
+ @SuppressWarnings("unchecked")
+ public FutureCallback wrapFutureCallback(FutureCallback futureCallback, HttpContext context, Span> span) {
return ((FutureCallbackWrapper) futureCallbackWrapperObjectPool.createInstance()).with(futureCallback, context, span);
}
diff --git a/apm-agent-plugins/apm-apache-httpclient/apm-apache-httpclient4-plugin/src/main/java/co/elastic/apm/agent/httpclient/v4/helper/FutureCallbackWrapper.java b/apm-agent-plugins/apm-apache-httpclient/apm-apache-httpclient4-plugin/src/main/java/co/elastic/apm/agent/httpclient/v4/helper/FutureCallbackWrapper.java
index ab3bc52b5ca..1c4f16eb676 100644
--- a/apm-agent-plugins/apm-apache-httpclient/apm-apache-httpclient4-plugin/src/main/java/co/elastic/apm/agent/httpclient/v4/helper/FutureCallbackWrapper.java
+++ b/apm-agent-plugins/apm-apache-httpclient/apm-apache-httpclient4-plugin/src/main/java/co/elastic/apm/agent/httpclient/v4/helper/FutureCallbackWrapper.java
@@ -18,8 +18,8 @@
*/
package co.elastic.apm.agent.httpclient.v4.helper;
-import co.elastic.apm.agent.impl.transaction.Outcome;
-import co.elastic.apm.agent.impl.transaction.Span;
+import co.elastic.apm.plugin.spi.DefaultOutcome;
+import co.elastic.apm.plugin.spi.Span;
import co.elastic.apm.agent.objectpool.Recyclable;
import org.apache.http.HttpResponse;
import org.apache.http.StatusLine;
@@ -35,13 +35,13 @@ class FutureCallbackWrapper implements FutureCallback, Recyclable {
private FutureCallback delegate;
@Nullable
private HttpContext context;
- private volatile Span span;
+ private volatile Span> span;
FutureCallbackWrapper(ApacheHttpAsyncClientHelper helper) {
this.helper = helper;
}
- FutureCallbackWrapper with(@Nullable FutureCallback delegate, @Nullable HttpContext context, Span span) {
+ FutureCallbackWrapper with(@Nullable FutureCallback delegate, @Nullable HttpContext context, Span> span) {
this.delegate = delegate;
this.context = context;
// write to volatile field last
@@ -87,7 +87,7 @@ public void cancelled() {
private void finishSpan(@Nullable Exception e) {
// start by reading the volatile field
- final Span localSpan = span;
+ final Span> localSpan = span;
try {
if (context != null) {
Object responseObject = context.getAttribute(HttpCoreContext.HTTP_RESPONSE);
@@ -101,7 +101,7 @@ private void finishSpan(@Nullable Exception e) {
localSpan.captureException(e);
if (e != null) {
- localSpan.withOutcome(Outcome.FAILURE);
+ localSpan.withOutcome(DefaultOutcome.FAILURE);
}
} finally {
localSpan.end();
diff --git a/apm-agent-plugins/apm-apache-httpclient/apm-apache-httpclient4-plugin/src/main/java/co/elastic/apm/agent/httpclient/v4/helper/HttpAsyncRequestProducerWrapper.java b/apm-agent-plugins/apm-apache-httpclient/apm-apache-httpclient4-plugin/src/main/java/co/elastic/apm/agent/httpclient/v4/helper/HttpAsyncRequestProducerWrapper.java
index 6fd26c169b3..754e9158105 100644
--- a/apm-agent-plugins/apm-apache-httpclient/apm-apache-httpclient4-plugin/src/main/java/co/elastic/apm/agent/httpclient/v4/helper/HttpAsyncRequestProducerWrapper.java
+++ b/apm-agent-plugins/apm-apache-httpclient/apm-apache-httpclient4-plugin/src/main/java/co/elastic/apm/agent/httpclient/v4/helper/HttpAsyncRequestProducerWrapper.java
@@ -19,10 +19,10 @@
package co.elastic.apm.agent.httpclient.v4.helper;
import co.elastic.apm.agent.httpclient.HttpClientHelper;
-import co.elastic.apm.agent.impl.transaction.AbstractSpan;
-import co.elastic.apm.agent.impl.transaction.Span;
-import co.elastic.apm.agent.impl.transaction.TraceContext;
+import co.elastic.apm.plugin.spi.AbstractSpan;
+import co.elastic.apm.plugin.spi.Span;
import co.elastic.apm.agent.objectpool.Recyclable;
+import co.elastic.apm.plugin.spi.TraceContextUtil;
import org.apache.http.HttpException;
import org.apache.http.HttpHost;
import org.apache.http.HttpRequest;
@@ -43,7 +43,7 @@ class HttpAsyncRequestProducerWrapper implements HttpAsyncRequestProducer, Recyc
private AbstractSpan> parent;
@Nullable
- private Span span;
+ private Span> span;
HttpAsyncRequestProducerWrapper(ApacheHttpAsyncClientHelper helper) {
this.asyncClientHelper = helper;
@@ -61,7 +61,7 @@ class HttpAsyncRequestProducerWrapper implements HttpAsyncRequestProducer, Recyc
* @param parent the active span when this method is called
* @return the {@link HttpAsyncRequestProducer} wrapper
*/
- public HttpAsyncRequestProducerWrapper with(HttpAsyncRequestProducer delegate, @Nullable Span span,
+ public HttpAsyncRequestProducerWrapper with(HttpAsyncRequestProducer delegate, @Nullable Span> span,
@Nullable AbstractSpan> parent) {
// Order is important due to visibility - write to delegate last on this (initiating) thread
this.span = span;
@@ -95,7 +95,7 @@ public HttpRequest generateRequest() throws IOException, HttpException {
}
}
- if (!TraceContext.containsTraceContextTextHeaders(request, RequestHeaderAccessor.INSTANCE)) {
+ if (!TraceContextUtil.containsTraceContextTextHeaders(request, RequestHeaderAccessor.INSTANCE)) {
if (span != null) {
span.propagateTraceContext(request, RequestHeaderAccessor.INSTANCE);
} else if (parent != null) {
diff --git a/apm-agent-plugins/apm-apache-httpclient/apm-apache-httpclient4-plugin/src/main/java/co/elastic/apm/agent/httpclient/v4/helper/RequestHeaderAccessor.java b/apm-agent-plugins/apm-apache-httpclient/apm-apache-httpclient4-plugin/src/main/java/co/elastic/apm/agent/httpclient/v4/helper/RequestHeaderAccessor.java
index e9ed30b0f56..f8477bb22b4 100644
--- a/apm-agent-plugins/apm-apache-httpclient/apm-apache-httpclient4-plugin/src/main/java/co/elastic/apm/agent/httpclient/v4/helper/RequestHeaderAccessor.java
+++ b/apm-agent-plugins/apm-apache-httpclient/apm-apache-httpclient4-plugin/src/main/java/co/elastic/apm/agent/httpclient/v4/helper/RequestHeaderAccessor.java
@@ -18,8 +18,8 @@
*/
package co.elastic.apm.agent.httpclient.v4.helper;
-import co.elastic.apm.agent.impl.transaction.TextHeaderGetter;
-import co.elastic.apm.agent.impl.transaction.TextHeaderSetter;
+import co.elastic.apm.plugin.spi.TextHeaderGetter;
+import co.elastic.apm.plugin.spi.TextHeaderSetter;
import org.apache.http.Header;
import org.apache.http.HttpRequest;
diff --git a/apm-agent-plugins/apm-api-plugin/src/main/java/co/elastic/apm/agent/pluginapi/AbstractSpanInstrumentation.java b/apm-agent-plugins/apm-api-plugin/src/main/java/co/elastic/apm/agent/pluginapi/AbstractSpanInstrumentation.java
index ea2388148f1..005aadcecfd 100644
--- a/apm-agent-plugins/apm-api-plugin/src/main/java/co/elastic/apm/agent/pluginapi/AbstractSpanInstrumentation.java
+++ b/apm-agent-plugins/apm-api-plugin/src/main/java/co/elastic/apm/agent/pluginapi/AbstractSpanInstrumentation.java
@@ -32,7 +32,7 @@
import javax.annotation.Nullable;
import java.lang.invoke.MethodHandle;
-import static co.elastic.apm.agent.impl.transaction.AbstractSpan.PRIO_USER_SUPPLIED;
+import static co.elastic.apm.plugin.spi.AbstractSpan.PRIO_USER_SUPPLIED;
import static net.bytebuddy.matcher.ElementMatchers.named;
import static net.bytebuddy.matcher.ElementMatchers.returns;
import static net.bytebuddy.matcher.ElementMatchers.takesArgument;
diff --git a/apm-agent-plugins/apm-api-plugin/src/main/java/co/elastic/apm/agent/pluginapi/ApiScopeInstrumentation.java b/apm-agent-plugins/apm-api-plugin/src/main/java/co/elastic/apm/agent/pluginapi/ApiScopeInstrumentation.java
index 1a3c167bf99..c254d918779 100644
--- a/apm-agent-plugins/apm-api-plugin/src/main/java/co/elastic/apm/agent/pluginapi/ApiScopeInstrumentation.java
+++ b/apm-agent-plugins/apm-api-plugin/src/main/java/co/elastic/apm/agent/pluginapi/ApiScopeInstrumentation.java
@@ -18,7 +18,7 @@
*/
package co.elastic.apm.agent.pluginapi;
-import co.elastic.apm.agent.impl.transaction.AbstractSpan;
+import co.elastic.apm.plugin.spi.AbstractSpan;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription;
diff --git a/apm-agent-plugins/apm-api-plugin/src/main/java/co/elastic/apm/agent/pluginapi/CaptureSpanInstrumentation.java b/apm-agent-plugins/apm-api-plugin/src/main/java/co/elastic/apm/agent/pluginapi/CaptureSpanInstrumentation.java
index acd6ad0e2c2..faa7ada6120 100644
--- a/apm-agent-plugins/apm-api-plugin/src/main/java/co/elastic/apm/agent/pluginapi/CaptureSpanInstrumentation.java
+++ b/apm-agent-plugins/apm-api-plugin/src/main/java/co/elastic/apm/agent/pluginapi/CaptureSpanInstrumentation.java
@@ -24,9 +24,9 @@
import co.elastic.apm.agent.configuration.CoreConfiguration;
import co.elastic.apm.agent.impl.ElasticApmTracer;
import co.elastic.apm.agent.impl.stacktrace.StacktraceConfiguration;
-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.plugin.spi.AbstractSpan;
+import co.elastic.apm.plugin.spi.DefaultOutcome;
+import co.elastic.apm.plugin.spi.Span;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.NamedElement;
import net.bytebuddy.description.method.MethodDescription;
@@ -40,7 +40,6 @@
import java.util.Arrays;
import java.util.Collection;
-import static co.elastic.apm.agent.bci.bytebuddy.CustomElementMatchers.classLoaderCanLoadClass;
import static co.elastic.apm.agent.bci.bytebuddy.CustomElementMatchers.isInAnyPackage;
import static co.elastic.apm.agent.bci.bytebuddy.CustomElementMatchers.isProxy;
import static co.elastic.apm.agent.bci.bytebuddy.CustomElementMatchers.overridesOrImplementsMethodThat;
@@ -78,7 +77,7 @@ public static Object onMethodEnter(
) {
final AbstractSpan> parent = tracer.getActive();
if (parent != null) {
- Span span = parent.createSpan()
+ Span> span = parent.createSpan()
.withName(spanName.isEmpty() ? signature : spanName)
.activate();
span.setType(type, subtype, action);
@@ -95,10 +94,10 @@ public static Object onMethodEnter(
@Advice.OnMethodExit(suppress = Throwable.class, onThrowable = Throwable.class, inline = false)
public static void onMethodExit(@Advice.Enter @Nullable Object span,
@Advice.Thrown @Nullable Throwable t) {
- if (span instanceof Span) {
- ((Span) span)
+ if (span instanceof Span>) {
+ ((Span>) span)
.captureException(t)
- .withOutcome(t != null ? Outcome.FAILURE : Outcome.SUCCESS)
+ .withOutcome(t != null ? DefaultOutcome.FAILURE : DefaultOutcome.SUCCESS)
.deactivate()
.end();
}
diff --git a/apm-agent-plugins/apm-api-plugin/src/main/java/co/elastic/apm/agent/pluginapi/CaptureTransactionInstrumentation.java b/apm-agent-plugins/apm-api-plugin/src/main/java/co/elastic/apm/agent/pluginapi/CaptureTransactionInstrumentation.java
index 8f2e9cdeff3..cd84b9d23cb 100644
--- a/apm-agent-plugins/apm-api-plugin/src/main/java/co/elastic/apm/agent/pluginapi/CaptureTransactionInstrumentation.java
+++ b/apm-agent-plugins/apm-api-plugin/src/main/java/co/elastic/apm/agent/pluginapi/CaptureTransactionInstrumentation.java
@@ -24,8 +24,8 @@
import co.elastic.apm.agent.configuration.CoreConfiguration;
import co.elastic.apm.agent.impl.ElasticApmTracer;
import co.elastic.apm.agent.impl.stacktrace.StacktraceConfiguration;
-import co.elastic.apm.agent.impl.transaction.Outcome;
-import co.elastic.apm.agent.impl.transaction.Transaction;
+import co.elastic.apm.plugin.spi.DefaultOutcome;
+import co.elastic.apm.plugin.spi.Transaction;
import co.elastic.apm.agent.util.PrivilegedActionUtils;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.NamedElement;
@@ -44,8 +44,8 @@
import static co.elastic.apm.agent.bci.bytebuddy.CustomElementMatchers.isInAnyPackage;
import static co.elastic.apm.agent.bci.bytebuddy.CustomElementMatchers.isProxy;
import static co.elastic.apm.agent.bci.bytebuddy.CustomElementMatchers.overridesOrImplementsMethodThat;
-import static co.elastic.apm.agent.impl.transaction.AbstractSpan.PRIO_METHOD_SIGNATURE;
-import static co.elastic.apm.agent.impl.transaction.AbstractSpan.PRIO_USER_SUPPLIED;
+import static co.elastic.apm.plugin.spi.AbstractSpan.PRIO_METHOD_SIGNATURE;
+import static co.elastic.apm.plugin.spi.AbstractSpan.PRIO_USER_SUPPLIED;
import static co.elastic.apm.agent.pluginapi.ElasticApmApiInstrumentation.PUBLIC_API_INSTRUMENTATION_GROUP;
import static co.elastic.apm.agent.pluginapi.Utils.FRAMEWORK_NAME;
import static net.bytebuddy.matcher.ElementMatchers.declaresMethod;
@@ -74,7 +74,7 @@ public static Object onMethodEnter(@Advice.Origin Class> clazz,
@AnnotationValueExtractor(annotationClassName = "co.elastic.apm.api.CaptureTransaction", method = "type") String type) {
final Object active = tracer.getActive();
if (active == null) {
- Transaction transaction = tracer.startRootTransaction(PrivilegedActionUtils.getClassLoader(clazz));
+ Transaction> transaction = tracer.startRootTransaction(PrivilegedActionUtils.getClassLoader(clazz));
if (transaction != null) {
if (transactionName.isEmpty()) {
transaction.withName(signature, PRIO_METHOD_SIGNATURE);
@@ -95,10 +95,10 @@ public static Object onMethodEnter(@Advice.Origin Class> clazz,
@Advice.OnMethodExit(suppress = Throwable.class, onThrowable = Throwable.class, inline = false)
public static void onMethodExit(@Advice.Enter @Nullable Object transaction,
@Advice.Thrown @Nullable Throwable t) {
- if (transaction instanceof Transaction) {
- ((Transaction) transaction)
+ if (transaction instanceof Transaction>) {
+ ((Transaction>) transaction)
.captureException(t)
- .withOutcome(t != null ? Outcome.FAILURE : Outcome.SUCCESS)
+ .withOutcome(t != null ? DefaultOutcome.FAILURE : DefaultOutcome.SUCCESS)
.deactivate()
.end();
}
diff --git a/apm-agent-plugins/apm-api-plugin/src/main/java/co/elastic/apm/agent/pluginapi/ElasticApmApiInstrumentation.java b/apm-agent-plugins/apm-api-plugin/src/main/java/co/elastic/apm/agent/pluginapi/ElasticApmApiInstrumentation.java
index c7cb07f4be3..cadd5db137f 100644
--- a/apm-agent-plugins/apm-api-plugin/src/main/java/co/elastic/apm/agent/pluginapi/ElasticApmApiInstrumentation.java
+++ b/apm-agent-plugins/apm-api-plugin/src/main/java/co/elastic/apm/agent/pluginapi/ElasticApmApiInstrumentation.java
@@ -19,7 +19,7 @@
package co.elastic.apm.agent.pluginapi;
import co.elastic.apm.agent.configuration.ServiceInfo;
-import co.elastic.apm.agent.impl.transaction.Transaction;
+import co.elastic.apm.plugin.spi.Transaction;
import co.elastic.apm.agent.util.PrivilegedActionUtils;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.method.MethodDescription;
diff --git a/apm-agent-plugins/apm-api-plugin/src/main/java/co/elastic/apm/agent/pluginapi/HeaderExtractorBridge.java b/apm-agent-plugins/apm-api-plugin/src/main/java/co/elastic/apm/agent/pluginapi/HeaderExtractorBridge.java
index fb86e718e2f..6fc9b6c3de8 100644
--- a/apm-agent-plugins/apm-api-plugin/src/main/java/co/elastic/apm/agent/pluginapi/HeaderExtractorBridge.java
+++ b/apm-agent-plugins/apm-api-plugin/src/main/java/co/elastic/apm/agent/pluginapi/HeaderExtractorBridge.java
@@ -18,8 +18,8 @@
*/
package co.elastic.apm.agent.pluginapi;
-import co.elastic.apm.agent.impl.transaction.AbstractHeaderGetter;
-import co.elastic.apm.agent.impl.transaction.TextHeaderGetter;
+import co.elastic.apm.plugin.spi.AbstractHeaderGetter;
+import co.elastic.apm.plugin.spi.TextHeaderGetter;
import co.elastic.apm.agent.sdk.logging.Logger;
import co.elastic.apm.agent.sdk.logging.LoggerFactory;
diff --git a/apm-agent-plugins/apm-api-plugin/src/main/java/co/elastic/apm/agent/pluginapi/HeaderInjectorBridge.java b/apm-agent-plugins/apm-api-plugin/src/main/java/co/elastic/apm/agent/pluginapi/HeaderInjectorBridge.java
index 251341c8a70..78402a0fa8c 100644
--- a/apm-agent-plugins/apm-api-plugin/src/main/java/co/elastic/apm/agent/pluginapi/HeaderInjectorBridge.java
+++ b/apm-agent-plugins/apm-api-plugin/src/main/java/co/elastic/apm/agent/pluginapi/HeaderInjectorBridge.java
@@ -18,7 +18,7 @@
*/
package co.elastic.apm.agent.pluginapi;
-import co.elastic.apm.agent.impl.transaction.TextHeaderSetter;
+import co.elastic.apm.plugin.spi.TextHeaderSetter;
import co.elastic.apm.agent.sdk.logging.Logger;
import co.elastic.apm.agent.sdk.logging.LoggerFactory;
diff --git a/apm-agent-plugins/apm-api-plugin/src/main/java/co/elastic/apm/agent/pluginapi/HeadersExtractorBridge.java b/apm-agent-plugins/apm-api-plugin/src/main/java/co/elastic/apm/agent/pluginapi/HeadersExtractorBridge.java
index 2948febeed5..0b534d45923 100644
--- a/apm-agent-plugins/apm-api-plugin/src/main/java/co/elastic/apm/agent/pluginapi/HeadersExtractorBridge.java
+++ b/apm-agent-plugins/apm-api-plugin/src/main/java/co/elastic/apm/agent/pluginapi/HeadersExtractorBridge.java
@@ -18,7 +18,7 @@
*/
package co.elastic.apm.agent.pluginapi;
-import co.elastic.apm.agent.impl.transaction.TextHeaderGetter;
+import co.elastic.apm.plugin.spi.TextHeaderGetter;
import co.elastic.apm.agent.sdk.logging.Logger;
import co.elastic.apm.agent.sdk.logging.LoggerFactory;
diff --git a/apm-agent-plugins/apm-api-plugin/src/main/java/co/elastic/apm/agent/pluginapi/LegacySpanInstrumentation.java b/apm-agent-plugins/apm-api-plugin/src/main/java/co/elastic/apm/agent/pluginapi/LegacySpanInstrumentation.java
index f2833632c10..e1b71b2e73e 100644
--- a/apm-agent-plugins/apm-api-plugin/src/main/java/co/elastic/apm/agent/pluginapi/LegacySpanInstrumentation.java
+++ b/apm-agent-plugins/apm-api-plugin/src/main/java/co/elastic/apm/agent/pluginapi/LegacySpanInstrumentation.java
@@ -28,7 +28,7 @@
import javax.annotation.Nullable;
-import static co.elastic.apm.agent.impl.transaction.AbstractSpan.PRIO_USER_SUPPLIED;
+import static co.elastic.apm.plugin.spi.AbstractSpan.PRIO_USER_SUPPLIED;
import static net.bytebuddy.matcher.ElementMatchers.hasSuperType;
import static net.bytebuddy.matcher.ElementMatchers.named;
import static net.bytebuddy.matcher.ElementMatchers.not;
diff --git a/apm-agent-plugins/apm-api-plugin/src/main/java/co/elastic/apm/agent/pluginapi/TracedInstrumentation.java b/apm-agent-plugins/apm-api-plugin/src/main/java/co/elastic/apm/agent/pluginapi/TracedInstrumentation.java
index 03a822a18c4..5152ed05b08 100644
--- a/apm-agent-plugins/apm-api-plugin/src/main/java/co/elastic/apm/agent/pluginapi/TracedInstrumentation.java
+++ b/apm-agent-plugins/apm-api-plugin/src/main/java/co/elastic/apm/agent/pluginapi/TracedInstrumentation.java
@@ -22,12 +22,8 @@
import co.elastic.apm.agent.bci.bytebuddy.AnnotationValueOffsetMappingFactory;
import co.elastic.apm.agent.bci.bytebuddy.SimpleMethodSignatureOffsetMappingFactory;
import co.elastic.apm.agent.configuration.CoreConfiguration;
-import co.elastic.apm.agent.impl.Tracer;
+import co.elastic.apm.plugin.spi.*;
import co.elastic.apm.agent.impl.stacktrace.StacktraceConfiguration;
-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.impl.transaction.Transaction;
import co.elastic.apm.agent.util.PrivilegedActionUtils;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.NamedElement;
@@ -41,8 +37,8 @@
import java.util.Collection;
import static co.elastic.apm.agent.bci.bytebuddy.CustomElementMatchers.*;
-import static co.elastic.apm.agent.impl.transaction.AbstractSpan.PRIO_METHOD_SIGNATURE;
-import static co.elastic.apm.agent.impl.transaction.AbstractSpan.PRIO_USER_SUPPLIED;
+import static co.elastic.apm.plugin.spi.AbstractSpan.PRIO_METHOD_SIGNATURE;
+import static co.elastic.apm.plugin.spi.AbstractSpan.PRIO_USER_SUPPLIED;
import static co.elastic.apm.agent.pluginapi.ElasticApmApiInstrumentation.PUBLIC_API_INSTRUMENTATION_GROUP;
import static co.elastic.apm.agent.pluginapi.Utils.FRAMEWORK_NAME;
import static net.bytebuddy.matcher.ElementMatchers.*;
@@ -75,7 +71,7 @@ public static Object onMethodEnter(
final AbstractSpan> parent = tracer.getActive();
if (parent != null) {
- Span span = parent.createSpan()
+ Span> span = parent.createSpan()
.withType(type.isEmpty() ? "app" : type)
.withSubtype(subtype)
.withAction(action)
@@ -86,7 +82,7 @@ public static Object onMethodEnter(
return span.activate();
}
- Transaction transaction = tracer.startRootTransaction(PrivilegedActionUtils.getClassLoader(clazz));
+ Transaction> transaction = tracer.startRootTransaction(PrivilegedActionUtils.getClassLoader(clazz));
if (transaction == null) {
return null;
}
@@ -112,7 +108,7 @@ public static void onMethodExit(@Advice.Enter @Nullable Object abstractSpan,
if (abstractSpan instanceof AbstractSpan>) {
((AbstractSpan>) abstractSpan)
.captureException(t)
- .withOutcome(t != null ? Outcome.FAILURE : Outcome.SUCCESS)
+ .withOutcome(t != null ? DefaultOutcome.FAILURE : DefaultOutcome.SUCCESS)
.deactivate()
.end();
}
diff --git a/apm-agent-plugins/apm-api-plugin/src/main/java/co/elastic/apm/agent/pluginapi/TransactionInstrumentation.java b/apm-agent-plugins/apm-api-plugin/src/main/java/co/elastic/apm/agent/pluginapi/TransactionInstrumentation.java
index 766cf743ebe..9f3384feb1b 100644
--- a/apm-agent-plugins/apm-api-plugin/src/main/java/co/elastic/apm/agent/pluginapi/TransactionInstrumentation.java
+++ b/apm-agent-plugins/apm-api-plugin/src/main/java/co/elastic/apm/agent/pluginapi/TransactionInstrumentation.java
@@ -19,9 +19,9 @@
package co.elastic.apm.agent.pluginapi;
import co.elastic.apm.agent.configuration.ServiceInfo;
-import co.elastic.apm.agent.impl.transaction.Id;
-import co.elastic.apm.agent.impl.transaction.TraceContext;
-import co.elastic.apm.agent.impl.transaction.Transaction;
+import co.elastic.apm.plugin.spi.Id;
+import co.elastic.apm.plugin.spi.TraceContext;
+import co.elastic.apm.plugin.spi.Transaction;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription;
@@ -62,8 +62,8 @@ public static class AdviceClass {
@Advice.OnMethodEnter(suppress = Throwable.class, inline = false)
public static void setFrameworkName(@Advice.FieldValue(value = "span", typing = Assigner.Typing.DYNAMIC) Object transaction,
@Advice.Argument(0) String frameworkName) {
- if (transaction instanceof Transaction) {
- ((Transaction) transaction).setUserFrameworkName(frameworkName);
+ if (transaction instanceof Transaction>) {
+ ((Transaction>) transaction).setUserFrameworkName(frameworkName);
}
}
}
@@ -78,8 +78,8 @@ public static class AdviceClass {
@Advice.OnMethodEnter(suppress = Throwable.class, inline = false)
public static void setUser(@Advice.FieldValue(value = "span", typing = Assigner.Typing.DYNAMIC) Object transaction,
@Advice.Argument(0) String id, @Advice.Argument(1) String email, @Advice.Argument(2) String username, @Advice.Argument(value = 3, optional = true) String domain) {
- if (transaction instanceof Transaction) {
- ((Transaction) transaction).setUser(id, email, username, domain);
+ if (transaction instanceof Transaction>) {
+ ((Transaction>) transaction).setUser(id, email, username, domain);
}
}
}
@@ -96,8 +96,8 @@ public static class AdviceClass {
@Advice.OnMethodExit(suppress = Throwable.class, inline = false)
public static String ensureParentId(@Advice.FieldValue(value = "span", typing = Assigner.Typing.DYNAMIC) Object transaction,
@Advice.Return @Nullable String returnValue) {
- if (transaction instanceof Transaction) {
- final TraceContext traceContext = ((Transaction) transaction).getTraceContext();
+ if (transaction instanceof Transaction>) {
+ final TraceContext traceContext = ((Transaction>) transaction).getTraceContext();
Id parentId = traceContext.getParentId();
if (parentId.isEmpty()) {
parentId.setToRandomValue();
@@ -118,8 +118,8 @@ public static class AdviceClass {
@Advice.OnMethodEnter(suppress = Throwable.class, inline = false)
public static void setResult(@Advice.FieldValue(value = "span", typing = Assigner.Typing.DYNAMIC) Object transaction,
@Advice.Argument(0) String result) {
- if (transaction instanceof Transaction) {
- ((Transaction) transaction).withResult(result);
+ if (transaction instanceof Transaction>) {
+ ((Transaction>) transaction).withResult(result);
}
}
}
@@ -135,8 +135,8 @@ public static class AdviceClass {
public static void addCustomContext(@Advice.FieldValue(value = "span", typing = Assigner.Typing.DYNAMIC) Object transactionObj,
@Advice.Argument(0) String key,
@Advice.Argument(1) @Nullable Object value) {
- if (value != null && transactionObj instanceof Transaction) {
- Transaction transaction = (Transaction) transactionObj;
+ if (value != null && transactionObj instanceof Transaction>) {
+ Transaction> transaction = (Transaction>) transactionObj;
if (value instanceof String) {
transaction.addCustomContext(key, (String) value);
} else if (value instanceof Number) {
@@ -158,8 +158,8 @@ public static class AdviceClass {
@Advice.OnMethodEnter(suppress = Throwable.class, inline = false)
public static void setServiceInfo(@Advice.FieldValue(value = "span", typing = Assigner.Typing.DYNAMIC) Object transaction,
@Advice.Argument(0) String serviceName, @Advice.Argument(1) String serviceVersion) {
- if (transaction instanceof Transaction) {
- ((Transaction) transaction).getTraceContext().setServiceInfo(serviceName, serviceVersion);
+ if (transaction instanceof Transaction>) {
+ ((Transaction>) transaction).getTraceContext().setServiceInfo(serviceName, serviceVersion);
}
}
}
@@ -174,10 +174,10 @@ public static class AdviceClass {
@Advice.OnMethodEnter(suppress = Throwable.class, inline = false)
public static void useServiceInfoForClassLoader(@Advice.FieldValue(value = "span", typing = Assigner.Typing.DYNAMIC) Object transaction,
@Advice.Argument(0) ClassLoader classLoader) {
- if (transaction instanceof Transaction) {
+ if (transaction instanceof Transaction>) {
ServiceInfo serviceInfo = tracer.getServiceInfoForClassLoader(classLoader);
if (serviceInfo != null) {
- ((Transaction) transaction).getTraceContext().setServiceInfo(serviceInfo.getServiceName(), serviceInfo.getServiceVersion());
+ ((Transaction>) transaction).getTraceContext().setServiceInfo(serviceInfo.getServiceName(), serviceInfo.getServiceVersion());
}
}
}
diff --git a/apm-agent-plugins/apm-asynchttpclient-plugin/src/main/java/co/elastic/apm/agent/asynchttpclient/AbstractAsyncHttpClientInstrumentation.java b/apm-agent-plugins/apm-asynchttpclient-plugin/src/main/java/co/elastic/apm/agent/asynchttpclient/AbstractAsyncHttpClientInstrumentation.java
index bd7ca07b3d3..6577f9c4471 100644
--- a/apm-agent-plugins/apm-asynchttpclient-plugin/src/main/java/co/elastic/apm/agent/asynchttpclient/AbstractAsyncHttpClientInstrumentation.java
+++ b/apm-agent-plugins/apm-asynchttpclient-plugin/src/main/java/co/elastic/apm/agent/asynchttpclient/AbstractAsyncHttpClientInstrumentation.java
@@ -21,10 +21,7 @@
import co.elastic.apm.agent.bci.TracerAwareInstrumentation;
import co.elastic.apm.agent.collections.WeakConcurrentProviderImpl;
import co.elastic.apm.agent.httpclient.HttpClientHelper;
-import co.elastic.apm.agent.impl.Tracer;
-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.plugin.spi.*;
import co.elastic.apm.agent.sdk.DynamicTransformer;
import co.elastic.apm.agent.sdk.ElasticApmInstrumentation;
import co.elastic.apm.agent.sdk.weakconcurrent.WeakMap;
@@ -55,7 +52,7 @@ public abstract class AbstractAsyncHttpClientInstrumentation extends TracerAware
public static class Helper {
- static final WeakMap, Span> handlerSpanMap = WeakConcurrentProviderImpl.createWeakSpanMap();
+ static final WeakMap, Span>> handlerSpanMap = WeakConcurrentProviderImpl.createWeakSpanMap();
public static final List> ASYNC_HANDLER_INSTRUMENTATIONS = Arrays.>asList(
AsyncHandlerOnCompletedInstrumentation.class,
@@ -65,8 +62,8 @@ public static class Helper {
@Nullable
- static Span removeAndActivateSpan(AsyncHandler> asyncHandler) {
- Span span = handlerSpanMap.remove(asyncHandler);
+ static Span> removeAndActivateSpan(AsyncHandler> asyncHandler) {
+ Span> span = handlerSpanMap.remove(asyncHandler);
if (span != null) {
span.activate();
}
@@ -74,8 +71,8 @@ static Span removeAndActivateSpan(AsyncHandler> asyncHandler) {
}
@Nullable
- static Span getAndActivateSpan(AsyncHandler> asyncHandler) {
- Span span = handlerSpanMap.get(asyncHandler);
+ static Span> getAndActivateSpan(AsyncHandler> asyncHandler) {
+ Span> span = handlerSpanMap.get(asyncHandler);
if (span != null) {
span.activate();
}
@@ -108,7 +105,7 @@ public static Object onBeforeExecute(@Advice.Argument(value = 0) Request request
DynamicTransformer.ensureInstrumented(asyncHandler.getClass(), Helper.ASYNC_HANDLER_INSTRUMENTATIONS);
Uri uri = request.getUri();
- Span span = HttpClientHelper.startHttpClientSpan(parent, request.getMethod(), uri.toUrl(), uri.getScheme(), uri.getHost(), uri.getPort());
+ Span> span = HttpClientHelper.startHttpClientSpan(parent, request.getMethod(), uri.toUrl(), uri.getScheme(), uri.getHost(), uri.getPort());
if (span != null) {
span.activate();
@@ -127,7 +124,7 @@ public static void onAfterExecute(@Advice.Enter @Nullable Object spanObj,
if (spanObj == null) {
return;
}
- Span span = (Span) spanObj;
+ Span> span = (Span>) spanObj;
span.deactivate();
if (t != null) {
Helper.handlerSpanMap.remove(asyncHandler);
@@ -174,7 +171,7 @@ public ElementMatcher super MethodDescription> getMethodMatcher() {
public static class AsyncHandlerOnCompletedInstrumentation extends AbstractAsyncHandlerInstrumentation {
- public AsyncHandlerOnCompletedInstrumentation(Tracer tracer) {
+ public AsyncHandlerOnCompletedInstrumentation() {
super(named("onCompleted").and(takesArguments(0)));
}
@@ -187,7 +184,7 @@ public static Object onMethodEnter(@Advice.This AsyncHandler> asyncHandler) {
@Advice.OnMethodExit(suppress = Throwable.class, inline = false)
public static void onMethodExit(@Nullable @Advice.Enter Object spanObj) {
- Span span = (Span) spanObj;
+ Span> span = (Span>) spanObj;
if (span != null) {
span.end();
span.deactivate();
@@ -198,7 +195,7 @@ public static void onMethodExit(@Nullable @Advice.Enter Object spanObj) {
public static class AsyncHandlerOnThrowableInstrumentation extends AbstractAsyncHandlerInstrumentation {
- public AsyncHandlerOnThrowableInstrumentation(Tracer tracer) {
+ public AsyncHandlerOnThrowableInstrumentation() {
super(named("onThrowable").and(takesArguments(Throwable.class)));
}
@@ -211,10 +208,10 @@ public static Object onMethodEnter(@Advice.This AsyncHandler> asyncHandler) {
@Advice.OnMethodExit(suppress = Throwable.class, inline = false)
public static void onMethodExit(@Nullable @Advice.Enter Object spanObj, @Advice.Argument(0) Throwable t) {
- Span span = (Span) spanObj;
+ Span> span = (Span>) spanObj;
if (span != null) {
if (t instanceof MaxRedirectException) {
- span.withOutcome(Outcome.FAILURE);
+ span.withOutcome(DefaultOutcome.FAILURE);
}
span.captureException(t).end();
span.deactivate();
@@ -225,7 +222,7 @@ public static void onMethodExit(@Nullable @Advice.Enter Object spanObj, @Advice.
public static class AsyncHandlerOnStatusReceivedInstrumentation extends AbstractAsyncHandlerInstrumentation {
- public AsyncHandlerOnStatusReceivedInstrumentation(Tracer tracer) {
+ public AsyncHandlerOnStatusReceivedInstrumentation() {
super(named("onStatusReceived").and(takesArgument(0, named("org.asynchttpclient.HttpResponseStatus"))));
}
@@ -238,7 +235,7 @@ public static Object onMethodEnter(@Advice.This AsyncHandler> asyncHandler) {
@Advice.OnMethodExit(suppress = Throwable.class, inline = false)
public static void onMethodExit(@Nullable @Advice.Enter Object spanObj, @Advice.Argument(0) HttpResponseStatus status) {
- Span span = (Span) spanObj;
+ Span> span = (Span>) spanObj;
if (span != null) {
span.getContext().getHttp().withStatusCode(status.getStatusCode());
span.deactivate();
@@ -249,7 +246,7 @@ public static void onMethodExit(@Nullable @Advice.Enter Object spanObj, @Advice.
public static class StreamedAsyncHandlerOnStreamInstrumentation extends AbstractAsyncHandlerInstrumentation {
- public StreamedAsyncHandlerOnStreamInstrumentation(Tracer tracer) {
+ public StreamedAsyncHandlerOnStreamInstrumentation() {
super(named("onStream").and(takesArgument(0, named("org.reactivestreams.Publisher"))));
}
@@ -262,7 +259,7 @@ public static Object onMethodEnter(@Advice.This AsyncHandler> asyncHandler) {
@Advice.OnMethodExit(suppress = Throwable.class, inline = false)
public static void onMethodExit(@Nullable @Advice.Enter Object spanObj) {
- Span span = (Span) spanObj;
+ Span> span = (Span>) spanObj;
if (span != null) {
span.deactivate();
}
diff --git a/apm-agent-plugins/apm-asynchttpclient-plugin/src/main/java/co/elastic/apm/agent/asynchttpclient/RequestHeaderSetter.java b/apm-agent-plugins/apm-asynchttpclient-plugin/src/main/java/co/elastic/apm/agent/asynchttpclient/RequestHeaderSetter.java
index 522c3875055..437d0a32d81 100644
--- a/apm-agent-plugins/apm-asynchttpclient-plugin/src/main/java/co/elastic/apm/agent/asynchttpclient/RequestHeaderSetter.java
+++ b/apm-agent-plugins/apm-asynchttpclient-plugin/src/main/java/co/elastic/apm/agent/asynchttpclient/RequestHeaderSetter.java
@@ -18,7 +18,7 @@
*/
package co.elastic.apm.agent.asynchttpclient;
-import co.elastic.apm.agent.impl.transaction.TextHeaderSetter;
+import co.elastic.apm.plugin.spi.TextHeaderSetter;
import org.asynchttpclient.Request;
class RequestHeaderSetter implements TextHeaderSetter {
diff --git a/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-1-plugin/src/main/java/co/elastic/apm/agent/awssdk/v1/AmazonHttpClientInstrumentation.java b/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-1-plugin/src/main/java/co/elastic/apm/agent/awssdk/v1/AmazonHttpClientInstrumentation.java
index 9d47c9ec0cc..0ab178ba3dc 100644
--- a/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-1-plugin/src/main/java/co/elastic/apm/agent/awssdk/v1/AmazonHttpClientInstrumentation.java
+++ b/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-1-plugin/src/main/java/co/elastic/apm/agent/awssdk/v1/AmazonHttpClientInstrumentation.java
@@ -24,8 +24,8 @@
import co.elastic.apm.agent.awssdk.v1.helper.S3Helper;
import co.elastic.apm.agent.awssdk.v1.helper.SQSHelper;
import co.elastic.apm.agent.awssdk.v1.helper.SdkV1DataSource;
-import co.elastic.apm.agent.impl.transaction.Outcome;
-import co.elastic.apm.agent.impl.transaction.Span;
+import co.elastic.apm.plugin.spi.DefaultOutcome;
+import co.elastic.apm.plugin.spi.Span;
import com.amazonaws.Request;
import com.amazonaws.handlers.HandlerContextKey;
import com.amazonaws.http.ExecutionContext;
@@ -76,7 +76,7 @@ public static Object enterInvoke(@Advice.Argument(value = 0) Request> request,
return null;
}
- Span span = helper.startSpan(request, request.getEndpoint(), executionContext);
+ Span> span = helper.startSpan(request, request.getEndpoint(), executionContext);
if (span != null) {
span.activate();
@@ -90,14 +90,14 @@ public static Object enterInvoke(@Advice.Argument(value = 0) Request> request,
@Advice.OnMethodExit(suppress = Throwable.class, inline = false, onThrowable = Throwable.class)
public static void exitInvoke(@Nullable @Advice.Enter Object spanObj,
@Nullable @Advice.Thrown Throwable thrown) {
- if (spanObj instanceof Span) {
- Span span = (Span) spanObj;
+ if (spanObj instanceof Span>) {
+ Span> span = (Span>) spanObj;
span.deactivate();
if (thrown != null) {
span.captureException(thrown);
- span.withOutcome(Outcome.FAILURE);
+ span.withOutcome(DefaultOutcome.FAILURE);
} else {
- span.withOutcome(Outcome.SUCCESS);
+ span.withOutcome(DefaultOutcome.SUCCESS);
}
span.end();
diff --git a/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-1-plugin/src/main/java/co/elastic/apm/agent/awssdk/v1/SQSMessageDispatchingInstrumentation.java b/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-1-plugin/src/main/java/co/elastic/apm/agent/awssdk/v1/SQSMessageDispatchingInstrumentation.java
index a32c139647a..4c5e4359ff9 100644
--- a/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-1-plugin/src/main/java/co/elastic/apm/agent/awssdk/v1/SQSMessageDispatchingInstrumentation.java
+++ b/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-1-plugin/src/main/java/co/elastic/apm/agent/awssdk/v1/SQSMessageDispatchingInstrumentation.java
@@ -21,8 +21,8 @@
import co.elastic.apm.agent.awssdk.common.AbstractAwsSdkInstrumentation;
import co.elastic.apm.agent.awssdk.v1.helper.SQSHelper;
import co.elastic.apm.agent.awssdk.v1.helper.SdkV1DataSource;
-import co.elastic.apm.agent.impl.transaction.Outcome;
-import co.elastic.apm.agent.impl.transaction.Span;
+import co.elastic.apm.plugin.spi.DefaultOutcome;
+import co.elastic.apm.plugin.spi.Span;
import co.elastic.apm.agent.sdk.state.CallDepth;
import com.amazonaws.AmazonWebServiceRequest;
import com.amazonaws.services.sqs.model.ReceiveMessageRequest;
@@ -49,14 +49,14 @@ public ElementMatcher super TypeDescription> getTypeMatcher() {
}
protected static void endSpan(@Nullable Object spanObj, @Nullable Throwable thrown) {
- if (spanObj instanceof Span) {
- Span span = (Span) spanObj;
+ if (spanObj instanceof Span>) {
+ Span> span = (Span>) spanObj;
span.deactivate();
if (thrown != null) {
span.captureException(thrown);
- span.withOutcome(Outcome.FAILURE);
+ span.withOutcome(DefaultOutcome.FAILURE);
} else {
- span.withOutcome(Outcome.SUCCESS);
+ span.withOutcome(DefaultOutcome.SUCCESS);
}
span.end();
}
@@ -91,7 +91,7 @@ public static Object enterSendMessage(@Advice.Argument(value = 0) AmazonWebServi
return null;
}
- Span span = SQSHelper.getInstance().createSpan(queueName);
+ Span> span = SQSHelper.getInstance().createSpan(queueName);
if (span != null) {
SQSHelper.getInstance().propagateContext(span, request);
@@ -123,7 +123,7 @@ public static class AdviceClass {
@Advice.OnMethodEnter(suppress = Throwable.class, inline = false)
public static Object enterReceiveMessage(@Advice.Argument(value = 0) ReceiveMessageRequest receiveMessageRequest) {
String queueName = SdkV1DataSource.getInstance().getQueueNameFromQueueUrl(receiveMessageRequest.getQueueUrl());
- Span span = SQSHelper.getInstance().createSpan(queueName);
+ Span> span = SQSHelper.getInstance().createSpan(queueName);
if (span != null) {
span.activate();
@@ -141,8 +141,8 @@ public static ReceiveMessageResult exitReceiveMessage(@Nullable @Advice.Enter Ob
@Advice.Argument(value = 0) ReceiveMessageRequest receiveMessageRequest,
@Advice.Return ReceiveMessageResult result,
@Nullable @Advice.Thrown Throwable thrown) {
- if (spanObj instanceof Span) {
- SQSHelper.getInstance().handleReceivedMessages((Span) spanObj, receiveMessageRequest.getQueueUrl(), result.getMessages());
+ if (spanObj instanceof Span>) {
+ SQSHelper.getInstance().handleReceivedMessages((Span>) spanObj, receiveMessageRequest.getQueueUrl(), result.getMessages());
}
endSpan(spanObj, thrown);
diff --git a/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-1-plugin/src/main/java/co/elastic/apm/agent/awssdk/v1/helper/DynamoDbHelper.java b/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-1-plugin/src/main/java/co/elastic/apm/agent/awssdk/v1/helper/DynamoDbHelper.java
index d7fa48bd2f8..7cbfe0f9acc 100644
--- a/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-1-plugin/src/main/java/co/elastic/apm/agent/awssdk/v1/helper/DynamoDbHelper.java
+++ b/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-1-plugin/src/main/java/co/elastic/apm/agent/awssdk/v1/helper/DynamoDbHelper.java
@@ -19,9 +19,9 @@
package co.elastic.apm.agent.awssdk.v1.helper;
import co.elastic.apm.agent.awssdk.common.AbstractDynamoDBInstrumentationHelper;
-import co.elastic.apm.agent.impl.GlobalTracer;
-import co.elastic.apm.agent.impl.Tracer;
-import co.elastic.apm.agent.impl.transaction.Span;
+import co.elastic.apm.plugin.spi.GlobalTracer;
+import co.elastic.apm.plugin.spi.Tracer;
+import co.elastic.apm.plugin.spi.Span;
import com.amazonaws.AmazonWebServiceRequest;
import com.amazonaws.Request;
import com.amazonaws.http.ExecutionContext;
@@ -43,10 +43,10 @@ public DynamoDbHelper(Tracer tracer) {
@Nullable
@Override
- public Span startSpan(Request> request, URI httpURI, ExecutionContext context) {
+ public Span> startSpan(Request> request, URI httpURI, ExecutionContext context) {
AmazonWebServiceRequest amazonRequest = request.getOriginalRequest();
- Span span = super.startSpan(request, httpURI, context);
+ Span> span = super.startSpan(request, httpURI, context);
if (span != null) {
span.withSync(!isRequestAsync(amazonRequest));
}
diff --git a/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-1-plugin/src/main/java/co/elastic/apm/agent/awssdk/v1/helper/S3Helper.java b/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-1-plugin/src/main/java/co/elastic/apm/agent/awssdk/v1/helper/S3Helper.java
index c44d5a8968d..62b3b499aa5 100644
--- a/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-1-plugin/src/main/java/co/elastic/apm/agent/awssdk/v1/helper/S3Helper.java
+++ b/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-1-plugin/src/main/java/co/elastic/apm/agent/awssdk/v1/helper/S3Helper.java
@@ -19,8 +19,8 @@
package co.elastic.apm.agent.awssdk.v1.helper;
import co.elastic.apm.agent.awssdk.common.AbstractS3InstrumentationHelper;
-import co.elastic.apm.agent.impl.GlobalTracer;
-import co.elastic.apm.agent.impl.Tracer;
+import co.elastic.apm.plugin.spi.GlobalTracer;
+import co.elastic.apm.plugin.spi.Tracer;
import com.amazonaws.Request;
import com.amazonaws.http.ExecutionContext;
diff --git a/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-1-plugin/src/main/java/co/elastic/apm/agent/awssdk/v1/helper/SQSHelper.java b/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-1-plugin/src/main/java/co/elastic/apm/agent/awssdk/v1/helper/SQSHelper.java
index 53856d4817f..b11ac54bbcc 100644
--- a/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-1-plugin/src/main/java/co/elastic/apm/agent/awssdk/v1/helper/SQSHelper.java
+++ b/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-1-plugin/src/main/java/co/elastic/apm/agent/awssdk/v1/helper/SQSHelper.java
@@ -21,11 +21,11 @@
import co.elastic.apm.agent.awssdk.common.AbstractSQSInstrumentationHelper;
import co.elastic.apm.agent.awssdk.v1.helper.sqs.wrapper.ReceiveMessageResultWrapper;
import co.elastic.apm.agent.configuration.CoreConfiguration;
-import co.elastic.apm.agent.impl.GlobalTracer;
-import co.elastic.apm.agent.impl.Tracer;
-import co.elastic.apm.agent.impl.transaction.Span;
-import co.elastic.apm.agent.impl.transaction.TextHeaderSetter;
-import co.elastic.apm.agent.impl.transaction.TraceContext;
+import co.elastic.apm.plugin.spi.GlobalTracer;
+import co.elastic.apm.plugin.spi.Tracer;
+import co.elastic.apm.plugin.spi.Span;
+import co.elastic.apm.plugin.spi.TextHeaderSetter;
+import co.elastic.apm.plugin.spi.TraceContext;
import co.elastic.apm.agent.common.util.WildcardMatcher;
import com.amazonaws.AmazonWebServiceRequest;
import com.amazonaws.Request;
@@ -57,7 +57,7 @@ protected SQSHelper(Tracer tracer) {
}
- public void propagateContext(Span span, AmazonWebServiceRequest request) {
+ public void propagateContext(Span> span, AmazonWebServiceRequest request) {
if (request instanceof SendMessageRequest) {
SendMessageRequest sendMessageRequest = (SendMessageRequest) request;
span.propagateTraceContext(sendMessageRequest.getMessageAttributes(), this);
@@ -127,7 +127,7 @@ protected boolean isReceiveMessageRequest(Request> request) {
}
@Override
- protected void setMessageContext(@Nullable Message sqsMessage, @Nullable String queueName, co.elastic.apm.agent.impl.context.Message message) {
+ protected void setMessageContext(@Nullable Message sqsMessage, @Nullable String queueName, co.elastic.apm.plugin.spi.Message message) {
if (queueName != null) {
message.withQueue(queueName);
}
@@ -164,15 +164,15 @@ protected void setMessageContext(@Nullable Message sqsMessage, @Nullable String
*/
@Nullable
@Override
- public Span startSpan(Request> request, URI httpURI, ExecutionContext context) {
+ public Span> startSpan(Request> request, URI httpURI, ExecutionContext context) {
if (isAlreadyActive(request)) {
- Span activeSpan = tracer.getActiveExitSpan();
+ Span> activeSpan = tracer.getActiveExitSpan();
if (activeSpan != null && SQS_TYPE.equals(activeSpan.getSubtype())) {
enrichSpan(activeSpan, request, request.getEndpoint(), context);
activeSpan.withSync(isRequestSync(request.getOriginalRequest()));
}
} else {
- Span span = super.startSpan(request, request.getEndpoint(), context);
+ Span> span = super.startSpan(request, request.getEndpoint(), context);
if (span != null) {
span.withSync(isRequestSync(request.getOriginalRequest()));
return span;
diff --git a/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-1-plugin/src/main/java/co/elastic/apm/agent/awssdk/v1/helper/sqs/wrapper/MessageIteratorWrapper.java b/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-1-plugin/src/main/java/co/elastic/apm/agent/awssdk/v1/helper/sqs/wrapper/MessageIteratorWrapper.java
index 3b260f6eb4f..799de9e35c3 100644
--- a/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-1-plugin/src/main/java/co/elastic/apm/agent/awssdk/v1/helper/sqs/wrapper/MessageIteratorWrapper.java
+++ b/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-1-plugin/src/main/java/co/elastic/apm/agent/awssdk/v1/helper/sqs/wrapper/MessageIteratorWrapper.java
@@ -20,7 +20,7 @@
import co.elastic.apm.agent.awssdk.common.AbstractMessageIteratorWrapper;
import co.elastic.apm.agent.awssdk.v1.helper.SQSHelper;
-import co.elastic.apm.agent.impl.Tracer;
+import co.elastic.apm.plugin.spi.Tracer;
import com.amazonaws.services.sqs.model.Message;
import java.util.Iterator;
diff --git a/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-1-plugin/src/main/java/co/elastic/apm/agent/awssdk/v1/helper/sqs/wrapper/MessageListWrapper.java b/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-1-plugin/src/main/java/co/elastic/apm/agent/awssdk/v1/helper/sqs/wrapper/MessageListWrapper.java
index f50ac61c279..8cc5b8b576c 100644
--- a/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-1-plugin/src/main/java/co/elastic/apm/agent/awssdk/v1/helper/sqs/wrapper/MessageListWrapper.java
+++ b/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-1-plugin/src/main/java/co/elastic/apm/agent/awssdk/v1/helper/sqs/wrapper/MessageListWrapper.java
@@ -20,7 +20,7 @@
import co.elastic.apm.agent.awssdk.common.AbstractMessageListWrapper;
import co.elastic.apm.agent.awssdk.v1.helper.SQSHelper;
-import co.elastic.apm.agent.impl.Tracer;
+import co.elastic.apm.plugin.spi.Tracer;
import com.amazonaws.services.sqs.model.Message;
import java.util.Iterator;
diff --git a/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-1-plugin/src/main/java/co/elastic/apm/agent/awssdk/v1/helper/sqs/wrapper/ReceiveMessageResultWrapper.java b/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-1-plugin/src/main/java/co/elastic/apm/agent/awssdk/v1/helper/sqs/wrapper/ReceiveMessageResultWrapper.java
index 013a0cf43c3..bb58826a16d 100644
--- a/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-1-plugin/src/main/java/co/elastic/apm/agent/awssdk/v1/helper/sqs/wrapper/ReceiveMessageResultWrapper.java
+++ b/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-1-plugin/src/main/java/co/elastic/apm/agent/awssdk/v1/helper/sqs/wrapper/ReceiveMessageResultWrapper.java
@@ -18,7 +18,7 @@
*/
package co.elastic.apm.agent.awssdk.v1.helper.sqs.wrapper;
-import co.elastic.apm.agent.impl.Tracer;
+import co.elastic.apm.plugin.spi.Tracer;
import com.amazonaws.services.sqs.model.Message;
import com.amazonaws.services.sqs.model.ReceiveMessageResult;
diff --git a/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-2-plugin/src/main/java/co/elastic/apm/agent/awssdk/v2/BaseAsyncClientHandlerInstrumentation.java b/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-2-plugin/src/main/java/co/elastic/apm/agent/awssdk/v2/BaseAsyncClientHandlerInstrumentation.java
index 1d7910d2733..a7429109d80 100644
--- a/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-2-plugin/src/main/java/co/elastic/apm/agent/awssdk/v2/BaseAsyncClientHandlerInstrumentation.java
+++ b/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-2-plugin/src/main/java/co/elastic/apm/agent/awssdk/v2/BaseAsyncClientHandlerInstrumentation.java
@@ -22,7 +22,7 @@
import co.elastic.apm.agent.awssdk.v2.helper.S3Helper;
import co.elastic.apm.agent.awssdk.v2.helper.SQSHelper;
import co.elastic.apm.agent.bci.TracerAwareInstrumentation;
-import co.elastic.apm.agent.impl.transaction.Span;
+import co.elastic.apm.plugin.spi.Span;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription;
@@ -75,7 +75,7 @@ public static TransformingAsyncResponseHandler> enterDoExecute(@Advice.Argumen
String awsService = executionContext.executionAttributes().getAttribute(AwsSignerExecutionAttribute.SERVICE_NAME);
SdkRequest sdkRequest = clientExecutionParams.getInput();
URI uri = clientConfiguration.option(SdkClientOption.ENDPOINT);
- Span span = null;
+ Span> span = null;
if ("S3".equalsIgnoreCase(awsService)) {
span = S3Helper.getInstance().startSpan(sdkRequest, uri, executionContext);
} else if ("DynamoDb".equalsIgnoreCase(awsService)) {
diff --git a/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-2-plugin/src/main/java/co/elastic/apm/agent/awssdk/v2/BaseSyncClientHandlerInstrumentation.java b/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-2-plugin/src/main/java/co/elastic/apm/agent/awssdk/v2/BaseSyncClientHandlerInstrumentation.java
index 8e89e832863..fe411211c5a 100644
--- a/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-2-plugin/src/main/java/co/elastic/apm/agent/awssdk/v2/BaseSyncClientHandlerInstrumentation.java
+++ b/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-2-plugin/src/main/java/co/elastic/apm/agent/awssdk/v2/BaseSyncClientHandlerInstrumentation.java
@@ -24,8 +24,8 @@
import co.elastic.apm.agent.awssdk.v2.helper.sqs.wrapper.MessageListWrapper;
import co.elastic.apm.agent.bci.TracerAwareInstrumentation;
import co.elastic.apm.agent.common.JvmRuntimeInfo;
-import co.elastic.apm.agent.impl.transaction.Outcome;
-import co.elastic.apm.agent.impl.transaction.Span;
+import co.elastic.apm.plugin.spi.DefaultOutcome;
+import co.elastic.apm.plugin.spi.Span;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription;
@@ -84,7 +84,7 @@ public static Object enterDoExecute(@Advice.Argument(value = 0) ClientExecutionP
String awsService = executionContext.executionAttributes().getAttribute(AwsSignerExecutionAttribute.SERVICE_NAME);
SdkRequest sdkRequest = clientExecutionParams.getInput();
URI uri = clientConfiguration.option(SdkClientOption.ENDPOINT);
- Span span = null;
+ Span> span = null;
if ("S3".equalsIgnoreCase(awsService)) {
span = S3Helper.getInstance().startSpan(sdkRequest, uri, executionContext);
} else if ("DynamoDb".equalsIgnoreCase(awsService)) {
@@ -110,8 +110,8 @@ public static void exitDoExecute(@Advice.Argument(value = 0) ClientExecutionPara
@Advice.This Object thiz) {
String awsService = executionContext.executionAttributes().getAttribute(AwsSignerExecutionAttribute.SERVICE_NAME);
SdkRequest sdkRequest = clientExecutionParams.getInput();
- if (spanObj instanceof Span) {
- Span span = (Span) spanObj;
+ if (spanObj instanceof Span>) {
+ Span> span = (Span>) spanObj;
span.deactivate();
if (thrown != null) {
if (JVM_RUNTIME_INFO.isCoretto() && JVM_RUNTIME_INFO.getMajorVersion() > 16) {
@@ -119,9 +119,9 @@ public static void exitDoExecute(@Advice.Argument(value = 0) ClientExecutionPara
} else {
span.captureException(thrown);
}
- span.withOutcome(Outcome.FAILURE);
+ span.withOutcome(DefaultOutcome.FAILURE);
} else {
- span.withOutcome(Outcome.SUCCESS);
+ span.withOutcome(DefaultOutcome.SUCCESS);
}
if ("Sqs".equalsIgnoreCase(awsService) && sdkResponse instanceof SdkResponse) {
diff --git a/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-2-plugin/src/main/java/co/elastic/apm/agent/awssdk/v2/ResponseHandlerWrapper.java b/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-2-plugin/src/main/java/co/elastic/apm/agent/awssdk/v2/ResponseHandlerWrapper.java
index 61fd0eee57e..fa1c2b66361 100644
--- a/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-2-plugin/src/main/java/co/elastic/apm/agent/awssdk/v2/ResponseHandlerWrapper.java
+++ b/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-2-plugin/src/main/java/co/elastic/apm/agent/awssdk/v2/ResponseHandlerWrapper.java
@@ -20,8 +20,8 @@
import co.elastic.apm.agent.awssdk.v2.helper.SQSHelper;
import co.elastic.apm.agent.awssdk.v2.helper.sqs.wrapper.MessageListWrapper;
-import co.elastic.apm.agent.impl.transaction.Outcome;
-import co.elastic.apm.agent.impl.transaction.Span;
+import co.elastic.apm.plugin.spi.DefaultOutcome;
+import co.elastic.apm.plugin.spi.Span;
import org.reactivestreams.Publisher;
import software.amazon.awssdk.core.Response;
import software.amazon.awssdk.core.SdkRequest;
@@ -37,11 +37,11 @@ public class ResponseHandlerWrapper implements TransformingAsyncResponseHandl
private final TransformingAsyncResponseHandler> delegate;
@Nullable
- private final Span span;
+ private final Span> span;
private final SdkRequest sdkRequest;
private final String awsService;
- public ResponseHandlerWrapper(String awsService, TransformingAsyncResponseHandler> delegate, SdkRequest request, @Nullable Span span) {
+ public ResponseHandlerWrapper(String awsService, TransformingAsyncResponseHandler> delegate, SdkRequest request, @Nullable Span> span) {
this.awsService = awsService;
this.delegate = delegate;
this.span = span;
@@ -56,12 +56,12 @@ public CompletableFuture> prepare() {
if (span != null) {
if (t != null) {
span.captureException(t);
- span.withOutcome(Outcome.FAILURE);
+ span.withOutcome(DefaultOutcome.FAILURE);
} else if (r.exception() != null) {
span.captureException(r.exception());
- span.withOutcome(Outcome.FAILURE);
+ span.withOutcome(DefaultOutcome.FAILURE);
} else {
- span.withOutcome(Outcome.SUCCESS);
+ span.withOutcome(DefaultOutcome.SUCCESS);
}
if ("Sqs".equalsIgnoreCase(awsService) && response instanceof SdkResponse) {
@@ -94,7 +94,7 @@ public void onStream(Publisher publisher) {
public void onError(Throwable throwable) {
if (span != null && !span.isFinished()) {
span.captureException(throwable);
- span.withOutcome(Outcome.FAILURE);
+ span.withOutcome(DefaultOutcome.FAILURE);
}
delegate.onError(throwable);
diff --git a/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-2-plugin/src/main/java/co/elastic/apm/agent/awssdk/v2/helper/DynamoDbHelper.java b/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-2-plugin/src/main/java/co/elastic/apm/agent/awssdk/v2/helper/DynamoDbHelper.java
index 214577487d0..54a67028969 100644
--- a/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-2-plugin/src/main/java/co/elastic/apm/agent/awssdk/v2/helper/DynamoDbHelper.java
+++ b/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-2-plugin/src/main/java/co/elastic/apm/agent/awssdk/v2/helper/DynamoDbHelper.java
@@ -19,8 +19,8 @@
package co.elastic.apm.agent.awssdk.v2.helper;
import co.elastic.apm.agent.awssdk.common.AbstractDynamoDBInstrumentationHelper;
-import co.elastic.apm.agent.impl.GlobalTracer;
-import co.elastic.apm.agent.impl.Tracer;
+import co.elastic.apm.plugin.spi.GlobalTracer;
+import co.elastic.apm.plugin.spi.Tracer;
import software.amazon.awssdk.core.SdkRequest;
import software.amazon.awssdk.core.http.ExecutionContext;
diff --git a/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-2-plugin/src/main/java/co/elastic/apm/agent/awssdk/v2/helper/S3Helper.java b/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-2-plugin/src/main/java/co/elastic/apm/agent/awssdk/v2/helper/S3Helper.java
index f805761f048..bcce8b60241 100644
--- a/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-2-plugin/src/main/java/co/elastic/apm/agent/awssdk/v2/helper/S3Helper.java
+++ b/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-2-plugin/src/main/java/co/elastic/apm/agent/awssdk/v2/helper/S3Helper.java
@@ -19,8 +19,8 @@
package co.elastic.apm.agent.awssdk.v2.helper;
import co.elastic.apm.agent.awssdk.common.AbstractS3InstrumentationHelper;
-import co.elastic.apm.agent.impl.GlobalTracer;
-import co.elastic.apm.agent.impl.Tracer;
+import co.elastic.apm.plugin.spi.GlobalTracer;
+import co.elastic.apm.plugin.spi.Tracer;
import software.amazon.awssdk.core.SdkRequest;
import software.amazon.awssdk.core.http.ExecutionContext;
diff --git a/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-2-plugin/src/main/java/co/elastic/apm/agent/awssdk/v2/helper/SQSHelper.java b/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-2-plugin/src/main/java/co/elastic/apm/agent/awssdk/v2/helper/SQSHelper.java
index 917a3bb0e17..6ad1e36f332 100644
--- a/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-2-plugin/src/main/java/co/elastic/apm/agent/awssdk/v2/helper/SQSHelper.java
+++ b/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-2-plugin/src/main/java/co/elastic/apm/agent/awssdk/v2/helper/SQSHelper.java
@@ -19,11 +19,11 @@
package co.elastic.apm.agent.awssdk.v2.helper;
import co.elastic.apm.agent.awssdk.common.AbstractSQSInstrumentationHelper;
-import co.elastic.apm.agent.impl.GlobalTracer;
-import co.elastic.apm.agent.impl.Tracer;
-import co.elastic.apm.agent.impl.transaction.Span;
-import co.elastic.apm.agent.impl.transaction.TextHeaderSetter;
-import co.elastic.apm.agent.impl.transaction.TraceContext;
+import co.elastic.apm.plugin.spi.GlobalTracer;
+import co.elastic.apm.plugin.spi.Tracer;
+import co.elastic.apm.plugin.spi.Span;
+import co.elastic.apm.plugin.spi.TextHeaderSetter;
+import co.elastic.apm.plugin.spi.TraceContext;
import software.amazon.awssdk.core.SdkRequest;
import software.amazon.awssdk.core.SdkResponse;
import software.amazon.awssdk.core.client.handler.ClientExecutionParams;
@@ -57,7 +57,7 @@ public SQSHelper(Tracer tracer) {
super(tracer, SdkV2DataSource.getInstance());
}
- private SdkRequest propagateContext(Span span, SdkRequest sdkRequest) {
+ private SdkRequest propagateContext(Span> span, SdkRequest sdkRequest) {
if (sdkRequest instanceof SendMessageRequest) {
SendMessageRequest sendMessageRequest = (SendMessageRequest) sdkRequest;
Map attributesMap = new HashMap<>(sendMessageRequest.messageAttributes());
@@ -119,7 +119,7 @@ protected boolean isReceiveMessageRequest(SdkRequest request) {
return request instanceof ReceiveMessageRequest;
}
- public void modifyRequestObject(@Nullable Span span, ClientExecutionParams clientExecutionParams, ExecutionContext executionContext) {
+ public void modifyRequestObject(@Nullable Span> span, ClientExecutionParams clientExecutionParams, ExecutionContext executionContext) {
SdkRequest sdkRequest = clientExecutionParams.getInput();
SdkRequest newRequestObj = null;
if (span != null && clientExecutionParams.getOperationName().startsWith("SendMessage")) {
@@ -179,7 +179,7 @@ public void forEach(String headerName, Message message, S state, HeaderConsu
}
}
- public void handleReceivedMessages(Span span, @Nullable SdkRequest sdkRequest, @Nullable SdkResponse sdkResponse) {
+ public void handleReceivedMessages(Span> span, @Nullable SdkRequest sdkRequest, @Nullable SdkResponse sdkResponse) {
if (sdkResponse instanceof ReceiveMessageResponse && sdkRequest instanceof ReceiveMessageRequest) {
SQSHelper.getInstance().handleReceivedMessages(span, ((ReceiveMessageRequest) sdkRequest).queueUrl(), ((ReceiveMessageResponse) sdkResponse).messages());
}
diff --git a/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-2-plugin/src/main/java/co/elastic/apm/agent/awssdk/v2/helper/sqs/wrapper/MessageIteratorWrapper.java b/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-2-plugin/src/main/java/co/elastic/apm/agent/awssdk/v2/helper/sqs/wrapper/MessageIteratorWrapper.java
index 735535eff9c..8e0568d9fa2 100644
--- a/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-2-plugin/src/main/java/co/elastic/apm/agent/awssdk/v2/helper/sqs/wrapper/MessageIteratorWrapper.java
+++ b/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-2-plugin/src/main/java/co/elastic/apm/agent/awssdk/v2/helper/sqs/wrapper/MessageIteratorWrapper.java
@@ -20,7 +20,7 @@
import co.elastic.apm.agent.awssdk.common.AbstractMessageIteratorWrapper;
import co.elastic.apm.agent.awssdk.v2.helper.SQSHelper;
-import co.elastic.apm.agent.impl.Tracer;
+import co.elastic.apm.plugin.spi.Tracer;
import software.amazon.awssdk.services.sqs.model.Message;
import java.util.Iterator;
diff --git a/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-2-plugin/src/main/java/co/elastic/apm/agent/awssdk/v2/helper/sqs/wrapper/MessageListWrapper.java b/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-2-plugin/src/main/java/co/elastic/apm/agent/awssdk/v2/helper/sqs/wrapper/MessageListWrapper.java
index 84073604557..cdc27247cc2 100644
--- a/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-2-plugin/src/main/java/co/elastic/apm/agent/awssdk/v2/helper/sqs/wrapper/MessageListWrapper.java
+++ b/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-2-plugin/src/main/java/co/elastic/apm/agent/awssdk/v2/helper/sqs/wrapper/MessageListWrapper.java
@@ -24,7 +24,7 @@
import co.elastic.apm.agent.awssdk.v2.helper.SdkV2DataSource;
import co.elastic.apm.agent.configuration.MessagingConfiguration;
import co.elastic.apm.agent.common.util.WildcardMatcher;
-import co.elastic.apm.agent.impl.Tracer;
+import co.elastic.apm.plugin.spi.Tracer;
import co.elastic.apm.agent.sdk.state.CallDepth;
import co.elastic.apm.agent.sdk.weakconcurrent.WeakConcurrent;
import co.elastic.apm.agent.sdk.weakconcurrent.WeakMap;
diff --git a/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-common/src/main/java/co/elastic/apm/agent/awssdk/common/AbstractAwsSdkInstrumentationHelper.java b/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-common/src/main/java/co/elastic/apm/agent/awssdk/common/AbstractAwsSdkInstrumentationHelper.java
index daafdbba2a9..61fe6dfbb8c 100644
--- a/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-common/src/main/java/co/elastic/apm/agent/awssdk/common/AbstractAwsSdkInstrumentationHelper.java
+++ b/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-common/src/main/java/co/elastic/apm/agent/awssdk/common/AbstractAwsSdkInstrumentationHelper.java
@@ -18,8 +18,8 @@
*/
package co.elastic.apm.agent.awssdk.common;
-import co.elastic.apm.agent.impl.Tracer;
-import co.elastic.apm.agent.impl.transaction.Span;
+import co.elastic.apm.plugin.spi.Tracer;
+import co.elastic.apm.plugin.spi.Span;
import javax.annotation.Nullable;
import java.net.URI;
@@ -38,9 +38,9 @@ public Tracer getTracer() {
}
@Nullable
- public abstract Span startSpan(R request, URI httpURI, C context);
+ public abstract Span> startSpan(R request, URI httpURI, C context);
- protected void setDestinationContext(Span span, @Nullable URI uri, R sdkRequest, C context, String type, @Nullable String name) {
+ protected void setDestinationContext(Span> span, @Nullable URI uri, R sdkRequest, C context, String type, @Nullable String name) {
if (uri != null) {
span.getContext().getDestination()
.withAddress(uri.getHost())
diff --git a/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-common/src/main/java/co/elastic/apm/agent/awssdk/common/AbstractDynamoDBInstrumentationHelper.java b/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-common/src/main/java/co/elastic/apm/agent/awssdk/common/AbstractDynamoDBInstrumentationHelper.java
index 45fc1768840..76f52b9959a 100644
--- a/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-common/src/main/java/co/elastic/apm/agent/awssdk/common/AbstractDynamoDBInstrumentationHelper.java
+++ b/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-common/src/main/java/co/elastic/apm/agent/awssdk/common/AbstractDynamoDBInstrumentationHelper.java
@@ -18,9 +18,9 @@
*/
package co.elastic.apm.agent.awssdk.common;
-import co.elastic.apm.agent.impl.Tracer;
-import co.elastic.apm.agent.impl.transaction.AbstractSpan;
-import co.elastic.apm.agent.impl.transaction.Span;
+import co.elastic.apm.plugin.spi.Tracer;
+import co.elastic.apm.plugin.spi.AbstractSpan;
+import co.elastic.apm.plugin.spi.Span;
import javax.annotation.Nullable;
import java.net.URI;
@@ -32,7 +32,7 @@ protected AbstractDynamoDBInstrumentationHelper(Tracer tracer, IAwsSdkDataSource
super(tracer, awsSdkDataSource);
}
- public void enrichSpan(Span span, R sdkRequest, URI httpURI, C context) {
+ public void enrichSpan(Span> span, R sdkRequest, URI httpURI, C context) {
String operationName = awsSdkDataSource.getOperationName(sdkRequest, context);
String region = awsSdkDataSource.getRegion(sdkRequest, context);
String tableName = awsSdkDataSource.getFieldValue(IAwsSdkDataSource.TABLE_NAME_FIELD, sdkRequest);
@@ -62,8 +62,8 @@ public void enrichSpan(Span span, R sdkRequest, URI httpURI, C context) {
}
@Nullable
- public Span startSpan(R sdkRequest, URI httpURI, C context) {
- Span span = tracer.createExitChildSpan();
+ public Span> startSpan(R sdkRequest, URI httpURI, C context) {
+ Span> span = tracer.createExitChildSpan();
if (span == null) {
return null;
}
diff --git a/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-common/src/main/java/co/elastic/apm/agent/awssdk/common/AbstractMessageIteratorWrapper.java b/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-common/src/main/java/co/elastic/apm/agent/awssdk/common/AbstractMessageIteratorWrapper.java
index ef905721a66..f63ef9c3a83 100644
--- a/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-common/src/main/java/co/elastic/apm/agent/awssdk/common/AbstractMessageIteratorWrapper.java
+++ b/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-common/src/main/java/co/elastic/apm/agent/awssdk/common/AbstractMessageIteratorWrapper.java
@@ -19,10 +19,10 @@
package co.elastic.apm.agent.awssdk.common;
-import co.elastic.apm.agent.impl.Tracer;
-import co.elastic.apm.agent.impl.transaction.Span;
-import co.elastic.apm.agent.impl.transaction.TextHeaderGetter;
-import co.elastic.apm.agent.impl.transaction.Transaction;
+import co.elastic.apm.plugin.spi.Tracer;
+import co.elastic.apm.plugin.spi.Span;
+import co.elastic.apm.plugin.spi.TextHeaderGetter;
+import co.elastic.apm.plugin.spi.Transaction;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -62,8 +62,8 @@ public boolean hasNext() {
}
@Nullable
- public Transaction endCurrentTransaction() {
- Transaction transaction = null;
+ public Transaction> endCurrentTransaction() {
+ Transaction> transaction = null;
try {
transaction = tracer.currentTransaction();
if (transaction != null && MESSAGING_TYPE.equals(transaction.getType())) {
@@ -77,7 +77,7 @@ public Transaction endCurrentTransaction() {
}
public void endMessageProcessingSpan() {
- Span span = tracer.getActiveSpan();
+ Span> span = tracer.getActiveSpan();
if (span != null
&& span.getType() != null && span.getType().equals(MESSAGING_TYPE)
@@ -89,7 +89,7 @@ public void endMessageProcessingSpan() {
@Override
public Message next() {
- Transaction currentTransaction = endCurrentTransaction();
+ Transaction> currentTransaction = endCurrentTransaction();
Message sqsMessage = delegate.next();
if (currentTransaction == null) {
sqsInstrumentationHelper.startTransactionOnMessage(sqsMessage, queueName, textHeaderGetter);
diff --git a/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-common/src/main/java/co/elastic/apm/agent/awssdk/common/AbstractMessageListWrapper.java b/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-common/src/main/java/co/elastic/apm/agent/awssdk/common/AbstractMessageListWrapper.java
index 4386cbd4cd4..4633ff85972 100644
--- a/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-common/src/main/java/co/elastic/apm/agent/awssdk/common/AbstractMessageListWrapper.java
+++ b/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-common/src/main/java/co/elastic/apm/agent/awssdk/common/AbstractMessageListWrapper.java
@@ -18,8 +18,8 @@
*/
package co.elastic.apm.agent.awssdk.common;
-import co.elastic.apm.agent.impl.Tracer;
-import co.elastic.apm.agent.impl.transaction.TextHeaderGetter;
+import co.elastic.apm.plugin.spi.Tracer;
+import co.elastic.apm.plugin.spi.TextHeaderGetter;
import java.util.Collection;
import java.util.List;
diff --git a/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-common/src/main/java/co/elastic/apm/agent/awssdk/common/AbstractS3InstrumentationHelper.java b/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-common/src/main/java/co/elastic/apm/agent/awssdk/common/AbstractS3InstrumentationHelper.java
index ee79deb71a5..719262e5f99 100644
--- a/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-common/src/main/java/co/elastic/apm/agent/awssdk/common/AbstractS3InstrumentationHelper.java
+++ b/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-common/src/main/java/co/elastic/apm/agent/awssdk/common/AbstractS3InstrumentationHelper.java
@@ -18,9 +18,9 @@
*/
package co.elastic.apm.agent.awssdk.common;
-import co.elastic.apm.agent.impl.Tracer;
-import co.elastic.apm.agent.impl.transaction.AbstractSpan;
-import co.elastic.apm.agent.impl.transaction.Span;
+import co.elastic.apm.plugin.spi.Tracer;
+import co.elastic.apm.plugin.spi.AbstractSpan;
+import co.elastic.apm.plugin.spi.Span;
import javax.annotation.Nullable;
import java.net.URI;
@@ -34,8 +34,8 @@ protected AbstractS3InstrumentationHelper(Tracer tracer, IAwsSdkDataSource
@Nullable
- public Span startSpan(R request, URI httpURI, C context) {
- Span span = tracer.createExitChildSpan();
+ public Span> startSpan(R request, URI httpURI, C context) {
+ Span> span = tracer.createExitChildSpan();
if (span == null) {
return null;
}
diff --git a/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-common/src/main/java/co/elastic/apm/agent/awssdk/common/AbstractSQSInstrumentationHelper.java b/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-common/src/main/java/co/elastic/apm/agent/awssdk/common/AbstractSQSInstrumentationHelper.java
index 2038764d58f..7cfea9a01ca 100644
--- a/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-common/src/main/java/co/elastic/apm/agent/awssdk/common/AbstractSQSInstrumentationHelper.java
+++ b/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-common/src/main/java/co/elastic/apm/agent/awssdk/common/AbstractSQSInstrumentationHelper.java
@@ -21,9 +21,9 @@
import co.elastic.apm.agent.common.util.WildcardMatcher;
import co.elastic.apm.agent.configuration.CoreConfiguration;
import co.elastic.apm.agent.configuration.MessagingConfiguration;
-import co.elastic.apm.agent.impl.Tracer;
-import co.elastic.apm.agent.impl.context.Message;
-import co.elastic.apm.agent.impl.transaction.*;
+import co.elastic.apm.plugin.spi.Tracer;
+import co.elastic.apm.plugin.spi.Message;
+import co.elastic.apm.plugin.spi.*;
import co.elastic.apm.agent.sdk.logging.Logger;
import co.elastic.apm.agent.sdk.logging.LoggerFactory;
import co.elastic.apm.agent.util.PrivilegedActionUtils;
@@ -80,11 +80,11 @@ protected AbstractSQSInstrumentationHelper(Tracer tracer, IAwsSdkDataSource createSpan(@Nullable String queueName) {
if (WildcardMatcher.isAnyMatch(messagingConfiguration.getIgnoreMessageQueues(), queueName)) {
return null;
}
- Span span = tracer.createExitChildSpan();
+ Span> span = tracer.createExitChildSpan();
if (span != null) {
span.withType(MESSAGING_TYPE)
.withSubtype(SQS_TYPE);
@@ -92,7 +92,7 @@ public Span createSpan(@Nullable String queueName) {
return span;
}
- public void enrichSpan(Span span, R request, URI httpURI, C context) {
+ public void enrichSpan(Span> span, R request, URI httpURI, C context) {
String operationName = awsSdkDataSource.getOperationName(request, context);
String queueName = awsSdkDataSource.getFieldValue(IAwsSdkDataSource.QUEUE_NAME_FIELD, request);
@@ -129,11 +129,11 @@ public void enrichSpan(Span span, R request, URI httpURI, C context) {
}
@Nullable
- public Span startSpan(R request, URI httpURI, C context) {
+ public Span> startSpan(R request, URI httpURI, C context) {
AbstractSpan> activeSpan = tracer.getActive();
- if (isReceiveMessageRequest(request) && messagingConfiguration.shouldEndMessagingTransactionOnPoll() && activeSpan instanceof Transaction) {
- Transaction transaction = (Transaction) activeSpan;
+ if (isReceiveMessageRequest(request) && messagingConfiguration.shouldEndMessagingTransactionOnPoll() && activeSpan instanceof Transaction>) {
+ Transaction> transaction = (Transaction>) activeSpan;
if (MESSAGING_TYPE.equals(transaction.getType())) {
transaction.deactivate().end();
return null;
@@ -142,7 +142,7 @@ public Span startSpan(R request, URI httpURI, C context) {
String queueName = awsSdkDataSource.getFieldValue(IAwsSdkDataSource.QUEUE_NAME_FIELD, request);
- Span span = createSpan(queueName);
+ Span> span = createSpan(queueName);
if (span != null) {
enrichSpan(span, request, httpURI, context);
}
@@ -153,7 +153,7 @@ public Span startSpan(R request, URI httpURI, C context) {
public void startTransactionOnMessage(MessageT sqsMessage, String queueName, TextHeaderGetter headerGetter) {
try {
if (!WildcardMatcher.isAnyMatch(messagingConfiguration.getIgnoreMessageQueues(), queueName)) {
- Transaction transaction = tracer.startChildTransaction(sqsMessage, headerGetter, PrivilegedActionUtils.getClassLoader(AbstractSQSInstrumentationHelper.class));
+ Transaction> transaction = tracer.startChildTransaction(sqsMessage, headerGetter, PrivilegedActionUtils.getClassLoader(AbstractSQSInstrumentationHelper.class));
if (transaction != null) {
transaction.withType(MESSAGING_TYPE).withName("SQS RECEIVE from " + queueName).activate();
transaction.setFrameworkName(FRAMEWORK_NAME);
@@ -168,9 +168,9 @@ public void startTransactionOnMessage(MessageT sqsMessage, String queueName, Tex
}
}
- private void addSpanLink(Span span, MessageT sqsMessage, TextHeaderGetter headerGetter) {
+ private void addSpanLink(Span> span, MessageT sqsMessage, TextHeaderGetter headerGetter) {
span.addSpanLink(
- TraceContext.getFromTraceContextTextHeaders(),
+ TraceContextUtil.getFromTraceContextTextHeaders(),
headerGetter,
sqsMessage
);
@@ -205,7 +205,7 @@ protected void setMessageContext(@Nullable MessageT sqsMessage, @Nullable String
}
}
- public void handleReceivedMessages(Span span, String queueUrl, @Nullable List messages) {
+ public void handleReceivedMessages(Span> span, String queueUrl, @Nullable List messages) {
String queueName = awsSdkDataSource.getQueueNameFromQueueUrl(queueUrl);
MessageT singleMessage = null;
if (messages != null) {
diff --git a/apm-agent-plugins/apm-cassandra/apm-cassandra-core-plugin/src/main/java/co/elastic/apm/agent/cassandra/CassandraHelper.java b/apm-agent-plugins/apm-cassandra/apm-cassandra-core-plugin/src/main/java/co/elastic/apm/agent/cassandra/CassandraHelper.java
index fdd67b271ce..95194166b19 100644
--- a/apm-agent-plugins/apm-cassandra/apm-cassandra-core-plugin/src/main/java/co/elastic/apm/agent/cassandra/CassandraHelper.java
+++ b/apm-agent-plugins/apm-cassandra/apm-cassandra-core-plugin/src/main/java/co/elastic/apm/agent/cassandra/CassandraHelper.java
@@ -19,9 +19,9 @@
package co.elastic.apm.agent.cassandra;
import co.elastic.apm.agent.db.signature.SignatureParser;
-import co.elastic.apm.agent.impl.Tracer;
-import co.elastic.apm.agent.impl.transaction.AbstractSpan;
-import co.elastic.apm.agent.impl.transaction.Span;
+import co.elastic.apm.plugin.spi.Tracer;
+import co.elastic.apm.plugin.spi.AbstractSpan;
+import co.elastic.apm.plugin.spi.Span;
import javax.annotation.Nullable;
@@ -35,8 +35,8 @@ public CassandraHelper(Tracer tracer) {
}
@Nullable
- public Span startCassandraSpan(@Nullable String query, boolean preparedStatement, @Nullable String keyspace) {
- Span span = tracer.createExitChildSpan();
+ public Span> startCassandraSpan(@Nullable String query, boolean preparedStatement, @Nullable String keyspace) {
+ Span> span = tracer.createExitChildSpan();
if (span == null) {
return null;
}
diff --git a/apm-agent-plugins/apm-cassandra/apm-cassandra3-plugin/src/main/java/co/elastic/apm/agent/cassandra3/Cassandra3Instrumentation.java b/apm-agent-plugins/apm-cassandra/apm-cassandra3-plugin/src/main/java/co/elastic/apm/agent/cassandra3/Cassandra3Instrumentation.java
index fe439060e99..e1f0f313047 100644
--- a/apm-agent-plugins/apm-cassandra/apm-cassandra3-plugin/src/main/java/co/elastic/apm/agent/cassandra3/Cassandra3Instrumentation.java
+++ b/apm-agent-plugins/apm-cassandra/apm-cassandra3-plugin/src/main/java/co/elastic/apm/agent/cassandra3/Cassandra3Instrumentation.java
@@ -21,9 +21,8 @@
import co.elastic.apm.agent.bci.TracerAwareInstrumentation;
import co.elastic.apm.agent.bci.bytebuddy.CustomElementMatchers;
import co.elastic.apm.agent.cassandra.CassandraHelper;
-import co.elastic.apm.agent.impl.GlobalTracer;
-import co.elastic.apm.agent.impl.context.Destination;
-import co.elastic.apm.agent.impl.transaction.Span;
+import co.elastic.apm.plugin.spi.GlobalTracer;
+import co.elastic.apm.plugin.spi.Span;
import com.datastax.driver.core.BoundStatement;
import com.datastax.driver.core.Host;
import com.datastax.driver.core.ResultSet;
@@ -111,10 +110,10 @@ private static String getQuery(Statement statement) {
public static void onExit(@Advice.Thrown @Nullable Throwable thrown,
@Advice.Return ResultSetFuture result,
@Nullable @Advice.Enter Object spanObj) {
- if (!(spanObj instanceof Span)) {
+ if (!(spanObj instanceof Span>)) {
return;
}
- final Span span = (Span) spanObj;
+ final Span> span = (Span>) spanObj;
span.captureException(thrown).deactivate();
Futures.addCallback(result, new FutureCallback() {
@Override
@@ -137,7 +136,7 @@ public void onFailure(Throwable t) {
}
private interface DestinationAddressSetter {
- void setDestination(Span span, Host host);
+ void setDestination(Span> span, Host host);
class Resolver {
@@ -164,14 +163,14 @@ static DestinationAddressSetter get() {
}
/**
- * References the method {@link Destination#withSocketAddress(java.net.SocketAddress)} that has been introduced in 2.0.2
+ * References the method {@link co.elastic.apm.plugin.spi.Destination#withSocketAddress(java.net.SocketAddress)} that has been introduced in 2.0.2
* We must not reference this class directly to avoid it being loaded which may cause a linkage error.
*/
enum WithSocketAddress implements DestinationAddressSetter {
INSTANCE;
@Override
- public void setDestination(Span span, Host host) {
+ public void setDestination(Span> span, Host host) {
span.getContext().getDestination().withSocketAddress(host.getSocketAddress());
}
}
@@ -180,7 +179,7 @@ enum WithInetAddress implements DestinationAddressSetter {
INSTANCE;
@Override
- public void setDestination(Span span, Host host) {
+ public void setDestination(Span> span, Host host) {
span.getContext().getDestination().withInetAddress(host.getAddress());
}
}
diff --git a/apm-agent-plugins/apm-cassandra/apm-cassandra4-plugin/src/main/java/co/elastic/apm/agent/cassandra4/Cassandra4Instrumentation.java b/apm-agent-plugins/apm-cassandra/apm-cassandra4-plugin/src/main/java/co/elastic/apm/agent/cassandra4/Cassandra4Instrumentation.java
index 9ae0a5c88cc..a8332f0d381 100644
--- a/apm-agent-plugins/apm-cassandra/apm-cassandra4-plugin/src/main/java/co/elastic/apm/agent/cassandra4/Cassandra4Instrumentation.java
+++ b/apm-agent-plugins/apm-cassandra/apm-cassandra4-plugin/src/main/java/co/elastic/apm/agent/cassandra4/Cassandra4Instrumentation.java
@@ -20,8 +20,8 @@
import co.elastic.apm.agent.bci.TracerAwareInstrumentation;
import co.elastic.apm.agent.cassandra.CassandraHelper;
-import co.elastic.apm.agent.impl.GlobalTracer;
-import co.elastic.apm.agent.impl.transaction.Span;
+import co.elastic.apm.plugin.spi.GlobalTracer;
+import co.elastic.apm.plugin.spi.Span;
import com.datastax.oss.driver.api.core.CqlIdentifier;
import com.datastax.oss.driver.api.core.cql.AsyncResultSet;
import com.datastax.oss.driver.api.core.cql.BoundStatement;
@@ -117,10 +117,10 @@ private static String getQuery(Request request) {
public static void onExit(@Advice.Thrown @Nullable Throwable thrown,
@Advice.Return Object result,
@Nullable @Advice.Enter Object spanObj) {
- if (!(spanObj instanceof Span)) {
+ if (!(spanObj instanceof Span>)) {
return;
}
- Span span = (Span) spanObj;
+ Span> span = (Span>) spanObj;
span.captureException(thrown).deactivate();
if (result instanceof ResultSet) {
setDestination(span, ((ResultSet) result).getExecutionInfo());
@@ -137,7 +137,7 @@ public static void onExit(@Advice.Thrown @Nullable Throwable thrown,
}
}
- private static void setDestination(Span span, ExecutionInfo info) {
+ private static void setDestination(Span> span, ExecutionInfo info) {
Node coordinator = info.getCoordinator();
if (coordinator != null) {
span.getContext().getDestination().withSocketAddress(coordinator.getEndPoint().resolve());
diff --git a/apm-agent-plugins/apm-dubbo-plugin/src/main/java/co/elastic/apm/agent/dubbo/AlibabaCallbackHolder.java b/apm-agent-plugins/apm-dubbo-plugin/src/main/java/co/elastic/apm/agent/dubbo/AlibabaCallbackHolder.java
index 264a72a1480..f58dd570b3d 100644
--- a/apm-agent-plugins/apm-dubbo-plugin/src/main/java/co/elastic/apm/agent/dubbo/AlibabaCallbackHolder.java
+++ b/apm-agent-plugins/apm-dubbo-plugin/src/main/java/co/elastic/apm/agent/dubbo/AlibabaCallbackHolder.java
@@ -19,7 +19,7 @@
package co.elastic.apm.agent.dubbo;
import co.elastic.apm.agent.collections.WeakConcurrentProviderImpl;
-import co.elastic.apm.agent.impl.transaction.AbstractSpan;
+import co.elastic.apm.plugin.spi.AbstractSpan;
import co.elastic.apm.agent.sdk.weakconcurrent.WeakMap;
import com.alibaba.dubbo.remoting.exchange.ResponseCallback;
diff --git a/apm-agent-plugins/apm-dubbo-plugin/src/main/java/co/elastic/apm/agent/dubbo/AlibabaResponseCallbackInstrumentation.java b/apm-agent-plugins/apm-dubbo-plugin/src/main/java/co/elastic/apm/agent/dubbo/AlibabaResponseCallbackInstrumentation.java
index 2a73afc86a5..ebd3c149be0 100644
--- a/apm-agent-plugins/apm-dubbo-plugin/src/main/java/co/elastic/apm/agent/dubbo/AlibabaResponseCallbackInstrumentation.java
+++ b/apm-agent-plugins/apm-dubbo-plugin/src/main/java/co/elastic/apm/agent/dubbo/AlibabaResponseCallbackInstrumentation.java
@@ -18,8 +18,8 @@
*/
package co.elastic.apm.agent.dubbo;
-import co.elastic.apm.agent.impl.transaction.AbstractSpan;
-import co.elastic.apm.agent.impl.transaction.Outcome;
+import co.elastic.apm.plugin.spi.AbstractSpan;
+import co.elastic.apm.plugin.spi.DefaultOutcome;
import com.alibaba.dubbo.remoting.exchange.ResponseCallback;
import com.alibaba.dubbo.rpc.Result;
import net.bytebuddy.asm.Advice;
@@ -78,7 +78,7 @@ public static void onExit(@Advice.Thrown @Nullable Throwable thrown,
}
span.captureException(thrown)
.captureException(resultException)
- .withOutcome(thrown != null || resultException != null ? Outcome.FAILURE : Outcome.SUCCESS)
+ .withOutcome(thrown != null || resultException != null ? DefaultOutcome.FAILURE : DefaultOutcome.SUCCESS)
.deactivate()
.end();
}
@@ -116,7 +116,7 @@ public static void onExit(@Advice.Thrown @Nullable Throwable thrown,
}
span.captureException(thrown)
.captureException(caught)
- .withOutcome(caught != null || thrown != null ? Outcome.FAILURE : Outcome.SUCCESS)
+ .withOutcome(caught != null || thrown != null ? DefaultOutcome.FAILURE : DefaultOutcome.SUCCESS)
.deactivate()
.end();
}
diff --git a/apm-agent-plugins/apm-dubbo-plugin/src/main/java/co/elastic/apm/agent/dubbo/AlibabaResponseFutureInstrumentation.java b/apm-agent-plugins/apm-dubbo-plugin/src/main/java/co/elastic/apm/agent/dubbo/AlibabaResponseFutureInstrumentation.java
index 9c86a8bd1d3..8a481295299 100644
--- a/apm-agent-plugins/apm-dubbo-plugin/src/main/java/co/elastic/apm/agent/dubbo/AlibabaResponseFutureInstrumentation.java
+++ b/apm-agent-plugins/apm-dubbo-plugin/src/main/java/co/elastic/apm/agent/dubbo/AlibabaResponseFutureInstrumentation.java
@@ -18,7 +18,7 @@
*/
package co.elastic.apm.agent.dubbo;
-import co.elastic.apm.agent.impl.transaction.AbstractSpan;
+import co.elastic.apm.plugin.spi.AbstractSpan;
import co.elastic.apm.agent.sdk.DynamicTransformer;
import co.elastic.apm.agent.sdk.ElasticApmInstrumentation;
import com.alibaba.dubbo.remoting.exchange.ResponseCallback;
diff --git a/apm-agent-plugins/apm-dubbo-plugin/src/main/java/co/elastic/apm/agent/dubbo/advice/AlibabaMonitorFilterAdvice.java b/apm-agent-plugins/apm-dubbo-plugin/src/main/java/co/elastic/apm/agent/dubbo/advice/AlibabaMonitorFilterAdvice.java
index c451979ef16..861bbf82523 100644
--- a/apm-agent-plugins/apm-dubbo-plugin/src/main/java/co/elastic/apm/agent/dubbo/advice/AlibabaMonitorFilterAdvice.java
+++ b/apm-agent-plugins/apm-dubbo-plugin/src/main/java/co/elastic/apm/agent/dubbo/advice/AlibabaMonitorFilterAdvice.java
@@ -20,12 +20,7 @@
import co.elastic.apm.agent.dubbo.helper.AlibabaDubboTextMapPropagator;
import co.elastic.apm.agent.dubbo.helper.DubboTraceHelper;
-import co.elastic.apm.agent.impl.GlobalTracer;
-import co.elastic.apm.agent.impl.Tracer;
-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.impl.transaction.Transaction;
+import co.elastic.apm.plugin.spi.*;
import co.elastic.apm.agent.util.PrivilegedActionUtils;
import com.alibaba.dubbo.rpc.Invocation;
import com.alibaba.dubbo.rpc.Result;
@@ -46,7 +41,7 @@ public static Object onEnterFilterInvoke(@Advice.Argument(1) Invocation invocati
// for consumer side, just create span, more information will be collected in provider side
AbstractSpan> active = tracer.getActive();
if (context.isConsumerSide() && active != null) {
- Span span = DubboTraceHelper.createConsumerSpan(tracer, invocation.getInvoker().getInterface(),
+ Span> span = DubboTraceHelper.createConsumerSpan(tracer, invocation.getInvoker().getInterface(),
invocation.getMethodName(), context.getRemoteAddress());
if (span != null) {
span.propagateTraceContext(context, AlibabaDubboTextMapPropagator.INSTANCE);
@@ -54,7 +49,7 @@ public static Object onEnterFilterInvoke(@Advice.Argument(1) Invocation invocati
}
} else if (context.isProviderSide() && active == null) {
// for provider side
- Transaction transaction = tracer.startChildTransaction(context, AlibabaDubboTextMapPropagator.INSTANCE, PrivilegedActionUtils.getClassLoader(Invocation.class));
+ Transaction> transaction = tracer.startChildTransaction(context, AlibabaDubboTextMapPropagator.INSTANCE, PrivilegedActionUtils.getClassLoader(Invocation.class));
if (transaction != null) {
transaction.activate();
DubboTraceHelper.fillTransaction(transaction, invocation.getInvoker().getInterface(), invocation.getMethodName());
@@ -81,7 +76,7 @@ public static void onExitFilterInvoke(@Advice.Argument(1) Invocation invocation,
span
.captureException(t)
.captureException(resultException)
- .withOutcome(t != null || resultException != null ? Outcome.FAILURE : Outcome.SUCCESS)
+ .withOutcome(t != null || resultException != null ? DefaultOutcome.FAILURE : DefaultOutcome.SUCCESS)
.deactivate();
if (!(RpcContext.getContext().getFuture() instanceof FutureAdapter)) {
diff --git a/apm-agent-plugins/apm-dubbo-plugin/src/main/java/co/elastic/apm/agent/dubbo/advice/ApacheMonitorFilterAdvice.java b/apm-agent-plugins/apm-dubbo-plugin/src/main/java/co/elastic/apm/agent/dubbo/advice/ApacheMonitorFilterAdvice.java
index 14051bc2143..bdfa1f113ca 100644
--- a/apm-agent-plugins/apm-dubbo-plugin/src/main/java/co/elastic/apm/agent/dubbo/advice/ApacheMonitorFilterAdvice.java
+++ b/apm-agent-plugins/apm-dubbo-plugin/src/main/java/co/elastic/apm/agent/dubbo/advice/ApacheMonitorFilterAdvice.java
@@ -20,12 +20,7 @@
import co.elastic.apm.agent.dubbo.helper.ApacheDubboTextMapPropagator;
import co.elastic.apm.agent.dubbo.helper.DubboTraceHelper;
-import co.elastic.apm.agent.impl.GlobalTracer;
-import co.elastic.apm.agent.impl.Tracer;
-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.impl.transaction.Transaction;
+import co.elastic.apm.plugin.spi.*;
import co.elastic.apm.agent.util.PrivilegedActionUtils;
import net.bytebuddy.asm.Advice;
import org.apache.dubbo.rpc.AsyncRpcResult;
@@ -47,7 +42,7 @@ public static Object onEnterFilterInvoke(@Advice.Argument(1) Invocation invocati
AbstractSpan> active = tracer.getActive();
// for consumer side, just create span, more information will be collected in provider side
if (context.isConsumerSide() && active != null) {
- Span span = DubboTraceHelper.createConsumerSpan(tracer, invocation.getInvoker().getInterface(),
+ Span> span = DubboTraceHelper.createConsumerSpan(tracer, invocation.getInvoker().getInterface(),
invocation.getMethodName(), context.getRemoteAddress());
if (span != null) {
span.propagateTraceContext(context, ApacheDubboTextMapPropagator.INSTANCE);
@@ -55,7 +50,7 @@ public static Object onEnterFilterInvoke(@Advice.Argument(1) Invocation invocati
}
} else if (context.isProviderSide() && active == null) {
// for provider side
- Transaction transaction = tracer.startChildTransaction(context, ApacheDubboTextMapPropagator.INSTANCE, PrivilegedActionUtils.getClassLoader(Invocation.class));
+ Transaction> transaction = tracer.startChildTransaction(context, ApacheDubboTextMapPropagator.INSTANCE, PrivilegedActionUtils.getClassLoader(Invocation.class));
if (transaction != null) {
transaction.activate();
DubboTraceHelper.fillTransaction(transaction, invocation.getInvoker().getInterface(), invocation.getMethodName());
@@ -104,7 +99,7 @@ public void accept(@Nullable Result result, @Nullable Throwable t) {
span.captureException(t)
.captureException(resultException)
- .withOutcome(t != null || resultException != null ? Outcome.FAILURE : Outcome.SUCCESS);
+ .withOutcome(t != null || resultException != null ? DefaultOutcome.FAILURE : DefaultOutcome.SUCCESS);
} finally {
span.end();
}
diff --git a/apm-agent-plugins/apm-dubbo-plugin/src/main/java/co/elastic/apm/agent/dubbo/helper/AlibabaDubboTextMapPropagator.java b/apm-agent-plugins/apm-dubbo-plugin/src/main/java/co/elastic/apm/agent/dubbo/helper/AlibabaDubboTextMapPropagator.java
index 3f62bc36a34..c8e75f04f9d 100644
--- a/apm-agent-plugins/apm-dubbo-plugin/src/main/java/co/elastic/apm/agent/dubbo/helper/AlibabaDubboTextMapPropagator.java
+++ b/apm-agent-plugins/apm-dubbo-plugin/src/main/java/co/elastic/apm/agent/dubbo/helper/AlibabaDubboTextMapPropagator.java
@@ -18,8 +18,8 @@
*/
package co.elastic.apm.agent.dubbo.helper;
-import co.elastic.apm.agent.impl.transaction.TextHeaderGetter;
-import co.elastic.apm.agent.impl.transaction.TextHeaderSetter;
+import co.elastic.apm.plugin.spi.TextHeaderGetter;
+import co.elastic.apm.plugin.spi.TextHeaderSetter;
import com.alibaba.dubbo.rpc.RpcContext;
import javax.annotation.Nullable;
diff --git a/apm-agent-plugins/apm-dubbo-plugin/src/main/java/co/elastic/apm/agent/dubbo/helper/ApacheDubboTextMapPropagator.java b/apm-agent-plugins/apm-dubbo-plugin/src/main/java/co/elastic/apm/agent/dubbo/helper/ApacheDubboTextMapPropagator.java
index 40428337406..de84a37fc80 100644
--- a/apm-agent-plugins/apm-dubbo-plugin/src/main/java/co/elastic/apm/agent/dubbo/helper/ApacheDubboTextMapPropagator.java
+++ b/apm-agent-plugins/apm-dubbo-plugin/src/main/java/co/elastic/apm/agent/dubbo/helper/ApacheDubboTextMapPropagator.java
@@ -18,8 +18,8 @@
*/
package co.elastic.apm.agent.dubbo.helper;
-import co.elastic.apm.agent.impl.transaction.TextHeaderGetter;
-import co.elastic.apm.agent.impl.transaction.TextHeaderSetter;
+import co.elastic.apm.plugin.spi.TextHeaderGetter;
+import co.elastic.apm.plugin.spi.TextHeaderSetter;
import org.apache.dubbo.rpc.RpcContext;
import javax.annotation.Nullable;
diff --git a/apm-agent-plugins/apm-dubbo-plugin/src/main/java/co/elastic/apm/agent/dubbo/helper/DubboTraceHelper.java b/apm-agent-plugins/apm-dubbo-plugin/src/main/java/co/elastic/apm/agent/dubbo/helper/DubboTraceHelper.java
index 9787f9fe303..eb02e9db7b6 100644
--- a/apm-agent-plugins/apm-dubbo-plugin/src/main/java/co/elastic/apm/agent/dubbo/helper/DubboTraceHelper.java
+++ b/apm-agent-plugins/apm-dubbo-plugin/src/main/java/co/elastic/apm/agent/dubbo/helper/DubboTraceHelper.java
@@ -18,11 +18,7 @@
*/
package co.elastic.apm.agent.dubbo.helper;
-import co.elastic.apm.agent.impl.Tracer;
-import co.elastic.apm.agent.impl.context.Destination;
-import co.elastic.apm.agent.impl.transaction.AbstractSpan;
-import co.elastic.apm.agent.impl.transaction.Span;
-import co.elastic.apm.agent.impl.transaction.Transaction;
+import co.elastic.apm.plugin.spi.*;
import javax.annotation.Nullable;
import java.net.InetSocketAddress;
@@ -34,12 +30,12 @@ public class DubboTraceHelper {
public static final String SPAN_KEY = "_elastic_apm_span";
@Nullable
- public static Span createConsumerSpan(Tracer tracer, Class> apiClass, String methodName, InetSocketAddress remoteAddress) {
+ public static Span> createConsumerSpan(Tracer tracer, Class> apiClass, String methodName, InetSocketAddress remoteAddress) {
AbstractSpan> traceContext = tracer.getActive();
if (traceContext == null) {
return null;
}
- Span span = traceContext.createExitSpan();
+ Span> span = traceContext.createExitSpan();
if (span == null) {
return null;
}
@@ -59,7 +55,7 @@ public static Span createConsumerSpan(Tracer tracer, Class> apiClass, String m
return span.activate();
}
- public static void fillTransaction(Transaction transaction, Class> apiClass, String methodName) {
+ public static void fillTransaction(Transaction> transaction, Class> apiClass, String methodName) {
transaction.updateName(apiClass, methodName);
transaction.withType(Transaction.TYPE_REQUEST);
}
diff --git a/apm-agent-plugins/apm-ecs-logging-plugin/src/main/java/co/elastic/apm/agent/ecs_logging/Log4j2ServiceNameInstrumentation.java b/apm-agent-plugins/apm-ecs-logging-plugin/src/main/java/co/elastic/apm/agent/ecs_logging/Log4j2ServiceNameInstrumentation.java
index 3c999803926..d8a079a5fc3 100644
--- a/apm-agent-plugins/apm-ecs-logging-plugin/src/main/java/co/elastic/apm/agent/ecs_logging/Log4j2ServiceNameInstrumentation.java
+++ b/apm-agent-plugins/apm-ecs-logging-plugin/src/main/java/co/elastic/apm/agent/ecs_logging/Log4j2ServiceNameInstrumentation.java
@@ -19,9 +19,9 @@
package co.elastic.apm.agent.ecs_logging;
import co.elastic.apm.agent.configuration.CoreConfiguration;
-import co.elastic.apm.agent.configuration.ServiceInfo;
-import co.elastic.apm.agent.impl.GlobalTracer;
-import co.elastic.apm.agent.impl.Tracer;
+import co.elastic.apm.plugin.spi.GlobalTracer;
+import co.elastic.apm.plugin.spi.ServiceInfo;
+import co.elastic.apm.plugin.spi.Tracer;
import co.elastic.logging.log4j2.EcsLayout;
import net.bytebuddy.asm.Advice;
diff --git a/apm-agent-plugins/apm-ecs-logging-plugin/src/main/java/co/elastic/apm/agent/ecs_logging/Log4j2ServiceVersionInstrumentation.java b/apm-agent-plugins/apm-ecs-logging-plugin/src/main/java/co/elastic/apm/agent/ecs_logging/Log4j2ServiceVersionInstrumentation.java
index bb19d0fd9a0..a0b6e6c35ee 100644
--- a/apm-agent-plugins/apm-ecs-logging-plugin/src/main/java/co/elastic/apm/agent/ecs_logging/Log4j2ServiceVersionInstrumentation.java
+++ b/apm-agent-plugins/apm-ecs-logging-plugin/src/main/java/co/elastic/apm/agent/ecs_logging/Log4j2ServiceVersionInstrumentation.java
@@ -19,9 +19,9 @@
package co.elastic.apm.agent.ecs_logging;
import co.elastic.apm.agent.configuration.CoreConfiguration;
-import co.elastic.apm.agent.configuration.ServiceInfo;
-import co.elastic.apm.agent.impl.GlobalTracer;
-import co.elastic.apm.agent.impl.Tracer;
+import co.elastic.apm.plugin.spi.GlobalTracer;
+import co.elastic.apm.plugin.spi.ServiceInfo;
+import co.elastic.apm.plugin.spi.Tracer;
import co.elastic.logging.log4j2.EcsLayout;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.type.TypeDescription;
diff --git a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-5_6/src/main/java/co/elastic/apm/agent/esrestclient/v5_6/ElasticsearchClientAsyncInstrumentation.java b/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-5_6/src/main/java/co/elastic/apm/agent/esrestclient/v5_6/ElasticsearchClientAsyncInstrumentation.java
index 10b9b54fa5c..2805b8e0f6e 100644
--- a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-5_6/src/main/java/co/elastic/apm/agent/esrestclient/v5_6/ElasticsearchClientAsyncInstrumentation.java
+++ b/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-5_6/src/main/java/co/elastic/apm/agent/esrestclient/v5_6/ElasticsearchClientAsyncInstrumentation.java
@@ -20,7 +20,7 @@
import co.elastic.apm.agent.esrestclient.ElasticsearchRestClientInstrumentation;
import co.elastic.apm.agent.esrestclient.ElasticsearchRestClientInstrumentationHelper;
-import co.elastic.apm.agent.impl.transaction.Span;
+import co.elastic.apm.plugin.spi.Span;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.asm.Advice.AssignReturned.ToArguments.ToArgument;
import net.bytebuddy.description.method.MethodDescription;
@@ -75,7 +75,7 @@ public static Object[] onBeforeExecute(@Advice.Argument(0) String method,
@Advice.Argument(3) @Nullable HttpEntity entity,
@Advice.Argument(5) ResponseListener responseListener) {
- Span span = helper.createClientSpan(method, endpoint, entity);
+ Span> span = helper.createClientSpan(method, endpoint, entity);
if (span != null) {
Object[] ret = new Object[2];
ret[0] = span;
@@ -89,7 +89,7 @@ public static Object[] onBeforeExecute(@Advice.Argument(0) String method,
public static void onAfterExecute(@Advice.Thrown @Nullable Throwable t,
@Advice.Enter @Nullable Object[] entryArgs) {
if (entryArgs != null) {
- final Span span = (Span) entryArgs[0];
+ final Span> span = (Span>) entryArgs[0];
if (span != null) {
// Deactivate in this thread. Span will be ended and reported by the listener
span.deactivate();
diff --git a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-5_6/src/main/java/co/elastic/apm/agent/esrestclient/v5_6/ElasticsearchClientSyncInstrumentation.java b/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-5_6/src/main/java/co/elastic/apm/agent/esrestclient/v5_6/ElasticsearchClientSyncInstrumentation.java
index 3e9dc348625..158d04a0b3a 100644
--- a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-5_6/src/main/java/co/elastic/apm/agent/esrestclient/v5_6/ElasticsearchClientSyncInstrumentation.java
+++ b/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-5_6/src/main/java/co/elastic/apm/agent/esrestclient/v5_6/ElasticsearchClientSyncInstrumentation.java
@@ -20,7 +20,7 @@
import co.elastic.apm.agent.esrestclient.ElasticsearchRestClientInstrumentation;
import co.elastic.apm.agent.esrestclient.ElasticsearchRestClientInstrumentationHelper;
-import co.elastic.apm.agent.impl.transaction.Span;
+import co.elastic.apm.plugin.spi.Span;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription;
@@ -54,7 +54,7 @@ public static Object onBeforeExecute(@Advice.Argument(0) String method,
public static void onAfterExecute(@Advice.Return @Nullable Response response,
@Advice.Enter @Nullable Object spanObj,
@Advice.Thrown @Nullable Throwable t) {
- Span span = (Span) spanObj;
+ Span> span = (Span>) spanObj;
if (span != null) {
try {
helper.finishClientSpan(response, span, t);
diff --git a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-6_4/src/main/java/co/elastic/apm/agent/esrestclient/v6_4/ElasticsearchClientAsyncInstrumentation.java b/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-6_4/src/main/java/co/elastic/apm/agent/esrestclient/v6_4/ElasticsearchClientAsyncInstrumentation.java
index ecefa86231e..139146e03c4 100644
--- a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-6_4/src/main/java/co/elastic/apm/agent/esrestclient/v6_4/ElasticsearchClientAsyncInstrumentation.java
+++ b/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-6_4/src/main/java/co/elastic/apm/agent/esrestclient/v6_4/ElasticsearchClientAsyncInstrumentation.java
@@ -20,7 +20,7 @@
import co.elastic.apm.agent.esrestclient.ElasticsearchRestClientInstrumentation;
import co.elastic.apm.agent.esrestclient.ElasticsearchRestClientInstrumentationHelper;
-import co.elastic.apm.agent.impl.transaction.Span;
+import co.elastic.apm.plugin.spi.Span;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.asm.Advice.AssignReturned.ToArguments.ToArgument;
import net.bytebuddy.description.method.MethodDescription;
@@ -66,7 +66,7 @@ public static class ElasticsearchRestClientAsyncAdvice {
@Advice.OnMethodEnter(suppress = Throwable.class, inline = false)
public static Object[] onBeforeExecute(@Advice.Argument(0) Request request,
@Advice.Argument(1) ResponseListener responseListener) {
- Span span = helper.createClientSpan(request.getMethod(), request.getEndpoint(), request.getEntity());
+ Span> span = helper.createClientSpan(request.getMethod(), request.getEndpoint(), request.getEntity());
if (span != null) {
Object[] ret = new Object[2];
ret[0] = span;
@@ -80,7 +80,7 @@ public static Object[] onBeforeExecute(@Advice.Argument(0) Request request,
public static void onAfterExecute(@Advice.Thrown @Nullable Throwable t,
@Advice.Enter @Nullable Object[] entryArgs) {
if (entryArgs != null) {
- final Span span = (Span) entryArgs[0];
+ final Span> span = (Span>) entryArgs[0];
if (span != null) {
// Deactivate in this thread. Span will be ended and reported by the listener
span.deactivate();
diff --git a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-6_4/src/main/java/co/elastic/apm/agent/esrestclient/v6_4/ElasticsearchClientSyncInstrumentation.java b/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-6_4/src/main/java/co/elastic/apm/agent/esrestclient/v6_4/ElasticsearchClientSyncInstrumentation.java
index b87ec3f5c3f..e44a57a2e21 100644
--- a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-6_4/src/main/java/co/elastic/apm/agent/esrestclient/v6_4/ElasticsearchClientSyncInstrumentation.java
+++ b/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-6_4/src/main/java/co/elastic/apm/agent/esrestclient/v6_4/ElasticsearchClientSyncInstrumentation.java
@@ -20,7 +20,7 @@
import co.elastic.apm.agent.esrestclient.ElasticsearchRestClientInstrumentation;
import co.elastic.apm.agent.esrestclient.ElasticsearchRestClientInstrumentationHelper;
-import co.elastic.apm.agent.impl.transaction.Span;
+import co.elastic.apm.plugin.spi.Span;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription;
@@ -67,7 +67,7 @@ public static Object onBeforeExecute(@Advice.Argument(0) Request request) {
public static void onAfterExecute(@Advice.Return @Nullable Response response,
@Advice.Enter @Nullable Object spanObj,
@Advice.Thrown @Nullable Throwable t) {
- Span span = (Span) spanObj;
+ Span> span = (Span>) spanObj;
if (span != null) {
try {
helper.finishClientSpan(response, span, t);
diff --git a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-7_x/src/main/java/co/elastic/apm/agent/esrestclient/v7_x/RestClientInstrumentation.java b/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-7_x/src/main/java/co/elastic/apm/agent/esrestclient/v7_x/RestClientInstrumentation.java
index 36e7125be24..463a72f2fda 100644
--- a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-7_x/src/main/java/co/elastic/apm/agent/esrestclient/v7_x/RestClientInstrumentation.java
+++ b/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-7_x/src/main/java/co/elastic/apm/agent/esrestclient/v7_x/RestClientInstrumentation.java
@@ -20,7 +20,7 @@
import co.elastic.apm.agent.esrestclient.ElasticsearchRestClientInstrumentation;
import co.elastic.apm.agent.esrestclient.ElasticsearchRestClientInstrumentationHelper;
-import co.elastic.apm.agent.impl.transaction.AbstractSpan;
+import co.elastic.apm.plugin.spi.AbstractSpan;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.asm.Advice.AssignReturned.ToArguments.ToArgument;
import net.bytebuddy.description.method.MethodDescription;
diff --git a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-common/src/main/java/co/elastic/apm/agent/esrestclient/ElasticsearchRestClientInstrumentationHelper.java b/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-common/src/main/java/co/elastic/apm/agent/esrestclient/ElasticsearchRestClientInstrumentationHelper.java
index a6fe28df96a..2a5fc8f37d2 100644
--- a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-common/src/main/java/co/elastic/apm/agent/esrestclient/ElasticsearchRestClientInstrumentationHelper.java
+++ b/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-common/src/main/java/co/elastic/apm/agent/esrestclient/ElasticsearchRestClientInstrumentationHelper.java
@@ -19,13 +19,7 @@
package co.elastic.apm.agent.esrestclient;
import co.elastic.apm.agent.common.util.WildcardMatcher;
-import co.elastic.apm.agent.impl.GlobalTracer;
-import co.elastic.apm.agent.impl.Tracer;
-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.objectpool.Allocator;
-import co.elastic.apm.agent.objectpool.ObjectPool;
+import co.elastic.apm.plugin.spi.*;
import co.elastic.apm.agent.sdk.logging.Logger;
import co.elastic.apm.agent.sdk.logging.LoggerFactory;
import co.elastic.apm.agent.util.IOUtils;
@@ -79,13 +73,13 @@ public ResponseListenerWrapper createInstance() {
}
@Nullable
- public Span createClientSpan(String method, String endpoint, @Nullable HttpEntity httpEntity) {
+ public Span> createClientSpan(String method, String endpoint, @Nullable HttpEntity httpEntity) {
final AbstractSpan> activeSpan = tracer.getActive();
if (activeSpan == null) {
return null;
}
- Span span = activeSpan.createExitSpan();
+ Span> span = activeSpan.createExitSpan();
// Don't record nested spans. In 5.x clients the instrumented sync method is calling the instrumented async method
if (span == null) {
@@ -120,7 +114,7 @@ public Span createClientSpan(String method, String endpoint, @Nullable HttpEntit
return span;
}
- public void finishClientSpan(@Nullable Response response, Span span, @Nullable Throwable t) {
+ public void finishClientSpan(@Nullable Response response, Span> span, @Nullable Throwable t) {
try {
String url = null;
int statusCode = -1;
@@ -146,7 +140,7 @@ public void finishClientSpan(@Nullable Response response, Span span, @Nullable T
statusCode = esre.getResponse().getStatusLine().getStatusCode();
} else if (t instanceof CancellationException) {
// We can't tell whether a cancelled search is related to a failure or not
- span.withOutcome(Outcome.UNKNOWN);
+ span.withOutcome(DefaultOutcome.UNKNOWN);
}
span.captureException(t);
}
@@ -162,7 +156,7 @@ public void finishClientSpan(@Nullable Response response, Span span, @Nullable T
}
}
- public ResponseListener wrapClientResponseListener(ResponseListener listener, Span span) {
+ public ResponseListener wrapClientResponseListener(ResponseListener listener, Span> span) {
return responseListenerObjectPool.createInstance().withClientSpan(listener, span);
}
diff --git a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-common/src/main/java/co/elastic/apm/agent/esrestclient/ResponseListenerWrapper.java b/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-common/src/main/java/co/elastic/apm/agent/esrestclient/ResponseListenerWrapper.java
index de31f44fb32..608a38c3498 100644
--- a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-common/src/main/java/co/elastic/apm/agent/esrestclient/ResponseListenerWrapper.java
+++ b/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-common/src/main/java/co/elastic/apm/agent/esrestclient/ResponseListenerWrapper.java
@@ -18,9 +18,9 @@
*/
package co.elastic.apm.agent.esrestclient;
-import co.elastic.apm.agent.impl.Tracer;
-import co.elastic.apm.agent.impl.transaction.AbstractSpan;
-import co.elastic.apm.agent.impl.transaction.Span;
+import co.elastic.apm.plugin.spi.Tracer;
+import co.elastic.apm.plugin.spi.AbstractSpan;
+import co.elastic.apm.plugin.spi.Span;
import co.elastic.apm.agent.objectpool.Recyclable;
import org.elasticsearch.client.Response;
import org.elasticsearch.client.ResponseListener;
@@ -49,7 +49,7 @@ public class ResponseListenerWrapper implements ResponseListener, Recyclable {
this.tracer = tracer;
}
- ResponseListenerWrapper withClientSpan(ResponseListener delegate, Span span) {
+ ResponseListenerWrapper withClientSpan(ResponseListener delegate, Span> span) {
// Order is important due to visibility - write to span last on this (initiating) thread
this.delegate = delegate;
this.isClientSpan = true;
@@ -144,8 +144,8 @@ private void onFailureContextPropagation(Exception exception) {
private void finishClientSpan(@Nullable Response response, @Nullable Throwable throwable) {
// First read volatile span to ensure visibility on executing thread
AbstractSpan> localSpan = context;
- if (localSpan instanceof Span) {
- helper.finishClientSpan(response, (Span) localSpan, throwable);
+ if (localSpan instanceof Span>) {
+ helper.finishClientSpan(response, (Span>) localSpan, throwable);
}
}
diff --git a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-common/src/test/java/co/elastic/apm/agent/esrestclient/ElasticsearchRestClientInstrumentationHelperTest.java b/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-common/src/test/java/co/elastic/apm/agent/esrestclient/ElasticsearchRestClientInstrumentationHelperTest.java
index 04c7d6b1dd2..df8ca9e6a85 100644
--- a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-common/src/test/java/co/elastic/apm/agent/esrestclient/ElasticsearchRestClientInstrumentationHelperTest.java
+++ b/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-common/src/test/java/co/elastic/apm/agent/esrestclient/ElasticsearchRestClientInstrumentationHelperTest.java
@@ -56,7 +56,7 @@ void after(){
@Test
void testCreateSpan() {
- Span span = helper.createClientSpan("GET", "/_test", null);
+ Span span = (Span) helper.createClientSpan("GET", "/_test", null);
assertThat(span).isNotNull();
assertThat(tracer.getActive()).isEqualTo(span);
@@ -81,7 +81,7 @@ void testCreateSpan() {
@Test
void testCreateSpanWithClusterName() {
- Span span = helper.createClientSpan("GET", "/_test", null);
+ Span span = (Span) helper.createClientSpan("GET", "/_test", null);
assertThat(span).isNotNull();
assertThat(tracer.getActive()).isEqualTo(span);
@@ -121,7 +121,7 @@ private static Response mockResponse(Map headers) {
@Test
void testNonSampledSpan() {
TransactionTest.setRecorded(false, transaction);
- Span esSpan = helper.createClientSpan("SEARCH", "/test", null);
+ Span esSpan = (Span) helper.createClientSpan("SEARCH", "/test", null);
assertThat(esSpan).isNotNull();
try {
assertThat(esSpan.isSampled()).isFalse();
diff --git a/apm-agent-plugins/apm-finagle-httpclient-plugin/src/main/java/co/elastic/apm/agent/finaglehttpclient/FinagleExceptionSourceFilterInstrumentation.java b/apm-agent-plugins/apm-finagle-httpclient-plugin/src/main/java/co/elastic/apm/agent/finaglehttpclient/FinagleExceptionSourceFilterInstrumentation.java
index bf28a6ab93a..fc4fec63c7d 100644
--- a/apm-agent-plugins/apm-finagle-httpclient-plugin/src/main/java/co/elastic/apm/agent/finaglehttpclient/FinagleExceptionSourceFilterInstrumentation.java
+++ b/apm-agent-plugins/apm-finagle-httpclient-plugin/src/main/java/co/elastic/apm/agent/finaglehttpclient/FinagleExceptionSourceFilterInstrumentation.java
@@ -21,7 +21,7 @@
import co.elastic.apm.agent.bci.TracerAwareInstrumentation;
import co.elastic.apm.agent.httpclient.HttpClientHelper;
-import co.elastic.apm.agent.impl.transaction.Span;
+import co.elastic.apm.plugin.spi.Span;
import co.elastic.apm.agent.sdk.logging.Logger;
import co.elastic.apm.agent.sdk.logging.LoggerFactory;
import com.twitter.finagle.http.Request;
@@ -91,7 +91,7 @@ public static class ExceptionSourceFilterAdvice {
@Advice.OnMethodEnter(suppress = Throwable.class, inline = false)
public static void onBeforeExecute(@Nullable @Advice.Argument(0) Object serviceArg, @Nullable @Advice.FieldValue(SERVICE_NAME_FIELD) String serviceName) {
if (serviceArg instanceof Request) {
- Span spanToEnhance = FinaglePayloadSizeFilterInstrumentation.PayloadSizeFilterAdvice
+ Span> spanToEnhance = FinaglePayloadSizeFilterInstrumentation.PayloadSizeFilterAdvice
.getAndRemoveSpanWithUnknownHostForRequest((Request) serviceArg);
if (spanToEnhance != null && serviceName != null && !serviceName.isEmpty()) {
updateSpanHostname(spanToEnhance, serviceName);
@@ -100,7 +100,7 @@ public static void onBeforeExecute(@Nullable @Advice.Argument(0) Object serviceA
}
}
- private static void updateSpanHostname(Span spanToEnhance, String serviceName) {
+ private static void updateSpanHostname(Span> spanToEnhance, String serviceName) {
CharSequence currentUriStr = spanToEnhance.getContext().getHttp().getUrl();
String method = spanToEnhance.getContext().getHttp().getMethod();
if (currentUriStr.length() == 0 || method == null || method.isEmpty()) {
diff --git a/apm-agent-plugins/apm-finagle-httpclient-plugin/src/main/java/co/elastic/apm/agent/finaglehttpclient/FinaglePayloadSizeFilterInstrumentation.java b/apm-agent-plugins/apm-finagle-httpclient-plugin/src/main/java/co/elastic/apm/agent/finaglehttpclient/FinaglePayloadSizeFilterInstrumentation.java
index f4eaeae510e..ff3555e0f9d 100644
--- a/apm-agent-plugins/apm-finagle-httpclient-plugin/src/main/java/co/elastic/apm/agent/finaglehttpclient/FinaglePayloadSizeFilterInstrumentation.java
+++ b/apm-agent-plugins/apm-finagle-httpclient-plugin/src/main/java/co/elastic/apm/agent/finaglehttpclient/FinaglePayloadSizeFilterInstrumentation.java
@@ -22,13 +22,13 @@
import co.elastic.apm.agent.bci.TracerAwareInstrumentation;
import co.elastic.apm.agent.finaglehttpclient.helper.RequestHeaderAccessor;
import co.elastic.apm.agent.httpclient.HttpClientHelper;
-import co.elastic.apm.agent.impl.transaction.AbstractSpan;
-import co.elastic.apm.agent.impl.transaction.Span;
-import co.elastic.apm.agent.impl.transaction.TraceContext;
+import co.elastic.apm.plugin.spi.AbstractSpan;
+import co.elastic.apm.plugin.spi.Span;
import co.elastic.apm.agent.sdk.logging.Logger;
import co.elastic.apm.agent.sdk.logging.LoggerFactory;
import co.elastic.apm.agent.sdk.weakconcurrent.WeakConcurrent;
import co.elastic.apm.agent.sdk.weakconcurrent.WeakMap;
+import co.elastic.apm.plugin.spi.TraceContextUtil;
import com.twitter.finagle.http.Request;
import com.twitter.finagle.http.Response;
import com.twitter.finagle.tracing.Trace;
@@ -92,7 +92,7 @@ public String getAdviceClassName() {
public static class PayloadSizeFilterAdvice {
- private static final WeakMap inflightSpansWithUnknownHost = WeakConcurrent.buildMap();
+ private static final WeakMap> inflightSpansWithUnknownHost = WeakConcurrent.buildMap();
/**
* The PayloadSizeFilterAdvice is executed both for server and client requests.
@@ -109,7 +109,7 @@ public static class PayloadSizeFilterAdvice {
}
@Nullable
- public static Span getAndRemoveSpanWithUnknownHostForRequest(Request forRequest) {
+ public static Span> getAndRemoveSpanWithUnknownHostForRequest(Request forRequest) {
return inflightSpansWithUnknownHost.remove(forRequest);
}
@@ -140,7 +140,7 @@ public static Object onBeforeExecute(@Nullable @Advice.Argument(0) Request reque
}
URI uri = resolveURI(request, host);
- Span span = HttpClientHelper.startHttpClientSpan(parent, request.method().name(), uri, null);
+ Span> span = HttpClientHelper.startHttpClientSpan(parent, request.method().name(), uri, null);
if (span != null) {
span.activate();
@@ -149,10 +149,10 @@ public static Object onBeforeExecute(@Nullable @Advice.Argument(0) Request reque
}
}
- if (!TraceContext.containsTraceContextTextHeaders(request, RequestHeaderAccessor.INSTANCE)) {
+ if (!TraceContextUtil.containsTraceContextTextHeaders(request, RequestHeaderAccessor.INSTANCE)) {
if (span != null) {
span.propagateTraceContext(request, RequestHeaderAccessor.INSTANCE);
- } else if (!TraceContext.containsTraceContextTextHeaders(request, RequestHeaderAccessor.INSTANCE)) {
+ } else if (!TraceContextUtil.containsTraceContextTextHeaders(request, RequestHeaderAccessor.INSTANCE)) {
// adds headers of potential parent exit-spans
parent.propagateTraceContext(request, RequestHeaderAccessor.INSTANCE);
}
@@ -185,7 +185,7 @@ public static void onExit(
if (spanObj == null) {
return;
}
- final Span span = (Span) spanObj;
+ final Span> span = (Span>) spanObj;
span.deactivate();
if (thrown != null) {
span.captureException(thrown);
@@ -210,7 +210,7 @@ public void onFailure(Throwable cause) {
}
}
- private static void endSpanForRequest(@Nullable Request request, Span span) {
+ private static void endSpanForRequest(@Nullable Request request, Span> span) {
if (request != null) { // should always be true because otherwise no span is created
inflightSpansWithUnknownHost.remove(request);
}
diff --git a/apm-agent-plugins/apm-finagle-httpclient-plugin/src/main/java/co/elastic/apm/agent/finaglehttpclient/helper/RequestHeaderAccessor.java b/apm-agent-plugins/apm-finagle-httpclient-plugin/src/main/java/co/elastic/apm/agent/finaglehttpclient/helper/RequestHeaderAccessor.java
index 19e2741c6dd..7b8eb97aed5 100644
--- a/apm-agent-plugins/apm-finagle-httpclient-plugin/src/main/java/co/elastic/apm/agent/finaglehttpclient/helper/RequestHeaderAccessor.java
+++ b/apm-agent-plugins/apm-finagle-httpclient-plugin/src/main/java/co/elastic/apm/agent/finaglehttpclient/helper/RequestHeaderAccessor.java
@@ -18,8 +18,8 @@
*/
package co.elastic.apm.agent.finaglehttpclient.helper;
-import co.elastic.apm.agent.impl.transaction.TextHeaderGetter;
-import co.elastic.apm.agent.impl.transaction.TextHeaderSetter;
+import co.elastic.apm.plugin.spi.TextHeaderGetter;
+import co.elastic.apm.plugin.spi.TextHeaderSetter;
import com.twitter.finagle.http.Request;
import scala.Option;
import scala.collection.Iterator;
diff --git a/apm-agent-plugins/apm-grails-plugin/src/main/java/co/elastic/apm/agent/grails/GrailsTransactionNameInstrumentation.java b/apm-agent-plugins/apm-grails-plugin/src/main/java/co/elastic/apm/agent/grails/GrailsTransactionNameInstrumentation.java
index 17f9d897089..fa3058ab488 100644
--- a/apm-agent-plugins/apm-grails-plugin/src/main/java/co/elastic/apm/agent/grails/GrailsTransactionNameInstrumentation.java
+++ b/apm-agent-plugins/apm-grails-plugin/src/main/java/co/elastic/apm/agent/grails/GrailsTransactionNameInstrumentation.java
@@ -19,7 +19,7 @@
package co.elastic.apm.agent.grails;
import co.elastic.apm.agent.bci.TracerAwareInstrumentation;
-import co.elastic.apm.agent.impl.transaction.Transaction;
+import co.elastic.apm.plugin.spi.Transaction;
import co.elastic.apm.agent.util.TransactionNameUtils;
import grails.core.GrailsControllerClass;
import net.bytebuddy.asm.Advice;
@@ -32,7 +32,7 @@
import java.util.Collections;
import static co.elastic.apm.agent.bci.bytebuddy.CustomElementMatchers.classLoaderCanLoadClass;
-import static co.elastic.apm.agent.impl.transaction.AbstractSpan.PRIO_HIGH_LEVEL_FRAMEWORK;
+import static co.elastic.apm.plugin.spi.AbstractSpan.PRIO_HIGH_LEVEL_FRAMEWORK;
import static grails.core.GrailsControllerClass.INDEX_ACTION;
import static net.bytebuddy.matcher.ElementMatchers.hasSuperType;
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
@@ -82,7 +82,7 @@ public static class HandlerAdapterAdvice {
@Advice.OnMethodEnter(suppress = Throwable.class, inline = false)
public static void setTransactionName(@Advice.Argument(2) Object handler) {
- final Transaction transaction = tracer.currentTransaction();
+ final Transaction> transaction = tracer.currentTransaction();
if (transaction == null) {
return;
}
diff --git a/apm-agent-plugins/apm-grpc/apm-grpc-plugin/src/main/java/co/elastic/apm/agent/grpc/ChannelInstrumentation.java b/apm-agent-plugins/apm-grpc/apm-grpc-plugin/src/main/java/co/elastic/apm/agent/grpc/ChannelInstrumentation.java
index 13a4bd22053..899aa03553e 100644
--- a/apm-agent-plugins/apm-grpc/apm-grpc-plugin/src/main/java/co/elastic/apm/agent/grpc/ChannelInstrumentation.java
+++ b/apm-agent-plugins/apm-grpc/apm-grpc-plugin/src/main/java/co/elastic/apm/agent/grpc/ChannelInstrumentation.java
@@ -18,7 +18,7 @@
*/
package co.elastic.apm.agent.grpc;
-import co.elastic.apm.agent.impl.transaction.Span;
+import co.elastic.apm.plugin.spi.Span;
import co.elastic.apm.agent.sdk.DynamicTransformer;
import co.elastic.apm.agent.sdk.ElasticApmInstrumentation;
import io.grpc.CallOptions;
@@ -92,7 +92,7 @@ public static void onExit(@Advice.Return @Nullable ClientCall, ?> clientCall,
if (clientCall != null) {
DynamicTransformer.ensureInstrumented(clientCall.getClass(), CLIENT_CALL_INSTRUMENTATION);
}
- GrpcHelper.getInstance().onClientCallCreationExit(clientCall, (Span) span);
+ GrpcHelper.getInstance().onClientCallCreationExit(clientCall, (Span>) span);
}
}
}
diff --git a/apm-agent-plugins/apm-grpc/apm-grpc-plugin/src/main/java/co/elastic/apm/agent/grpc/ClientCallImplInstrumentation.java b/apm-agent-plugins/apm-grpc/apm-grpc-plugin/src/main/java/co/elastic/apm/agent/grpc/ClientCallImplInstrumentation.java
index e70062c967c..10809797137 100644
--- a/apm-agent-plugins/apm-grpc/apm-grpc-plugin/src/main/java/co/elastic/apm/agent/grpc/ClientCallImplInstrumentation.java
+++ b/apm-agent-plugins/apm-grpc/apm-grpc-plugin/src/main/java/co/elastic/apm/agent/grpc/ClientCallImplInstrumentation.java
@@ -18,7 +18,7 @@
*/
package co.elastic.apm.agent.grpc;
-import co.elastic.apm.agent.impl.transaction.Span;
+import co.elastic.apm.plugin.spi.Span;
import co.elastic.apm.agent.sdk.DynamicTransformer;
import co.elastic.apm.agent.sdk.ElasticApmInstrumentation;
import io.grpc.ClientCall;
@@ -96,7 +96,7 @@ public static void onExit(@Advice.Argument(0) ClientCall.Listener> listener,
@Advice.Thrown @Nullable Throwable thrown,
@Advice.Enter @Nullable Object span) {
- GrpcHelper.getInstance().clientCallStartExit((Span) span, listener, thrown);
+ GrpcHelper.getInstance().clientCallStartExit((Span>) span, listener, thrown);
}
}
}
diff --git a/apm-agent-plugins/apm-grpc/apm-grpc-plugin/src/main/java/co/elastic/apm/agent/grpc/ClientCallListenerInstrumentation.java b/apm-agent-plugins/apm-grpc/apm-grpc-plugin/src/main/java/co/elastic/apm/agent/grpc/ClientCallListenerInstrumentation.java
index f6eecaea683..d4894b78da8 100644
--- a/apm-agent-plugins/apm-grpc/apm-grpc-plugin/src/main/java/co/elastic/apm/agent/grpc/ClientCallListenerInstrumentation.java
+++ b/apm-agent-plugins/apm-grpc/apm-grpc-plugin/src/main/java/co/elastic/apm/agent/grpc/ClientCallListenerInstrumentation.java
@@ -18,7 +18,7 @@
*/
package co.elastic.apm.agent.grpc;
-import co.elastic.apm.agent.impl.transaction.Span;
+import co.elastic.apm.plugin.spi.Span;
import co.elastic.apm.agent.sdk.DynamicTransformer;
import io.grpc.ClientCall;
import io.grpc.Metadata;
@@ -74,7 +74,7 @@ public static void onExit(@Advice.This ClientCall.Listener> listener,
@Advice.Thrown @Nullable Throwable thrown,
@Advice.Enter @Nullable Object span) {
- GrpcHelper.getInstance().exitClientListenerMethod(thrown, listener, (Span) span, status);
+ GrpcHelper.getInstance().exitClientListenerMethod(thrown, listener, (Span>) span, status);
}
}
}
@@ -115,7 +115,7 @@ public static void onExit(@Advice.This ClientCall.Listener> listener,
@Advice.Thrown @Nullable Throwable thrown,
@Advice.Enter @Nullable Object span) {
- GrpcHelper.getInstance().exitClientListenerMethod(thrown, listener, (Span) span, null);
+ GrpcHelper.getInstance().exitClientListenerMethod(thrown, listener, (Span>) span, null);
}
}
}
diff --git a/apm-agent-plugins/apm-grpc/apm-grpc-plugin/src/main/java/co/elastic/apm/agent/grpc/GrpcHelper.java b/apm-agent-plugins/apm-grpc/apm-grpc-plugin/src/main/java/co/elastic/apm/agent/grpc/GrpcHelper.java
index f4090f6e624..0c655c73f54 100644
--- a/apm-agent-plugins/apm-grpc/apm-grpc-plugin/src/main/java/co/elastic/apm/agent/grpc/GrpcHelper.java
+++ b/apm-agent-plugins/apm-grpc/apm-grpc-plugin/src/main/java/co/elastic/apm/agent/grpc/GrpcHelper.java
@@ -19,17 +19,7 @@
package co.elastic.apm.agent.grpc;
import co.elastic.apm.agent.collections.WeakConcurrentProviderImpl;
-import co.elastic.apm.agent.impl.GlobalTracer;
-import co.elastic.apm.agent.impl.Tracer;
-import co.elastic.apm.agent.impl.context.Destination;
-import co.elastic.apm.agent.impl.transaction.AbstractHeaderGetter;
-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.impl.transaction.TextHeaderGetter;
-import co.elastic.apm.agent.impl.transaction.TextHeaderSetter;
-import co.elastic.apm.agent.impl.transaction.TraceContext;
-import co.elastic.apm.agent.impl.transaction.Transaction;
+import co.elastic.apm.plugin.spi.*;
import co.elastic.apm.agent.sdk.weakconcurrent.WeakConcurrent;
import co.elastic.apm.agent.sdk.weakconcurrent.WeakMap;
import io.grpc.CallOptions;
@@ -50,6 +40,8 @@ public class GrpcHelper {
private static final String FRAMEWORK_NAME = "gRPC";
+ private static final Tracer tracer = GlobalTracer.get();
+
private static final GrpcHelper INSTANCE = new GrpcHelper();
public static GrpcHelper getInstance() {
@@ -59,27 +51,27 @@ public static GrpcHelper getInstance() {
/**
* Map of all in-flight {@link Span} with {@link ClientCall} instance as key.
*/
- private final WeakMap, Span> clientCallSpans;
+ private final WeakMap, Span>> clientCallSpans;
/**
* Map of all in-flight {@link Span} with {@link ClientCall} instance as key.
*/
- private final WeakMap, Span> delayedClientCallSpans;
+ private final WeakMap, Span>> delayedClientCallSpans;
/**
* Map of all in-flight {@link Span} with {@link ClientCall.Listener} instance as key.
*/
- private final WeakMap, Span> clientCallListenerSpans;
+ private final WeakMap, Span>> clientCallListenerSpans;
/**
* Map of all in-flight {@link Transaction} with {@link ServerCall.Listener} instance as key.
*/
- private final WeakMap, Transaction> serverListenerTransactions;
+ private final WeakMap, Transaction>> serverListenerTransactions;
/**
* Map of all in-flight {@link Transaction} with {@link ServerCall} instance as key.
*/
- private final WeakMap, Transaction> serverCallTransactions;
+ private final WeakMap, Transaction>> serverCallTransactions;
/**
* gRPC header cache used to minimize allocations
@@ -115,7 +107,7 @@ public GrpcHelper() {
* @return transaction, or {@literal null} if none has been created
*/
@Nullable
- public Transaction startTransaction(Tracer tracer, ClassLoader cl, ServerCall, ?> serverCall, Metadata headers) {
+ public Transaction> startTransaction(Tracer tracer, ClassLoader cl, ServerCall, ?> serverCall, Metadata headers) {
MethodDescriptor, ?> methodDescriptor = serverCall.getMethodDescriptor();
// ignore non-unary method calls for now
@@ -129,7 +121,7 @@ public Transaction startTransaction(Tracer tracer, ClassLoader cl, ServerCall,
return null;
}
- Transaction transaction = tracer.startChildTransaction(headers, headerGetter, cl);
+ Transaction> transaction = tracer.startChildTransaction(headers, headerGetter, cl);
if (transaction == null) {
return null;
}
@@ -149,7 +141,7 @@ public Transaction startTransaction(Tracer tracer, ClassLoader cl, ServerCall,
* @param listener server call listener
* @param transaction transaction
*/
- public void registerTransaction(ServerCall, ?> serverCall, ServerCall.Listener> listener, Transaction transaction) {
+ public void registerTransaction(ServerCall, ?> serverCall, ServerCall.Listener> listener, Transaction> transaction) {
serverCallTransactions.put(serverCall, transaction);
serverListenerTransactions.put(listener, transaction);
transaction.deactivate();
@@ -164,7 +156,7 @@ public void registerTransaction(ServerCall, ?> serverCall, ServerCall.Listener
* @param serverCall server call
*/
public void exitServerCall(Status status, @Nullable Throwable thrown, ServerCall, ?> serverCall) {
- Transaction transaction = serverCallTransactions.remove(serverCall);
+ Transaction> transaction = serverCallTransactions.remove(serverCall);
if (transaction != null) {
// there are multiple ways to terminate transaction, which aren't mutually exclusive
@@ -172,7 +164,7 @@ public void exitServerCall(Status status, @Nullable Throwable thrown, ServerCall
// 1. thrown exception within any of ServerCall.Listener methods
// 2. ServerCall.onClose, which might falsely report 'OK' status after a thrown listener exception.
// in this case we just have to ignore the reported status if already set
- if (Outcome.UNKNOWN == transaction.getOutcome()) {
+ if (transaction.getOutcome().name().equals(DefaultOutcome.UNKNOWN.name())) {
transaction.withOutcome(toServerOutcome(status))
.withResultIfUnset(status.getCode().name()); // keep outcome and result consistent
}
@@ -186,15 +178,15 @@ public void exitServerCall(Status status, @Nullable Throwable thrown, ServerCall
public static Outcome toClientOutcome(@Nullable Status status) {
if (status == null || !status.isOk()) {
- return Outcome.FAILURE;
+ return DefaultOutcome.FAILURE;
} else {
- return Outcome.SUCCESS;
+ return DefaultOutcome.SUCCESS;
}
}
public static Outcome toServerOutcome(@Nullable Status status) {
if (status == null) {
- return Outcome.FAILURE;
+ return DefaultOutcome.FAILURE;
}
switch (status.getCode()) {
case UNKNOWN:
@@ -205,9 +197,9 @@ public static Outcome toServerOutcome(@Nullable Status status) {
case INTERNAL:
case UNAVAILABLE:
case DATA_LOSS:
- return Outcome.FAILURE;
+ return DefaultOutcome.FAILURE;
default:
- return Outcome.SUCCESS;
+ return DefaultOutcome.SUCCESS;
}
}
@@ -218,8 +210,8 @@ public static Outcome toServerOutcome(@Nullable Status status) {
* @return transaction, or {@literal null} if there is none
*/
@Nullable
- public Transaction enterServerListenerMethod(ServerCall.Listener> listener) {
- Transaction transaction = serverListenerTransactions.get(listener);
+ public Transaction> enterServerListenerMethod(ServerCall.Listener> listener) {
+ Transaction> transaction = serverListenerTransactions.get(listener);
if (transaction != null) {
transaction.activate();
}
@@ -236,7 +228,7 @@ public Transaction enterServerListenerMethod(ServerCall.Listener> listener) {
*/
public void exitServerListenerMethod(@Nullable Throwable thrown,
ServerCall.Listener> listener,
- @Nullable Transaction transaction,
+ @Nullable Transaction> transaction,
@Nullable Status terminateStatus) {
if (transaction == null) {
@@ -258,7 +250,7 @@ public void exitServerListenerMethod(@Nullable Throwable thrown,
terminateStatus = Status.fromThrowable(thrown);
setTerminateStatus = true;
- } else if (transaction.getOutcome() == Outcome.UNKNOWN) {
+ } else if (transaction.getOutcome().name().equals(DefaultOutcome.UNKNOWN.name())) {
setTerminateStatus = true;
}
@@ -285,7 +277,7 @@ public void exitServerListenerMethod(@Nullable Throwable thrown,
* @return client call span (activated) or {@literal null} if not within an exit span.
*/
@Nullable
- public Span onClientCallCreationEntry(@Nullable AbstractSpan> parent,
+ public Span> onClientCallCreationEntry(@Nullable AbstractSpan> parent,
@Nullable MethodDescriptor, ?> method,
@Nullable String authority) {
@@ -298,7 +290,7 @@ public Span onClientCallCreationEntry(@Nullable AbstractSpan> parent,
return null;
}
- Span span = parent.createExitSpan();
+ Span> span = parent.createExitSpan();
if (span == null) {
// as it's an external call, we only need a single span for nested calls
return null;
@@ -328,12 +320,12 @@ public Span onClientCallCreationEntry(@Nullable AbstractSpan> parent,
* @param clientCall client call
* @param spanFromEntry span created at {@link #onClientCallCreationEntry(AbstractSpan, MethodDescriptor, String)}
*/
- public void onClientCallCreationExit(@Nullable ClientCall, ?> clientCall, @Nullable Span spanFromEntry) {
+ public void onClientCallCreationExit(@Nullable ClientCall, ?> clientCall, @Nullable Span> spanFromEntry) {
if (clientCall != null) {
- Span spanToMap = spanFromEntry;
+ Span> spanToMap = spanFromEntry;
if (spanToMap == null) {
// handling nested newCall() invocations - we still want to map the client call to the same span
- Span tmp = GlobalTracer.get().getActiveSpan();
+ Span> tmp = tracer.getActiveSpan();
if (tmp != null && tmp.getSubtype() != null && tmp.getSubtype().equals(GRPC) && tmp.isExit()) {
spanToMap = tmp;
}
@@ -385,7 +377,7 @@ private boolean isDelayedClientCall(ClientCall, ?> clientCall) {
public void replaceClientCallRegistration(ClientCall, ?> placeholderClientCall, ClientCall, ?> realClientCall) {
// we cannot remove yet, because the span could have been ended already through ClientCall#start(), in which case
// it will be recycled ahead of time due to reference decrement when removed from the map
- Span spanOfPlaceholder = delayedClientCallSpans.get(placeholderClientCall);
+ Span> spanOfPlaceholder = delayedClientCallSpans.get(placeholderClientCall);
if (spanOfPlaceholder == null) {
return;
}
@@ -393,7 +385,7 @@ public void replaceClientCallRegistration(ClientCall, ?> placeholderClientCall
try {
// we cannot remove yet, because the span could have been ended already, in which case
// it will be recycled ahead of time due to reference decrement when removed from the map
- Span spanOfRealClientCall = clientCallSpans.get(realClientCall);
+ Span> spanOfRealClientCall = clientCallSpans.get(realClientCall);
boolean mapPlaceholderSpanToRealClientCall = false;
if (spanOfRealClientCall == null) {
mapPlaceholderSpanToRealClientCall = true;
@@ -432,20 +424,20 @@ public void replaceClientCallRegistration(ClientCall, ?> placeholderClientCall
* @return span, or {@literal null is there is none}
*/
@Nullable
- public Span clientCallStartEnter(ClientCall, ?> clientCall,
- ClientCall.Listener> listener,
- Metadata headers) {
+ public Span> clientCallStartEnter(ClientCall, ?> clientCall,
+ ClientCall.Listener> listener,
+ Metadata headers) {
// span should already have been registered
// no other lookup by client call is required, thus removing entry
- Span span = clientCallSpans.remove(clientCall);
+ Span> span = clientCallSpans.remove(clientCall);
if (span == null) {
return null;
}
clientCallListenerSpans.put(listener, span);
- if (!TraceContext.containsTraceContextTextHeaders(headers, headerGetter)) {
+ if (!TraceContextUtil.containsTraceContextTextHeaders(headers, headerGetter)) {
span.propagateTraceContext(headers, headerSetter);
}
@@ -459,7 +451,7 @@ public Span clientCallStartEnter(ClientCall, ?> clientCall,
* @param listener client call listener
* @param thrown thrown exception
*/
- public void clientCallStartExit(@Nullable Span spanFromEntry, ClientCall.Listener> listener, @Nullable Throwable thrown) {
+ public void clientCallStartExit(@Nullable Span> spanFromEntry, ClientCall.Listener> listener, @Nullable Throwable thrown) {
if (spanFromEntry != null) {
spanFromEntry.deactivate();
}
@@ -467,16 +459,16 @@ public void clientCallStartExit(@Nullable Span spanFromEntry, ClientCall.Listene
// when there is an exception, we have to end span and perform some cleanup
clientCallListenerSpans.remove(listener);
if (spanFromEntry != null) {
- spanFromEntry.withOutcome(Outcome.FAILURE)
+ spanFromEntry.withOutcome(DefaultOutcome.FAILURE)
.end();
}
}
}
public void cancelCall(ClientCall, ?> clientCall, @Nullable Throwable cause) {
- WeakMap, Span> clientCallMap = (isDelayedClientCall(clientCall)) ? delayedClientCallSpans : clientCallSpans;
+ WeakMap, Span>> clientCallMap = (isDelayedClientCall(clientCall)) ? delayedClientCallSpans : clientCallSpans;
// we can't remove yet, in order to avoid reference decrement prematurely
- Span span = clientCallMap.get(clientCall);
+ Span> span = clientCallMap.get(clientCall);
if (span != null) {
if (!span.isFinished()) {
span
@@ -495,14 +487,14 @@ public void cancelCall(ClientCall, ?> clientCall, @Nullable Throwable cause) {
* @return active span or {@literal null} if there is none
*/
@Nullable
- public Span enterClientListenerMethod(ClientCall.Listener> listener) {
- Span span = clientCallListenerSpans.get(listener);
+ public Span> enterClientListenerMethod(ClientCall.Listener> listener) {
+ Span> span = clientCallListenerSpans.get(listener);
if (span != null) {
if (span.isFinished()) {
// the span may have already been ended by another listener on a different thread/stack
clientCallListenerSpans.remove(listener);
span = null;
- } else if (span == GlobalTracer.get().getActiveSpan()) {
+ } else if (span == tracer.getActiveSpan()) {
// avoid duplicated activation and invocation on nested listener method calls
span = null;
} else {
@@ -522,7 +514,7 @@ public Span enterClientListenerMethod(ClientCall.Listener> listener) {
*/
public void exitClientListenerMethod(@Nullable Throwable thrown,
ClientCall.Listener> listener,
- @Nullable Span span,
+ @Nullable Span> span,
@Nullable Status onCloseStatus) {
boolean lastCall = onCloseStatus != null || thrown != null;
diff --git a/apm-agent-plugins/apm-grpc/apm-grpc-plugin/src/main/java/co/elastic/apm/agent/grpc/ServerCallHandlerInstrumentation.java b/apm-agent-plugins/apm-grpc/apm-grpc-plugin/src/main/java/co/elastic/apm/agent/grpc/ServerCallHandlerInstrumentation.java
index b5a4d728a15..6233cdb0d9b 100644
--- a/apm-agent-plugins/apm-grpc/apm-grpc-plugin/src/main/java/co/elastic/apm/agent/grpc/ServerCallHandlerInstrumentation.java
+++ b/apm-agent-plugins/apm-grpc/apm-grpc-plugin/src/main/java/co/elastic/apm/agent/grpc/ServerCallHandlerInstrumentation.java
@@ -18,7 +18,7 @@
*/
package co.elastic.apm.agent.grpc;
-import co.elastic.apm.agent.impl.transaction.Transaction;
+import co.elastic.apm.plugin.spi.Transaction;
import co.elastic.apm.agent.sdk.DynamicTransformer;
import co.elastic.apm.agent.sdk.ElasticApmInstrumentation;
import co.elastic.apm.agent.util.PrivilegedActionUtils;
@@ -94,10 +94,10 @@ public static void onExit(@Advice.Thrown @Nullable Throwable thrown,
@Advice.Return @Nullable ServerCall.Listener> listener,
@Advice.Enter @Nullable Object enterTransaction) {
- if (!(enterTransaction instanceof Transaction)) {
+ if (!(enterTransaction instanceof Transaction>)) {
return;
}
- Transaction transaction = (Transaction) enterTransaction;
+ Transaction> transaction = (Transaction>) enterTransaction;
if (thrown != null) {
// terminate transaction in case of exception as it won't be stored
transaction.deactivate().end();
diff --git a/apm-agent-plugins/apm-grpc/apm-grpc-plugin/src/main/java/co/elastic/apm/agent/grpc/ServerCallListenerInstrumentation.java b/apm-agent-plugins/apm-grpc/apm-grpc-plugin/src/main/java/co/elastic/apm/agent/grpc/ServerCallListenerInstrumentation.java
index 1bbb671cf5a..d693e6d45ef 100644
--- a/apm-agent-plugins/apm-grpc/apm-grpc-plugin/src/main/java/co/elastic/apm/agent/grpc/ServerCallListenerInstrumentation.java
+++ b/apm-agent-plugins/apm-grpc/apm-grpc-plugin/src/main/java/co/elastic/apm/agent/grpc/ServerCallListenerInstrumentation.java
@@ -18,7 +18,7 @@
*/
package co.elastic.apm.agent.grpc;
-import co.elastic.apm.agent.impl.transaction.Transaction;
+import co.elastic.apm.plugin.spi.Transaction;
import co.elastic.apm.agent.sdk.DynamicTransformer;
import io.grpc.ServerCall;
import io.grpc.Status;
@@ -92,8 +92,8 @@ public static void onExit(@Advice.Thrown @Nullable Throwable thrown,
@Advice.This ServerCall.Listener> listener,
@Advice.Enter @Nullable Object transaction) {
- if (transaction instanceof Transaction) {
- GrpcHelper.getInstance().exitServerListenerMethod(thrown, listener, (Transaction) transaction, null);
+ if (transaction instanceof Transaction>) {
+ GrpcHelper.getInstance().exitServerListenerMethod(thrown, listener, (Transaction>) transaction, null);
}
}
}
@@ -128,7 +128,7 @@ public static void onExit(@Advice.Thrown @Nullable Throwable thrown,
@Advice.Enter @Nullable Object transaction) {
if (transaction instanceof Transaction) {
- GrpcHelper.getInstance().exitServerListenerMethod(thrown, listener, (Transaction) transaction, Status.CANCELLED);
+ GrpcHelper.getInstance().exitServerListenerMethod(thrown, listener, (Transaction>) transaction, Status.CANCELLED);
}
}
}
@@ -163,7 +163,7 @@ public static void onExit(@Advice.Thrown @Nullable Throwable thrown,
@Advice.Enter @Nullable Object transaction) {
if (transaction instanceof Transaction) {
- GrpcHelper.getInstance().exitServerListenerMethod(thrown, listener, (Transaction) transaction, Status.OK);
+ GrpcHelper.getInstance().exitServerListenerMethod(thrown, listener, (Transaction>) transaction, Status.OK);
}
}
}
diff --git a/apm-agent-plugins/apm-grpc/apm-grpc-plugin/src/test/java/specs/OutcomeGrpcStepsDefinitions.java b/apm-agent-plugins/apm-grpc/apm-grpc-plugin/src/test/java/specs/OutcomeGrpcStepsDefinitions.java
index 275fca7d9fb..cc35545f2de 100644
--- a/apm-agent-plugins/apm-grpc/apm-grpc-plugin/src/test/java/specs/OutcomeGrpcStepsDefinitions.java
+++ b/apm-agent-plugins/apm-grpc/apm-grpc-plugin/src/test/java/specs/OutcomeGrpcStepsDefinitions.java
@@ -38,15 +38,15 @@ public void grpcSpan(String grpcStatus) {
state.startRootTransactionIfRequired();
state.startSpan()
- .withName(String.format("gRPC span %s", grpcStatus))
- .withOutcome(getOutcome(grpcStatus, GrpcHelper::toClientOutcome));
+ .withName(String.format("gRPC span %s", grpcStatus));
+ // TODO Rafael .withOutcome(getOutcome(grpcStatus, GrpcHelper::toClientOutcome));
}
@Given("a gRPC call is received that returns {string}")
public void grpcTransaction(String grpcStatus) {
state.startTransaction()
- .withName(String.format("gRPC transaction %s", grpcStatus))
- .withOutcome(getOutcome(grpcStatus, GrpcHelper::toServerOutcome));
+ .withName(String.format("gRPC transaction %s", grpcStatus));
+ // TODO Rafael .withOutcome(getOutcome(grpcStatus, GrpcHelper::toServerOutcome));
}
private static Outcome getOutcome(String grpcStatus, Function mapFunction) {
diff --git a/apm-agent-plugins/apm-hibernate-search-plugin/apm-hibernate-search-plugin-5_x/src/main/java/co/elastic/apm/agent/hibernatesearch/v5/HibernateSearch5Instrumentation.java b/apm-agent-plugins/apm-hibernate-search-plugin/apm-hibernate-search-plugin-5_x/src/main/java/co/elastic/apm/agent/hibernatesearch/v5/HibernateSearch5Instrumentation.java
index 2358c4bbb4d..045c7ab0e7c 100644
--- a/apm-agent-plugins/apm-hibernate-search-plugin/apm-hibernate-search-plugin-5_x/src/main/java/co/elastic/apm/agent/hibernatesearch/v5/HibernateSearch5Instrumentation.java
+++ b/apm-agent-plugins/apm-hibernate-search-plugin/apm-hibernate-search-plugin-5_x/src/main/java/co/elastic/apm/agent/hibernatesearch/v5/HibernateSearch5Instrumentation.java
@@ -21,7 +21,7 @@
import co.elastic.apm.agent.bci.TracerAwareInstrumentation;
import co.elastic.apm.agent.hibernatesearch.HibernateSearchConstants;
import co.elastic.apm.agent.hibernatesearch.HibernateSearchHelper;
-import co.elastic.apm.agent.impl.transaction.Span;
+import co.elastic.apm.plugin.spi.Span;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.NamedElement;
import net.bytebuddy.description.method.MethodDescription;
@@ -90,8 +90,8 @@ public static Object onBeforeExecute(@Advice.This FullTextQueryImpl query,
public static void onAfterExecute(@Advice.Enter @Nullable Object span,
@Advice.Thrown Throwable t) {
- if (span instanceof Span) {
- ((Span) span).captureException(t)
+ if (span instanceof Span>) {
+ ((Span>) span).captureException(t)
.deactivate()
.end();
}
diff --git a/apm-agent-plugins/apm-hibernate-search-plugin/apm-hibernate-search-plugin-6_x/src/main/java/co/elastic/apm/agent/hibernatesearch/HibernateSearch6Instrumentation.java b/apm-agent-plugins/apm-hibernate-search-plugin/apm-hibernate-search-plugin-6_x/src/main/java/co/elastic/apm/agent/hibernatesearch/HibernateSearch6Instrumentation.java
index 0cf1875c80e..29880d93adb 100644
--- a/apm-agent-plugins/apm-hibernate-search-plugin/apm-hibernate-search-plugin-6_x/src/main/java/co/elastic/apm/agent/hibernatesearch/HibernateSearch6Instrumentation.java
+++ b/apm-agent-plugins/apm-hibernate-search-plugin/apm-hibernate-search-plugin-6_x/src/main/java/co/elastic/apm/agent/hibernatesearch/HibernateSearch6Instrumentation.java
@@ -19,7 +19,7 @@
package co.elastic.apm.agent.hibernatesearch;
import co.elastic.apm.agent.bci.TracerAwareInstrumentation;
-import co.elastic.apm.agent.impl.transaction.Span;
+import co.elastic.apm.plugin.spi.Span;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.NamedElement;
import net.bytebuddy.description.method.MethodDescription;
@@ -87,8 +87,8 @@ public static Object onBeforeExecute(@Advice.This SearchQuery> query,
public static void onAfterExecute(@Advice.Enter @Nullable Object span,
@Advice.Thrown @Nullable Throwable t) {
- if (span instanceof Span) {
- ((Span) span).captureException(t)
+ if (span instanceof Span>) {
+ ((Span>) span).captureException(t)
.deactivate()
.end();
}
diff --git a/apm-agent-plugins/apm-hibernate-search-plugin/apm-hibernate-search-plugin-common/src/main/java/co/elastic/apm/agent/hibernatesearch/HibernateSearchHelper.java b/apm-agent-plugins/apm-hibernate-search-plugin/apm-hibernate-search-plugin-common/src/main/java/co/elastic/apm/agent/hibernatesearch/HibernateSearchHelper.java
index f33d869788f..a3d7bdfaa15 100644
--- a/apm-agent-plugins/apm-hibernate-search-plugin/apm-hibernate-search-plugin-common/src/main/java/co/elastic/apm/agent/hibernatesearch/HibernateSearchHelper.java
+++ b/apm-agent-plugins/apm-hibernate-search-plugin/apm-hibernate-search-plugin-common/src/main/java/co/elastic/apm/agent/hibernatesearch/HibernateSearchHelper.java
@@ -18,9 +18,9 @@
*/
package co.elastic.apm.agent.hibernatesearch;
-import co.elastic.apm.agent.impl.Tracer;
-import co.elastic.apm.agent.impl.transaction.AbstractSpan;
-import co.elastic.apm.agent.impl.transaction.Span;
+import co.elastic.apm.plugin.spi.Tracer;
+import co.elastic.apm.plugin.spi.AbstractSpan;
+import co.elastic.apm.plugin.spi.Span;
public final class HibernateSearchHelper {
@@ -28,17 +28,17 @@ private HibernateSearchHelper() {
}
- public static Span createAndActivateSpan(final Tracer tracer, final String methodName,
+ public static Span> createAndActivateSpan(final Tracer tracer, final String methodName,
final String query) {
AbstractSpan> active = tracer.getActive();
// avoid creating the same span twice for example, when an instrumented API is wrapped
- if (active == null || active instanceof Span && HibernateSearchConstants.HIBERNATE_SEARCH_ORM_TYPE
- .equals(((Span) active).getSubtype())) {
+ if (active == null || active instanceof Span> && HibernateSearchConstants.HIBERNATE_SEARCH_ORM_TYPE
+ .equals(((Span>) active).getSubtype())) {
return null;
}
- Span span = active.createSpan().activate();
+ Span> span = active.createSpan().activate();
span.withType(HibernateSearchConstants.HIBERNATE_SEARCH_ORM_SPAN_TYPE)
.withSubtype(HibernateSearchConstants.HIBERNATE_SEARCH_ORM_TYPE)
diff --git a/apm-agent-plugins/apm-httpclient-core/src/main/java/co/elastic/apm/agent/httpclient/HttpClientHelper.java b/apm-agent-plugins/apm-httpclient-core/src/main/java/co/elastic/apm/agent/httpclient/HttpClientHelper.java
index 6560e044d07..1e3e2fd7a2a 100644
--- a/apm-agent-plugins/apm-httpclient-core/src/main/java/co/elastic/apm/agent/httpclient/HttpClientHelper.java
+++ b/apm-agent-plugins/apm-httpclient-core/src/main/java/co/elastic/apm/agent/httpclient/HttpClientHelper.java
@@ -18,8 +18,8 @@
*/
package co.elastic.apm.agent.httpclient;
-import co.elastic.apm.agent.impl.transaction.AbstractSpan;
-import co.elastic.apm.agent.impl.transaction.Span;
+import co.elastic.apm.plugin.spi.AbstractSpan;
+import co.elastic.apm.plugin.spi.Span;
import co.elastic.apm.agent.sdk.logging.Logger;
import co.elastic.apm.agent.sdk.logging.LoggerFactory;
@@ -34,7 +34,7 @@ public class HttpClientHelper {
public static final String HTTP_SUBTYPE = "http";
@Nullable
- public static Span startHttpClientSpan(AbstractSpan> parent, String method, @Nullable URI uri, @Nullable CharSequence hostName) {
+ public static Span> startHttpClientSpan(AbstractSpan> parent, String method, @Nullable URI uri, @Nullable CharSequence hostName) {
String uriString = null;
String scheme = null;
int port = -1;
@@ -50,9 +50,9 @@ public static Span startHttpClientSpan(AbstractSpan> parent, String method, @N
}
@Nullable
- public static Span startHttpClientSpan(AbstractSpan> parent, String method, @Nullable String uri,
+ public static Span> startHttpClientSpan(AbstractSpan> parent, String method, @Nullable String uri,
@Nullable String scheme, @Nullable CharSequence hostName, int port) {
- Span span = parent.createExitSpan();
+ Span> span = parent.createExitSpan();
if (span != null) {
updateHttpSpanNameAndContext(span, method, uri, scheme, hostName, port);
}
@@ -62,7 +62,7 @@ public static Span startHttpClientSpan(AbstractSpan> parent, String method, @N
return span;
}
- public static void updateHttpSpanNameAndContext(Span span, String method, @Nullable String uri, String scheme, CharSequence hostName, int port) {
+ public static void updateHttpSpanNameAndContext(Span> span, String method, @Nullable String uri, String scheme, CharSequence hostName, int port) {
span.withType(EXTERNAL_TYPE)
.withSubtype(HTTP_SUBTYPE)
.withName(method).appendToName(" ").appendToName(hostName != null ? hostName : "unknown host");
@@ -74,7 +74,7 @@ public static void updateHttpSpanNameAndContext(Span span, String method, @Nulla
setDestinationServiceDetails(span, scheme, hostName, port);
}
- public static void setDestinationServiceDetails(Span span, @Nullable String scheme, @Nullable CharSequence host, int port) {
+ public static void setDestinationServiceDetails(Span> span, @Nullable String scheme, @Nullable CharSequence host, int port) {
if (scheme == null || host == null || host.length() == 0) {
return;
}
diff --git a/apm-agent-plugins/apm-httpclient-core/src/test/java/co/elastic/apm/agent/httpclient/AbstractHttpClientInstrumentationTest.java b/apm-agent-plugins/apm-httpclient-core/src/test/java/co/elastic/apm/agent/httpclient/AbstractHttpClientInstrumentationTest.java
index 933bcce865f..bd426ec72a4 100644
--- a/apm-agent-plugins/apm-httpclient-core/src/test/java/co/elastic/apm/agent/httpclient/AbstractHttpClientInstrumentationTest.java
+++ b/apm-agent-plugins/apm-httpclient-core/src/test/java/co/elastic/apm/agent/httpclient/AbstractHttpClientInstrumentationTest.java
@@ -20,16 +20,11 @@
import co.elastic.apm.agent.AbstractInstrumentationTest;
import co.elastic.apm.agent.configuration.CoreConfiguration;
-import co.elastic.apm.agent.configuration.converter.TimeDuration;
import co.elastic.apm.agent.impl.TextHeaderMapAccessor;
import co.elastic.apm.agent.impl.context.Destination;
import co.elastic.apm.agent.impl.context.Http;
import co.elastic.apm.agent.impl.context.web.ResultUtil;
-import co.elastic.apm.agent.impl.transaction.Outcome;
-import co.elastic.apm.agent.impl.transaction.Span;
-import co.elastic.apm.agent.impl.transaction.TextHeaderGetter;
-import co.elastic.apm.agent.impl.transaction.TraceContext;
-import co.elastic.apm.agent.impl.transaction.Transaction;
+import co.elastic.apm.agent.impl.transaction.*;
import com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder;
import com.github.tomakehurst.wiremock.core.WireMockConfiguration;
import com.github.tomakehurst.wiremock.http.HttpHeader;
@@ -329,7 +324,7 @@ private void verifyTraceContextHeaders(Span span, String path) {
);
assertThat(headerCount.get()).isEqualTo(1);
headerMap.forEach((key, value) -> assertThat(request.getHeader(key)).isEqualTo(value));
- Transaction transaction = tracer.startChildTransaction(request, new HeaderAccessor(), AbstractHttpClientInstrumentationTest.class.getClassLoader());
+ Transaction transaction = tracer.startChildTransaction(request, HeaderAccessor.INSTANCE, AbstractHttpClientInstrumentationTest.class.getClassLoader());
assertThat(transaction).isNotNull();
assertThat(transaction.getTraceContext().getTraceId()).isEqualTo(span.getTraceContext().getTraceId());
assertThat(transaction.getTraceContext().getParentId()).isEqualTo(span.getTraceContext().getId());
@@ -349,9 +344,9 @@ private List findLoggedRequests(String path) {
return loggedRequests.get();
}
- private static class HeaderAccessor implements TextHeaderGetter {
+ private static class HeaderAccessor implements co.elastic.apm.plugin.spi.TextHeaderGetter {
- static final HeaderAccessor INSTANCE = new HeaderAccessor();
+ static final TextHeaderGetter INSTANCE = new TextHeaderGetterBridge<>(new HeaderAccessor());
@Nullable
@Override
diff --git a/apm-agent-plugins/apm-jakarta-websocket-plugin/src/main/java/co/elastic/apm/agent/websocket/BaseServerEndpointInstrumentation.java b/apm-agent-plugins/apm-jakarta-websocket-plugin/src/main/java/co/elastic/apm/agent/websocket/BaseServerEndpointInstrumentation.java
index d85a408fdd4..6aabc300d5b 100644
--- a/apm-agent-plugins/apm-jakarta-websocket-plugin/src/main/java/co/elastic/apm/agent/websocket/BaseServerEndpointInstrumentation.java
+++ b/apm-agent-plugins/apm-jakarta-websocket-plugin/src/main/java/co/elastic/apm/agent/websocket/BaseServerEndpointInstrumentation.java
@@ -19,10 +19,10 @@
package co.elastic.apm.agent.websocket;
import co.elastic.apm.agent.bci.TracerAwareInstrumentation;
-import co.elastic.apm.agent.impl.Tracer;
+import co.elastic.apm.plugin.spi.DefaultOutcome;
+import co.elastic.apm.plugin.spi.Tracer;
import co.elastic.apm.agent.impl.stacktrace.StacktraceConfiguration;
-import co.elastic.apm.agent.impl.transaction.Outcome;
-import co.elastic.apm.agent.impl.transaction.Transaction;
+import co.elastic.apm.plugin.spi.Transaction;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.NamedElement;
import net.bytebuddy.description.method.MethodDescription;
@@ -36,7 +36,7 @@
import static co.elastic.apm.agent.bci.bytebuddy.CustomElementMatchers.classLoaderCanLoadClass;
import static co.elastic.apm.agent.bci.bytebuddy.CustomElementMatchers.isInAnyPackage;
import static co.elastic.apm.agent.bci.bytebuddy.CustomElementMatchers.isProxy;
-import static co.elastic.apm.agent.impl.transaction.AbstractSpan.PRIO_HIGH_LEVEL_FRAMEWORK;
+import static co.elastic.apm.plugin.spi.AbstractSpan.PRIO_HIGH_LEVEL_FRAMEWORK;
import static net.bytebuddy.matcher.ElementMatchers.isAnnotatedWith;
import static net.bytebuddy.matcher.ElementMatchers.isBootstrapClassLoader;
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
@@ -83,9 +83,9 @@ protected static class BaseAdvice {
@Nullable
protected static Object startTransactionOrSetTransactionName(String signature, String frameworkName, @Nullable String frameworkVersion) {
- Transaction currentTransaction = tracer.currentTransaction();
+ Transaction> currentTransaction = tracer.currentTransaction();
if (currentTransaction == null) {
- Transaction rootTransaction = tracer.startRootTransaction(Thread.currentThread().getContextClassLoader());
+ Transaction> rootTransaction = tracer.startRootTransaction(Thread.currentThread().getContextClassLoader());
if (rootTransaction != null) {
setTransactionTypeAndName(rootTransaction, signature, frameworkName, frameworkVersion);
return rootTransaction.activate();
@@ -102,17 +102,17 @@ protected static void endTransaction(@Nullable Object transactionOrNull, @Advice
return;
}
- Transaction transaction = (Transaction) transactionOrNull;
+ Transaction> transaction = (Transaction>) transactionOrNull;
try {
if (t != null) {
- transaction.captureException(t).withOutcome(Outcome.FAILURE);
+ transaction.captureException(t).withOutcome(DefaultOutcome.FAILURE);
}
} finally {
transaction.deactivate().end();
}
}
- private static void setTransactionTypeAndName(Transaction transaction, String signature, String frameworkName, @Nullable String frameworkVersion) {
+ private static void setTransactionTypeAndName(Transaction> transaction, String signature, String frameworkName, @Nullable String frameworkVersion) {
transaction.withType(Transaction.TYPE_REQUEST);
transaction.withName(signature, PRIO_HIGH_LEVEL_FRAMEWORK, false);
transaction.setFrameworkName(frameworkName);
diff --git a/apm-agent-plugins/apm-jakarta-websocket-plugin/src/main/java/co/elastic/apm/agent/websocket/JakartaServerEndpointInstrumentation.java b/apm-agent-plugins/apm-jakarta-websocket-plugin/src/main/java/co/elastic/apm/agent/websocket/JakartaServerEndpointInstrumentation.java
index 5d51b59d42f..2b468d2e657 100644
--- a/apm-agent-plugins/apm-jakarta-websocket-plugin/src/main/java/co/elastic/apm/agent/websocket/JakartaServerEndpointInstrumentation.java
+++ b/apm-agent-plugins/apm-jakarta-websocket-plugin/src/main/java/co/elastic/apm/agent/websocket/JakartaServerEndpointInstrumentation.java
@@ -19,7 +19,7 @@
package co.elastic.apm.agent.websocket;
import co.elastic.apm.agent.bci.bytebuddy.SimpleMethodSignatureOffsetMappingFactory;
-import co.elastic.apm.agent.impl.Tracer;
+import co.elastic.apm.plugin.spi.Tracer;
import co.elastic.apm.agent.util.VersionUtils;
import jakarta.websocket.server.ServerEndpoint;
import net.bytebuddy.asm.Advice;
diff --git a/apm-agent-plugins/apm-jakarta-websocket-plugin/src/main/java/co/elastic/apm/agent/websocket/JavaxServerEndpointInstrumentation.java b/apm-agent-plugins/apm-jakarta-websocket-plugin/src/main/java/co/elastic/apm/agent/websocket/JavaxServerEndpointInstrumentation.java
index 40ac2f9f026..c0cc2cf27fb 100644
--- a/apm-agent-plugins/apm-jakarta-websocket-plugin/src/main/java/co/elastic/apm/agent/websocket/JavaxServerEndpointInstrumentation.java
+++ b/apm-agent-plugins/apm-jakarta-websocket-plugin/src/main/java/co/elastic/apm/agent/websocket/JavaxServerEndpointInstrumentation.java
@@ -19,7 +19,7 @@
package co.elastic.apm.agent.websocket;
import co.elastic.apm.agent.bci.bytebuddy.SimpleMethodSignatureOffsetMappingFactory;
-import co.elastic.apm.agent.impl.Tracer;
+import co.elastic.apm.plugin.spi.Tracer;
import co.elastic.apm.agent.util.VersionUtils;
import net.bytebuddy.asm.Advice;
diff --git a/apm-agent-plugins/apm-java-concurrent-plugin/src/main/java/co/elastic/apm/agent/concurrent/JavaConcurrent.java b/apm-agent-plugins/apm-java-concurrent-plugin/src/main/java/co/elastic/apm/agent/concurrent/JavaConcurrent.java
index 6518cfd2fa9..1f9d496a88e 100644
--- a/apm-agent-plugins/apm-java-concurrent-plugin/src/main/java/co/elastic/apm/agent/concurrent/JavaConcurrent.java
+++ b/apm-agent-plugins/apm-java-concurrent-plugin/src/main/java/co/elastic/apm/agent/concurrent/JavaConcurrent.java
@@ -20,8 +20,8 @@
import co.elastic.apm.agent.collections.WeakConcurrentProviderImpl;
import co.elastic.apm.agent.common.ThreadUtils;
-import co.elastic.apm.agent.impl.Tracer;
-import co.elastic.apm.agent.impl.transaction.AbstractSpan;
+import co.elastic.apm.plugin.spi.Tracer;
+import co.elastic.apm.plugin.spi.AbstractSpan;
import co.elastic.apm.agent.sdk.DynamicTransformer;
import co.elastic.apm.agent.sdk.ElasticApmInstrumentation;
import co.elastic.apm.agent.sdk.state.GlobalState;
diff --git a/apm-agent-plugins/apm-java-concurrent-plugin/src/main/java/co/elastic/apm/agent/concurrent/RunnableCallableForkJoinTaskInstrumentation.java b/apm-agent-plugins/apm-java-concurrent-plugin/src/main/java/co/elastic/apm/agent/concurrent/RunnableCallableForkJoinTaskInstrumentation.java
index f61791e668e..80575b189d1 100644
--- a/apm-agent-plugins/apm-java-concurrent-plugin/src/main/java/co/elastic/apm/agent/concurrent/RunnableCallableForkJoinTaskInstrumentation.java
+++ b/apm-agent-plugins/apm-java-concurrent-plugin/src/main/java/co/elastic/apm/agent/concurrent/RunnableCallableForkJoinTaskInstrumentation.java
@@ -19,7 +19,7 @@
package co.elastic.apm.agent.concurrent;
import co.elastic.apm.agent.bci.TracerAwareInstrumentation;
-import co.elastic.apm.agent.impl.transaction.AbstractSpan;
+import co.elastic.apm.plugin.spi.AbstractSpan;
import co.elastic.apm.agent.sdk.DynamicTransformer;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.method.MethodDescription;
diff --git a/apm-agent-plugins/apm-java-ldap-plugin/src/main/java/co/elastic/apm/agent/java_ldap/LdapClientAdvice.java b/apm-agent-plugins/apm-java-ldap-plugin/src/main/java/co/elastic/apm/agent/java_ldap/LdapClientAdvice.java
index 0240061aa40..cfb86808c49 100644
--- a/apm-agent-plugins/apm-java-ldap-plugin/src/main/java/co/elastic/apm/agent/java_ldap/LdapClientAdvice.java
+++ b/apm-agent-plugins/apm-java-ldap-plugin/src/main/java/co/elastic/apm/agent/java_ldap/LdapClientAdvice.java
@@ -18,13 +18,9 @@
*/
package co.elastic.apm.agent.java_ldap;
-import co.elastic.apm.agent.impl.GlobalTracer;
-import co.elastic.apm.agent.impl.Tracer;
-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 com.sun.jndi.ldap.Connection;
-import com.sun.jndi.ldap.LdapResult;
+import co.elastic.apm.plugin.spi.*;
+// TODO Rafael import com.sun.jndi.ldap.Connection;
+// TODO Rafael import com.sun.jndi.ldap.LdapResult;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.implementation.bytecode.assign.Assigner;
@@ -35,13 +31,13 @@ public class LdapClientAdvice {
private static final Tracer tracer = GlobalTracer.get();
@Advice.OnMethodEnter(suppress = Throwable.class, inline = false)
- public static Object onEnter(@Advice.Origin("#m") String methodName, @Advice.FieldValue(value = "conn", typing = Assigner.Typing.DYNAMIC) Connection connection) {
+ public static Object onEnter(@Advice.Origin("#m") String methodName, @Advice.FieldValue(value = "conn", typing = Assigner.Typing.DYNAMIC) Void connection) {
AbstractSpan> parent = tracer.getActive();
if (parent == null) {
return null;
}
- Span span = parent.createExitSpan();
+ Span> span = parent.createExitSpan();
if (span == null) {
return null;
}
@@ -51,20 +47,20 @@ public static Object onEnter(@Advice.Origin("#m") String methodName, @Advice.Fie
.withSubtype("ldap");
if (connection != null) {
- span.getContext().getDestination().withAddress(connection.host).withPort(connection.port);
- span.getContext().getServiceTarget().withType("ldap").withHostPortName(connection.host, connection.port);
+ //span.getContext().getDestination().withAddress(connection.host).withPort(connection.port);
+ //span.getContext().getServiceTarget().withType("ldap").withHostPortName(connection.host, connection.port);
}
return span.activate();
}
@Advice.OnMethodExit(suppress = Throwable.class, onThrowable = Throwable.class, inline = false)
- public static void onExit(@Advice.Enter @Nullable Object spanObj, @Nullable @Advice.Return LdapResult ldapResult, @Nullable @Advice.Thrown Throwable t) {
- Span span = (Span) spanObj;
+ public static void onExit(@Advice.Enter @Nullable Object spanObj, @Nullable @Advice.Return Void ldapResult, @Nullable @Advice.Thrown Throwable t) {
+ Span> span = (Span>) spanObj;
if (span != null) {
- span.withOutcome((ldapResult != null && ldapResult.status == 0 /* LDAP_SUCCESS */) ? Outcome.SUCCESS : Outcome.FAILURE)
- .captureException(t)
- .deactivate().end();
+ //span.withOutcome((ldapResult != null && ldapResult.status == 0 /* LDAP_SUCCESS */) ? DefaultOutcome.SUCCESS : DefaultOutcome.FAILURE)
+// .captureException(t)
+ // .deactivate().end();
}
}
}
diff --git a/apm-agent-plugins/apm-javalin-plugin/src/main/java/co/elastic/apm/agent/javalin/JavalinInstrumentation.java b/apm-agent-plugins/apm-javalin-plugin/src/main/java/co/elastic/apm/agent/javalin/JavalinInstrumentation.java
index 073e4ee064b..6b274018f9f 100644
--- a/apm-agent-plugins/apm-javalin-plugin/src/main/java/co/elastic/apm/agent/javalin/JavalinInstrumentation.java
+++ b/apm-agent-plugins/apm-javalin-plugin/src/main/java/co/elastic/apm/agent/javalin/JavalinInstrumentation.java
@@ -19,11 +19,11 @@
package co.elastic.apm.agent.javalin;
import co.elastic.apm.agent.bci.TracerAwareInstrumentation;
-import co.elastic.apm.agent.impl.GlobalTracer;
+import co.elastic.apm.plugin.spi.GlobalTracer;
import co.elastic.apm.agent.impl.context.web.WebConfiguration;
-import co.elastic.apm.agent.impl.transaction.AbstractSpan;
-import co.elastic.apm.agent.impl.transaction.Span;
-import co.elastic.apm.agent.impl.transaction.Transaction;
+import co.elastic.apm.plugin.spi.AbstractSpan;
+import co.elastic.apm.plugin.spi.Span;
+import co.elastic.apm.plugin.spi.Transaction;
import co.elastic.apm.agent.util.TransactionNameUtils;
import co.elastic.apm.agent.util.VersionUtils;
import io.javalin.http.Context;
@@ -45,7 +45,7 @@
import java.util.concurrent.CompletableFuture;
import static co.elastic.apm.agent.bci.bytebuddy.CustomElementMatchers.classLoaderCanLoadClass;
-import static co.elastic.apm.agent.impl.transaction.AbstractSpan.PRIO_HIGH_LEVEL_FRAMEWORK;
+import static co.elastic.apm.plugin.spi.AbstractSpan.PRIO_HIGH_LEVEL_FRAMEWORK;
import static net.bytebuddy.matcher.ElementMatchers.hasSuperType;
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
import static net.bytebuddy.matcher.ElementMatchers.named;
@@ -137,7 +137,7 @@ public static Object setSpanAndTransactionName(@Advice.This Handler handler,
return null;
}
- final Transaction transaction = tracer.currentTransaction();
+ final Transaction> transaction = tracer.currentTransaction();
if (transaction == null) {
return null;
}
@@ -183,7 +183,7 @@ public static void onAfterExecute(@Advice.Enter @Nullable Object spanObj,
@Advice.Argument(0) Context ctx,
@Advice.Thrown @Nullable Throwable t) {
if (spanObj != null) {
- final Span span = (Span) spanObj;
+ final Span> span = (Span>) spanObj;
span.deactivate();
final CompletableFuture> responseFuture = ctx.resultFuture();
diff --git a/apm-agent-plugins/apm-javalin-plugin/src/main/java/co/elastic/apm/agent/javalin/JavalinRenderInstrumentation.java b/apm-agent-plugins/apm-javalin-plugin/src/main/java/co/elastic/apm/agent/javalin/JavalinRenderInstrumentation.java
index 34938a38fb3..e0cd352b604 100644
--- a/apm-agent-plugins/apm-javalin-plugin/src/main/java/co/elastic/apm/agent/javalin/JavalinRenderInstrumentation.java
+++ b/apm-agent-plugins/apm-javalin-plugin/src/main/java/co/elastic/apm/agent/javalin/JavalinRenderInstrumentation.java
@@ -19,8 +19,8 @@
package co.elastic.apm.agent.javalin;
import co.elastic.apm.agent.bci.TracerAwareInstrumentation;
-import co.elastic.apm.agent.impl.transaction.AbstractSpan;
-import co.elastic.apm.agent.impl.transaction.Span;
+import co.elastic.apm.plugin.spi.AbstractSpan;
+import co.elastic.apm.plugin.spi.Span;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription;
@@ -89,7 +89,7 @@ public static Object setSpanName(@Advice.Argument(0) String template) {
public static void onAfterExecute(@Advice.Enter @Nullable Object spanObj,
@Advice.Thrown @Nullable Throwable t) {
if (spanObj != null) {
- final Span span = (Span) spanObj;
+ final Span> span = (Span>) spanObj;
span.deactivate();
span.captureException(t);
span.end();
diff --git a/apm-agent-plugins/apm-jaxrs-plugin/src/main/java/co/elastic/apm/agent/jaxrs/JakartaeeJaxRsTransactionNameInstrumentation.java b/apm-agent-plugins/apm-jaxrs-plugin/src/main/java/co/elastic/apm/agent/jaxrs/JakartaeeJaxRsTransactionNameInstrumentation.java
index 3cf822a10ec..c77735947bc 100644
--- a/apm-agent-plugins/apm-jaxrs-plugin/src/main/java/co/elastic/apm/agent/jaxrs/JakartaeeJaxRsTransactionNameInstrumentation.java
+++ b/apm-agent-plugins/apm-jaxrs-plugin/src/main/java/co/elastic/apm/agent/jaxrs/JakartaeeJaxRsTransactionNameInstrumentation.java
@@ -19,7 +19,7 @@
package co.elastic.apm.agent.jaxrs;
import co.elastic.apm.agent.bci.bytebuddy.SimpleMethodSignatureOffsetMappingFactory;
-import co.elastic.apm.agent.impl.Tracer;
+import co.elastic.apm.plugin.spi.Tracer;
import co.elastic.apm.agent.util.VersionUtils;
import net.bytebuddy.asm.Advice;
diff --git a/apm-agent-plugins/apm-jaxrs-plugin/src/main/java/co/elastic/apm/agent/jaxrs/JavaxJaxRsTransactionNameInstrumentation.java b/apm-agent-plugins/apm-jaxrs-plugin/src/main/java/co/elastic/apm/agent/jaxrs/JavaxJaxRsTransactionNameInstrumentation.java
index 33248197520..9ea9f0dd710 100644
--- a/apm-agent-plugins/apm-jaxrs-plugin/src/main/java/co/elastic/apm/agent/jaxrs/JavaxJaxRsTransactionNameInstrumentation.java
+++ b/apm-agent-plugins/apm-jaxrs-plugin/src/main/java/co/elastic/apm/agent/jaxrs/JavaxJaxRsTransactionNameInstrumentation.java
@@ -19,7 +19,7 @@
package co.elastic.apm.agent.jaxrs;
import co.elastic.apm.agent.bci.bytebuddy.SimpleMethodSignatureOffsetMappingFactory;
-import co.elastic.apm.agent.impl.Tracer;
+import co.elastic.apm.plugin.spi.Tracer;
import co.elastic.apm.agent.util.VersionUtils;
import net.bytebuddy.asm.Advice;
diff --git a/apm-agent-plugins/apm-jaxrs-plugin/src/main/java/co/elastic/apm/agent/jaxrs/JaxRsOffsetMappingFactory.java b/apm-agent-plugins/apm-jaxrs-plugin/src/main/java/co/elastic/apm/agent/jaxrs/JaxRsOffsetMappingFactory.java
index 14c7c8fb389..e9a53fa7c43 100644
--- a/apm-agent-plugins/apm-jaxrs-plugin/src/main/java/co/elastic/apm/agent/jaxrs/JaxRsOffsetMappingFactory.java
+++ b/apm-agent-plugins/apm-jaxrs-plugin/src/main/java/co/elastic/apm/agent/jaxrs/JaxRsOffsetMappingFactory.java
@@ -18,7 +18,7 @@
*/
package co.elastic.apm.agent.jaxrs;
-import co.elastic.apm.agent.impl.Tracer;
+import co.elastic.apm.plugin.spi.Tracer;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.annotation.AnnotationDescription;
import net.bytebuddy.description.annotation.AnnotationSource;
diff --git a/apm-agent-plugins/apm-jaxrs-plugin/src/main/java/co/elastic/apm/agent/jaxrs/JaxRsTransactionNameInstrumentation.java b/apm-agent-plugins/apm-jaxrs-plugin/src/main/java/co/elastic/apm/agent/jaxrs/JaxRsTransactionNameInstrumentation.java
index b49ec5cb934..254a27d0f17 100644
--- a/apm-agent-plugins/apm-jaxrs-plugin/src/main/java/co/elastic/apm/agent/jaxrs/JaxRsTransactionNameInstrumentation.java
+++ b/apm-agent-plugins/apm-jaxrs-plugin/src/main/java/co/elastic/apm/agent/jaxrs/JaxRsTransactionNameInstrumentation.java
@@ -19,10 +19,10 @@
package co.elastic.apm.agent.jaxrs;
import co.elastic.apm.agent.bci.TracerAwareInstrumentation;
-import co.elastic.apm.agent.impl.GlobalTracer;
-import co.elastic.apm.agent.impl.Tracer;
+import co.elastic.apm.plugin.spi.GlobalTracer;
+import co.elastic.apm.plugin.spi.Tracer;
import co.elastic.apm.agent.impl.stacktrace.StacktraceConfiguration;
-import co.elastic.apm.agent.impl.transaction.Transaction;
+import co.elastic.apm.plugin.spi.Transaction;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.NamedElement;
import net.bytebuddy.description.method.MethodDescription;
@@ -38,7 +38,7 @@
import static co.elastic.apm.agent.bci.bytebuddy.CustomElementMatchers.isInAnyPackage;
import static co.elastic.apm.agent.bci.bytebuddy.CustomElementMatchers.isProxy;
import static co.elastic.apm.agent.bci.bytebuddy.CustomElementMatchers.overridesOrImplementsMethodThat;
-import static co.elastic.apm.agent.impl.transaction.AbstractSpan.PRIO_HIGH_LEVEL_FRAMEWORK;
+import static co.elastic.apm.plugin.spi.AbstractSpan.PRIO_HIGH_LEVEL_FRAMEWORK;
import static net.bytebuddy.matcher.ElementMatchers.hasSuperType;
import static net.bytebuddy.matcher.ElementMatchers.isAnnotatedWith;
import static net.bytebuddy.matcher.ElementMatchers.isBootstrapClassLoader;
@@ -125,7 +125,7 @@ static class BaseAdvice {
.isUseJaxRsPathForTransactionName();
protected static void setTransactionName(String signature, @Nullable String pathAnnotationValue, @Nullable String frameworkVersion) {
- final Transaction transaction = TracerAwareInstrumentation.tracer.currentTransaction();
+ final Transaction> transaction = TracerAwareInstrumentation.tracer.currentTransaction();
if (transaction != null) {
String transactionName = signature;
if (useAnnotationValueForTransactionName) {
diff --git a/apm-agent-plugins/apm-jaxws-plugin/src/main/java/co/elastic/apm/agent/jaxws/JaxWsTransactionNameInstrumentation.java b/apm-agent-plugins/apm-jaxws-plugin/src/main/java/co/elastic/apm/agent/jaxws/JaxWsTransactionNameInstrumentation.java
index 6986f7504a7..eed00caf083 100644
--- a/apm-agent-plugins/apm-jaxws-plugin/src/main/java/co/elastic/apm/agent/jaxws/JaxWsTransactionNameInstrumentation.java
+++ b/apm-agent-plugins/apm-jaxws-plugin/src/main/java/co/elastic/apm/agent/jaxws/JaxWsTransactionNameInstrumentation.java
@@ -20,9 +20,9 @@
import co.elastic.apm.agent.bci.TracerAwareInstrumentation;
import co.elastic.apm.agent.bci.bytebuddy.SimpleMethodSignatureOffsetMappingFactory.SimpleMethodSignature;
-import co.elastic.apm.agent.impl.Tracer;
+import co.elastic.apm.plugin.spi.Tracer;
import co.elastic.apm.agent.impl.stacktrace.StacktraceConfiguration;
-import co.elastic.apm.agent.impl.transaction.Transaction;
+import co.elastic.apm.plugin.spi.Transaction;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.NamedElement;
import net.bytebuddy.description.method.MethodDescription;
@@ -37,7 +37,7 @@
import static co.elastic.apm.agent.bci.bytebuddy.CustomElementMatchers.isInAnyPackage;
import static co.elastic.apm.agent.bci.bytebuddy.CustomElementMatchers.isProxy;
import static co.elastic.apm.agent.bci.bytebuddy.CustomElementMatchers.overridesOrImplementsMethodThat;
-import static co.elastic.apm.agent.impl.transaction.AbstractSpan.PRIO_HIGH_LEVEL_FRAMEWORK;
+import static co.elastic.apm.plugin.spi.AbstractSpan.PRIO_HIGH_LEVEL_FRAMEWORK;
import static net.bytebuddy.matcher.ElementMatchers.isAnnotatedWith;
import static net.bytebuddy.matcher.ElementMatchers.isBootstrapClassLoader;
import static net.bytebuddy.matcher.ElementMatchers.isDeclaredBy;
@@ -59,7 +59,7 @@ public JaxWsTransactionNameInstrumentation(Tracer tracer) {
public static class AdviceClass {
@Advice.OnMethodEnter(suppress = Throwable.class, inline = false)
public static void setTransactionName(@SimpleMethodSignature String signature) {
- final Transaction transaction = tracer.currentTransaction();
+ final Transaction> transaction = tracer.currentTransaction();
if (transaction != null) {
transaction.withName(signature, PRIO_HIGH_LEVEL_FRAMEWORK, false);
transaction.setFrameworkName(FRAMEWORK_NAME);
diff --git a/apm-agent-plugins/apm-jdbc-plugin/src/main/java/co/elastic/apm/agent/jdbc/StatementInstrumentation.java b/apm-agent-plugins/apm-jdbc-plugin/src/main/java/co/elastic/apm/agent/jdbc/StatementInstrumentation.java
index 28d1fa242e0..6432f0dff1b 100644
--- a/apm-agent-plugins/apm-jdbc-plugin/src/main/java/co/elastic/apm/agent/jdbc/StatementInstrumentation.java
+++ b/apm-agent-plugins/apm-jdbc-plugin/src/main/java/co/elastic/apm/agent/jdbc/StatementInstrumentation.java
@@ -18,8 +18,7 @@
*/
package co.elastic.apm.agent.jdbc;
-import co.elastic.apm.agent.impl.Tracer;
-import co.elastic.apm.agent.impl.transaction.Span;
+import co.elastic.apm.plugin.spi.Span;
import co.elastic.apm.agent.jdbc.helper.JdbcHelper;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.NamedElement;
@@ -82,7 +81,7 @@ public ElementMatcher super MethodDescription> getMethodMatcher() {
@SuppressWarnings("DuplicatedCode")
public static class ExecuteWithQueryInstrumentation extends StatementInstrumentation {
- public ExecuteWithQueryInstrumentation(Tracer tracer) {
+ public ExecuteWithQueryInstrumentation() {
super(
named("execute").or(named("executeQuery"))
.and(takesArgument(0, String.class))
@@ -108,7 +107,7 @@ public static void onAfterExecute(@Advice.This Statement statement,
return;
}
- ((Span) span).captureException(t)
+ ((Span>) span).captureException(t)
.deactivate()
.end();
@@ -131,7 +130,7 @@ public static void onAfterExecute(@Advice.This Statement statement,
*/
public static class ExecuteUpdateWithQueryInstrumentation extends StatementInstrumentation {
- public ExecuteUpdateWithQueryInstrumentation(Tracer tracer) {
+ public ExecuteUpdateWithQueryInstrumentation() {
super(
named("executeUpdate").or(named("executeLargeUpdate"))
.and(takesArgument(0, String.class))
@@ -157,12 +156,12 @@ public static void onAfterExecute(@Advice.Enter @Nullable Object span,
}
if (t == null) {
- ((Span) span).getContext()
+ ((Span>) span).getContext()
.getDb()
.withAffectedRowsCount(returnValue);
}
- ((Span) span).captureException(t)
+ ((Span>) span).captureException(t)
.deactivate()
.end();
}
@@ -174,7 +173,7 @@ public static void onAfterExecute(@Advice.Enter @Nullable Object span,
*/
public static class AddBatchInstrumentation extends StatementInstrumentation {
- public AddBatchInstrumentation(Tracer tracer) {
+ public AddBatchInstrumentation() {
super(
nameStartsWith("addBatch")
.and(takesArgument(0, String.class))
@@ -200,7 +199,7 @@ public static void storeSql(@Advice.This Statement statement, @Advice.Argument(0
*
*/
public static class ExecuteBatchInstrumentation extends StatementInstrumentation {
- public ExecuteBatchInstrumentation(Tracer tracer) {
+ public ExecuteBatchInstrumentation() {
super(
named("executeBatch").or(named("executeLargeBatch"))
.and(takesArguments(0))
@@ -224,10 +223,10 @@ public static Object onBeforeExecute(@Advice.This Statement statement) {
public static void onAfterExecute(@Advice.Enter @Nullable Object spanObj,
@Advice.Thrown @Nullable Throwable t,
@Advice.Return @Nullable Object returnValue) {
- if (!(spanObj instanceof Span)) {
+ if (!(spanObj instanceof Span>)) {
return;
}
- Span span = (Span) spanObj;
+ Span> span = (Span>) spanObj;
// for 'executeBatch' and 'executeLargeBatch', we have to compute the sum as Statement.getUpdateCount()
// does not seem to return the sum of all elements. As we can use instanceof to check return type
@@ -265,7 +264,7 @@ public static void onAfterExecute(@Advice.Enter @Nullable Object spanObj,
*
*/
public static class ExecuteUpdateNoQueryInstrumentation extends StatementInstrumentation {
- public ExecuteUpdateNoQueryInstrumentation(Tracer tracer) {
+ public ExecuteUpdateNoQueryInstrumentation() {
super(
named("executeUpdate").or(named("executeLargeUpdate"))
.and(takesArguments(0))
@@ -293,12 +292,12 @@ public static void onAfterExecute(@Advice.Enter @Nullable Object span,
}
if (t == null) {
- ((Span) span).getContext()
+ ((Span>) span).getContext()
.getDb()
.withAffectedRowsCount(returnValue);
}
- ((Span) span).captureException(t)
+ ((Span>) span).captureException(t)
.deactivate()
.end();
}
@@ -313,7 +312,7 @@ public static void onAfterExecute(@Advice.Enter @Nullable Object span,
*
*/
public static class ExecutePreparedStatementInstrumentation extends StatementInstrumentation {
- public ExecutePreparedStatementInstrumentation(Tracer tracer) {
+ public ExecutePreparedStatementInstrumentation() {
super(
named("execute").or(named("executeQuery"))
.and(takesArguments(0))
@@ -340,7 +339,7 @@ public static void onAfterExecute(@Advice.This Statement statement,
return;
}
- ((Span) span).captureException(t)
+ ((Span>) span).captureException(t)
.deactivate()
.end();
}
@@ -355,7 +354,7 @@ public static void onAfterExecute(@Advice.This Statement statement,
*/
public static class CloseStatementInstrumentation extends StatementInstrumentation {
- public CloseStatementInstrumentation(Tracer tracer) {
+ public CloseStatementInstrumentation() {
super(
named("close")
.and(takesArguments(0))
diff --git a/apm-agent-plugins/apm-jdbc-plugin/src/main/java/co/elastic/apm/agent/jdbc/helper/JdbcHelper.java b/apm-agent-plugins/apm-jdbc-plugin/src/main/java/co/elastic/apm/agent/jdbc/helper/JdbcHelper.java
index 3283b035449..833d297ab2f 100644
--- a/apm-agent-plugins/apm-jdbc-plugin/src/main/java/co/elastic/apm/agent/jdbc/helper/JdbcHelper.java
+++ b/apm-agent-plugins/apm-jdbc-plugin/src/main/java/co/elastic/apm/agent/jdbc/helper/JdbcHelper.java
@@ -20,8 +20,8 @@
import co.elastic.apm.agent.db.signature.Scanner;
import co.elastic.apm.agent.db.signature.SignatureParser;
-import co.elastic.apm.agent.impl.transaction.AbstractSpan;
-import co.elastic.apm.agent.impl.transaction.Span;
+import co.elastic.apm.plugin.spi.AbstractSpan;
+import co.elastic.apm.plugin.spi.Span;
import co.elastic.apm.agent.jdbc.JdbcFilter;
import co.elastic.apm.agent.sdk.logging.Logger;
import co.elastic.apm.agent.sdk.logging.LoggerFactory;
@@ -81,12 +81,12 @@ public String retrieveSqlForStatement(Object statement) {
@Nullable
- public Span createJdbcSpan(@Nullable String sql, Object statement, @Nullable AbstractSpan> parent, boolean preparedStatement) {
+ public Span> createJdbcSpan(@Nullable String sql, Object statement, @Nullable AbstractSpan> parent, boolean preparedStatement) {
if (!(statement instanceof Statement) || sql == null || isAlreadyMonitored(parent) || parent == null) {
return null;
}
- Span span = parent.createExitSpan();
+ Span> span = parent.createExitSpan();
if (span == null) {
return null;
} else {
@@ -141,10 +141,10 @@ public Span createJdbcSpan(@Nullable String sql, Object statement, @Nullable Abs
* we only record each JDBC call once.
*/
private boolean isAlreadyMonitored(@Nullable AbstractSpan> parent) {
- if (!(parent instanceof Span)) {
+ if (!(parent instanceof Span>)) {
return false;
}
- Span parentSpan = (Span) parent;
+ Span> parentSpan = (Span>) parent;
// a db span can't be the child of another db span
// this means the span has already been created for this db call
return parentSpan.getType() != null && parentSpan.getType().equals(DB_SPAN_TYPE);
diff --git a/apm-agent-plugins/apm-jdk-httpclient-plugin/src/main/java/co/elastic/apm/agent/httpclient/HttpClientAdvice.java b/apm-agent-plugins/apm-jdk-httpclient-plugin/src/main/java/co/elastic/apm/agent/httpclient/HttpClientAdvice.java
index a8629418cfe..d1abe35dd4a 100644
--- a/apm-agent-plugins/apm-jdk-httpclient-plugin/src/main/java/co/elastic/apm/agent/httpclient/HttpClientAdvice.java
+++ b/apm-agent-plugins/apm-jdk-httpclient-plugin/src/main/java/co/elastic/apm/agent/httpclient/HttpClientAdvice.java
@@ -18,7 +18,7 @@
*/
package co.elastic.apm.agent.httpclient;
-import co.elastic.apm.agent.impl.transaction.Span;
+import co.elastic.apm.plugin.spi.Span;
import net.bytebuddy.asm.Advice;
import javax.annotation.Nullable;
@@ -36,8 +36,8 @@ public static Object onBeforeExecute(@Advice.Argument(value = 0) HttpRequest htt
public static void onAfterExecute(@Advice.Return @Nullable HttpResponse> response,
@Advice.Enter @Nullable Object spanObj,
@Advice.Thrown @Nullable Throwable t) {
- if (spanObj instanceof Span) {
- final Span span = (Span) spanObj;
+ if (spanObj instanceof Span>) {
+ final Span> span = (Span>) spanObj;
if (response != null) {
int statusCode = response.statusCode();
span.getContext().getHttp().withStatusCode(statusCode);
diff --git a/apm-agent-plugins/apm-jdk-httpclient-plugin/src/main/java/co/elastic/apm/agent/httpclient/HttpClientAdviceHelper.java b/apm-agent-plugins/apm-jdk-httpclient-plugin/src/main/java/co/elastic/apm/agent/httpclient/HttpClientAdviceHelper.java
index abdfa7f46be..cb6675dabdc 100644
--- a/apm-agent-plugins/apm-jdk-httpclient-plugin/src/main/java/co/elastic/apm/agent/httpclient/HttpClientAdviceHelper.java
+++ b/apm-agent-plugins/apm-jdk-httpclient-plugin/src/main/java/co/elastic/apm/agent/httpclient/HttpClientAdviceHelper.java
@@ -18,10 +18,10 @@
*/
package co.elastic.apm.agent.httpclient;
-import co.elastic.apm.agent.impl.GlobalTracer;
-import co.elastic.apm.agent.impl.Tracer;
-import co.elastic.apm.agent.impl.transaction.AbstractSpan;
-import co.elastic.apm.agent.impl.transaction.Span;
+import co.elastic.apm.plugin.spi.GlobalTracer;
+import co.elastic.apm.plugin.spi.Tracer;
+import co.elastic.apm.plugin.spi.AbstractSpan;
+import co.elastic.apm.plugin.spi.Span;
import javax.annotation.Nullable;
import java.net.URI;
@@ -32,14 +32,14 @@ public class HttpClientAdviceHelper {
private static final Tracer tracer = GlobalTracer.get();
@Nullable
- public static Span startSpan(HttpRequest httpRequest) {
+ public static Span> startSpan(HttpRequest httpRequest) {
final AbstractSpan> parent = tracer.getActive();
if (parent == null) {
return null;
}
URI uri = httpRequest.uri();
- Span span = HttpClientHelper.startHttpClientSpan(parent, httpRequest.method(), uri, uri.getHost());
+ Span> span = HttpClientHelper.startHttpClientSpan(parent, httpRequest.method(), uri, uri.getHost());
if (span != null) {
span.activate();
}
diff --git a/apm-agent-plugins/apm-jdk-httpclient-plugin/src/main/java/co/elastic/apm/agent/httpclient/HttpClientAsyncAdvice.java b/apm-agent-plugins/apm-jdk-httpclient-plugin/src/main/java/co/elastic/apm/agent/httpclient/HttpClientAsyncAdvice.java
index 831d6f07f21..9019fe89e26 100644
--- a/apm-agent-plugins/apm-jdk-httpclient-plugin/src/main/java/co/elastic/apm/agent/httpclient/HttpClientAsyncAdvice.java
+++ b/apm-agent-plugins/apm-jdk-httpclient-plugin/src/main/java/co/elastic/apm/agent/httpclient/HttpClientAsyncAdvice.java
@@ -18,7 +18,7 @@
*/
package co.elastic.apm.agent.httpclient;
-import co.elastic.apm.agent.impl.transaction.Span;
+import co.elastic.apm.plugin.spi.Span;
import net.bytebuddy.asm.Advice;
import javax.annotation.Nullable;
@@ -37,8 +37,8 @@ public static Object onBeforeExecute(@Advice.Argument(value = 0) HttpRequest htt
public static void onAfterExecute(@Advice.Return @Nullable CompletableFuture> completableFuture,
@Advice.Enter @Nullable Object spanObj,
@Advice.Thrown @Nullable Throwable t) {
- if (spanObj instanceof Span) {
- final Span span = (Span) spanObj;
+ if (spanObj instanceof Span>) {
+ final Span> span = (Span>) spanObj;
span.deactivate();
if (completableFuture == null) {
span.captureException(t)
diff --git a/apm-agent-plugins/apm-jdk-httpclient-plugin/src/main/java/co/elastic/apm/agent/httpclient/HttpClientRequestPropertyAccessor.java b/apm-agent-plugins/apm-jdk-httpclient-plugin/src/main/java/co/elastic/apm/agent/httpclient/HttpClientRequestPropertyAccessor.java
index 5eee00194a2..29a0bce6e37 100644
--- a/apm-agent-plugins/apm-jdk-httpclient-plugin/src/main/java/co/elastic/apm/agent/httpclient/HttpClientRequestPropertyAccessor.java
+++ b/apm-agent-plugins/apm-jdk-httpclient-plugin/src/main/java/co/elastic/apm/agent/httpclient/HttpClientRequestPropertyAccessor.java
@@ -18,7 +18,7 @@
*/
package co.elastic.apm.agent.httpclient;
-import co.elastic.apm.agent.impl.transaction.TextHeaderSetter;
+import co.elastic.apm.plugin.spi.TextHeaderSetter;
import java.util.Collections;
import java.util.List;
diff --git a/apm-agent-plugins/apm-jdk-httpclient-plugin/src/main/java/co/elastic/apm/agent/httpclient/HttpRequestHeadersAdvice.java b/apm-agent-plugins/apm-jdk-httpclient-plugin/src/main/java/co/elastic/apm/agent/httpclient/HttpRequestHeadersAdvice.java
index ebae9e54eb2..c91643093ae 100644
--- a/apm-agent-plugins/apm-jdk-httpclient-plugin/src/main/java/co/elastic/apm/agent/httpclient/HttpRequestHeadersAdvice.java
+++ b/apm-agent-plugins/apm-jdk-httpclient-plugin/src/main/java/co/elastic/apm/agent/httpclient/HttpRequestHeadersAdvice.java
@@ -18,9 +18,9 @@
*/
package co.elastic.apm.agent.httpclient;
-import co.elastic.apm.agent.impl.GlobalTracer;
-import co.elastic.apm.agent.impl.Tracer;
-import co.elastic.apm.agent.impl.transaction.Span;
+import co.elastic.apm.plugin.spi.GlobalTracer;
+import co.elastic.apm.plugin.spi.Tracer;
+import co.elastic.apm.plugin.spi.Span;
import net.bytebuddy.asm.Advice;
import javax.annotation.Nullable;
@@ -37,7 +37,7 @@ public class HttpRequestHeadersAdvice {
@Advice.AssignReturned.ToReturned
@Advice.OnMethodExit(suppress = Throwable.class, onThrowable = Throwable.class, inline = false)
public static HttpHeaders onAfterExecute(@Advice.Return @Nullable final HttpHeaders httpHeaders) {
- Span span = tracer.getActiveSpan();
+ Span> span = tracer.getActiveSpan();
if (span == null || httpHeaders == null) { // in case of thrown exception return value might be null
return httpHeaders;
}
diff --git a/apm-agent-plugins/apm-jdk-httpserver-plugin/src/main/java/co/elastic/apm/agent/httpserver/HeadersHeaderGetter.java b/apm-agent-plugins/apm-jdk-httpserver-plugin/src/main/java/co/elastic/apm/agent/httpserver/HeadersHeaderGetter.java
index 0902635b6d1..87ec58d0223 100644
--- a/apm-agent-plugins/apm-jdk-httpserver-plugin/src/main/java/co/elastic/apm/agent/httpserver/HeadersHeaderGetter.java
+++ b/apm-agent-plugins/apm-jdk-httpserver-plugin/src/main/java/co/elastic/apm/agent/httpserver/HeadersHeaderGetter.java
@@ -18,8 +18,8 @@
*/
package co.elastic.apm.agent.httpserver;
-import co.elastic.apm.agent.impl.transaction.AbstractHeaderGetter;
-import co.elastic.apm.agent.impl.transaction.TextHeaderGetter;
+import co.elastic.apm.plugin.spi.AbstractHeaderGetter;
+import co.elastic.apm.plugin.spi.TextHeaderGetter;
import com.sun.net.httpserver.Headers;
import javax.annotation.Nullable;
diff --git a/apm-agent-plugins/apm-jdk-httpserver-plugin/src/main/java/co/elastic/apm/agent/httpserver/HttpHandlerAdvice.java b/apm-agent-plugins/apm-jdk-httpserver-plugin/src/main/java/co/elastic/apm/agent/httpserver/HttpHandlerAdvice.java
index 1e26f7398be..16fdd04eba1 100644
--- a/apm-agent-plugins/apm-jdk-httpserver-plugin/src/main/java/co/elastic/apm/agent/httpserver/HttpHandlerAdvice.java
+++ b/apm-agent-plugins/apm-jdk-httpserver-plugin/src/main/java/co/elastic/apm/agent/httpserver/HttpHandlerAdvice.java
@@ -19,14 +19,8 @@
package co.elastic.apm.agent.httpserver;
import co.elastic.apm.agent.configuration.CoreConfiguration;
-import co.elastic.apm.agent.impl.GlobalTracer;
-import co.elastic.apm.agent.impl.Tracer;
-import co.elastic.apm.agent.impl.context.Request;
-import co.elastic.apm.agent.impl.context.Response;
-import co.elastic.apm.agent.impl.context.web.ResultUtil;
+import co.elastic.apm.plugin.spi.*;
import co.elastic.apm.agent.impl.context.web.WebConfiguration;
-import co.elastic.apm.agent.impl.transaction.AbstractSpan;
-import co.elastic.apm.agent.impl.transaction.Transaction;
import co.elastic.apm.agent.util.TransactionNameUtils;
import com.sun.net.httpserver.Headers;
import com.sun.net.httpserver.HttpExchange;
@@ -61,7 +55,7 @@ public static Object onEnterHandle(@Advice.Argument(0) HttpExchange exchange) {
return null;
}
- Transaction transaction = tracer.startChildTransaction(exchange.getRequestHeaders(), HeadersHeaderGetter.INSTANCE, Thread.currentThread().getContextClassLoader());
+ Transaction> transaction = tracer.startChildTransaction(exchange.getRequestHeaders(), HeadersHeaderGetter.INSTANCE, Thread.currentThread().getContextClassLoader());
if (transaction == null) {
return null;
}
@@ -132,7 +126,7 @@ public static void onExitHandle(@Advice.Argument(0) HttpExchange exchange, @Advi
return;
}
- Transaction transaction = (Transaction) transactionOrNull;
+ Transaction> transaction = (Transaction>) transactionOrNull;
transaction
.withResultIfUnset(ResultUtil.getResultByHttpStatus(exchange.getResponseCode()))
.captureException(t);
diff --git a/apm-agent-plugins/apm-jms-plugin/apm-jms-plugin-base/src/main/java/co/elastic/apm/agent/jms/BaseJmsInstrumentation.java b/apm-agent-plugins/apm-jms-plugin/apm-jms-plugin-base/src/main/java/co/elastic/apm/agent/jms/BaseJmsInstrumentation.java
index de8bb910865..63d10be7d35 100644
--- a/apm-agent-plugins/apm-jms-plugin/apm-jms-plugin-base/src/main/java/co/elastic/apm/agent/jms/BaseJmsInstrumentation.java
+++ b/apm-agent-plugins/apm-jms-plugin/apm-jms-plugin-base/src/main/java/co/elastic/apm/agent/jms/BaseJmsInstrumentation.java
@@ -21,8 +21,8 @@
import co.elastic.apm.agent.bci.TracerAwareInstrumentation;
import co.elastic.apm.agent.configuration.CoreConfiguration;
import co.elastic.apm.agent.configuration.MessagingConfiguration;
-import co.elastic.apm.agent.impl.GlobalTracer;
-import co.elastic.apm.agent.impl.Tracer;
+import co.elastic.apm.plugin.spi.GlobalTracer;
+import co.elastic.apm.plugin.spi.Tracer;
import net.bytebuddy.matcher.ElementMatcher;
import java.util.Collection;
diff --git a/apm-agent-plugins/apm-jms-plugin/apm-jms-plugin-base/src/main/java/co/elastic/apm/agent/jms/JmsInstrumentationHelper.java b/apm-agent-plugins/apm-jms-plugin/apm-jms-plugin-base/src/main/java/co/elastic/apm/agent/jms/JmsInstrumentationHelper.java
index d0927d081a2..ca25a4cae05 100644
--- a/apm-agent-plugins/apm-jms-plugin/apm-jms-plugin-base/src/main/java/co/elastic/apm/agent/jms/JmsInstrumentationHelper.java
+++ b/apm-agent-plugins/apm-jms-plugin/apm-jms-plugin-base/src/main/java/co/elastic/apm/agent/jms/JmsInstrumentationHelper.java
@@ -20,11 +20,7 @@
import co.elastic.apm.agent.configuration.CoreConfiguration;
import co.elastic.apm.agent.configuration.MessagingConfiguration;
-import co.elastic.apm.agent.impl.Tracer;
-import co.elastic.apm.agent.impl.transaction.AbstractSpan;
-import co.elastic.apm.agent.impl.transaction.Span;
-import co.elastic.apm.agent.impl.transaction.TraceContext;
-import co.elastic.apm.agent.impl.transaction.Transaction;
+import co.elastic.apm.plugin.spi.*;
import co.elastic.apm.agent.common.util.WildcardMatcher;
import co.elastic.apm.agent.sdk.logging.Logger;
import co.elastic.apm.agent.sdk.logging.LoggerFactory;
@@ -96,7 +92,7 @@ public JmsInstrumentationHelper(Tracer tracer) {
@SuppressWarnings("Duplicates")
@Nullable
- public Span startJmsSendSpan(Destination destination, Message message) {
+ public Span> startJmsSendSpan(Destination destination, Message message) {
final AbstractSpan> activeSpan = tracer.getActive();
if (activeSpan == null) {
@@ -113,7 +109,7 @@ public Span startJmsSendSpan(Destination destination, Message message) {
return null;
}
- Span span = activeSpan.createExitSpan();
+ Span> span = activeSpan.createExitSpan();
if (span == null) {
return null;
@@ -143,16 +139,16 @@ public Span startJmsSendSpan(Destination destination, Message message) {
}
@Nullable
- public Transaction startJmsTransaction(Message parentMessage, Class> instrumentedClass) {
- Transaction transaction = tracer.startChildTransaction(parentMessage, JmsMessagePropertyAccessor.instance(), PrivilegedActionUtils.getClassLoader(instrumentedClass));
+ public Transaction> startJmsTransaction(Message parentMessage, Class> instrumentedClass) {
+ Transaction> transaction = tracer.startChildTransaction(parentMessage, JmsMessagePropertyAccessor.instance(), PrivilegedActionUtils.getClassLoader(instrumentedClass));
if (transaction != null) {
transaction.setFrameworkName(FRAMEWORK_NAME);
}
return transaction;
}
- public void makeChildOf(Transaction childTransaction, Message parentMessage) {
- TraceContext.getFromTraceContextTextHeaders().asChildOf(childTransaction.getTraceContext(), parentMessage, JmsMessagePropertyAccessor.instance());
+ public void makeChildOf(Transaction> childTransaction, Message parentMessage) {
+ TraceContextUtil.getFromTraceContextTextHeaders().asChildOf(childTransaction.getTraceContext(), parentMessage, JmsMessagePropertyAccessor.instance());
}
@Nullable
@@ -244,7 +240,7 @@ public void addMessageDetails(@Nullable Message message, AbstractSpan> span) {
return;
}
try {
- co.elastic.apm.agent.impl.context.Message messageContext = span.getContext().getMessage();
+ co.elastic.apm.plugin.spi.Message messageContext = span.getContext().getMessage();
// Currently only capturing body of TextMessages. The javax.jms.Message#getBody() API is since 2.0, so,
// if we are supporting JMS 1.1, it makes no sense to rely on isAssignableFrom.
@@ -258,7 +254,7 @@ public void addMessageDetails(@Nullable Message message, AbstractSpan> span) {
messageContext.addHeader(JMS_EXPIRATION_HEADER, String.valueOf(message.getJMSExpiration()));
messageContext.addHeader(JMS_TIMESTAMP_HEADER, String.valueOf(message.getJMSTimestamp()));
- Enumeration properties = message.getPropertyNames();
+ Enumeration> properties = message.getPropertyNames();
if (properties != null) {
while (properties.hasMoreElements()) {
String propertyName = String.valueOf(properties.nextElement());
diff --git a/apm-agent-plugins/apm-jms-plugin/apm-jms-plugin-base/src/main/java/co/elastic/apm/agent/jms/JmsMessageConsumerInstrumentation.java b/apm-agent-plugins/apm-jms-plugin/apm-jms-plugin-base/src/main/java/co/elastic/apm/agent/jms/JmsMessageConsumerInstrumentation.java
index c18fe4a168f..3106c0bc6c1 100644
--- a/apm-agent-plugins/apm-jms-plugin/apm-jms-plugin-base/src/main/java/co/elastic/apm/agent/jms/JmsMessageConsumerInstrumentation.java
+++ b/apm-agent-plugins/apm-jms-plugin/apm-jms-plugin-base/src/main/java/co/elastic/apm/agent/jms/JmsMessageConsumerInstrumentation.java
@@ -19,10 +19,10 @@
package co.elastic.apm.agent.jms;
import co.elastic.apm.agent.configuration.MessagingConfiguration;
-import co.elastic.apm.agent.impl.transaction.AbstractSpan;
-import co.elastic.apm.agent.impl.transaction.Span;
-import co.elastic.apm.agent.impl.transaction.TraceContext;
-import co.elastic.apm.agent.impl.transaction.Transaction;
+import co.elastic.apm.plugin.spi.AbstractSpan;
+import co.elastic.apm.plugin.spi.Span;
+import co.elastic.apm.plugin.spi.TraceContextUtil;
+import co.elastic.apm.plugin.spi.Transaction;
import co.elastic.apm.agent.util.PrivilegedActionUtils;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.asm.Advice.AssignReturned.ToArguments.ToArgument;
@@ -97,8 +97,8 @@ public static Object beforeReceive(@Advice.Origin Class> clazz,
if (parent == null) {
createPollingTransaction = true;
} else {
- if (parent instanceof Transaction) {
- Transaction transaction = (Transaction) parent;
+ if (parent instanceof Transaction>) {
+ Transaction> transaction = (Transaction>) parent;
if (MESSAGE_POLLING.equals(transaction.getType())) {
// Avoid duplications for nested calls
return null;
@@ -111,8 +111,8 @@ public static Object beforeReceive(@Advice.Origin Class> clazz,
} else {
createPollingSpan = true;
}
- } else if (parent instanceof Span) {
- Span parentSpan = (Span) parent;
+ } else if (parent instanceof Span>) {
+ Span> parentSpan = (Span>) parent;
if (MESSAGING_TYPE.equals(parentSpan.getType()) && "receive".equals(parentSpan.getAction())) {
// Avoid duplication for nested calls
return null;
@@ -132,7 +132,7 @@ public static Object beforeReceive(@Advice.Origin Class> clazz,
} else if (createPollingTransaction) {
createdSpan = tracer.startRootTransaction(PrivilegedActionUtils.getClassLoader(clazz));
if (createdSpan != null) {
- ((Transaction) createdSpan).withType(MESSAGE_POLLING);
+ ((Transaction>) createdSpan).withType(MESSAGE_POLLING);
}
}
@@ -166,8 +166,8 @@ public static void afterReceive(@Advice.Origin Class> clazz,
logger.error("Failed to retrieve meta info from Message", e);
}
- if (abstractSpan instanceof Transaction) {
- Transaction transaction = (Transaction) abstractSpan;
+ if (abstractSpan instanceof Transaction>) {
+ Transaction> transaction = (Transaction>) abstractSpan;
if (discard) {
transaction.ignoreTransaction();
} else {
@@ -177,14 +177,14 @@ public static void afterReceive(@Advice.Origin Class> clazz,
}
} else if (abstractSpan != null) {
abstractSpan.addSpanLink(
- TraceContext.getFromTraceContextTextHeaders(),
+ TraceContextUtil.getFromTraceContextTextHeaders(),
JmsMessagePropertyAccessor.instance(),
message
);
}
- } else if (abstractSpan instanceof Transaction) {
+ } else if (abstractSpan instanceof Transaction>) {
// Do not report polling transactions if not yielding messages
- ((Transaction) abstractSpan).ignoreTransaction();
+ ((Transaction>) abstractSpan).ignoreTransaction();
addDetails = false;
}
@@ -210,7 +210,7 @@ public static void afterReceive(@Advice.Origin Class> clazz,
&& messagingConfiguration.getMessagePollingTransactionStrategy() != MessagingConfiguration.JmsStrategy.POLLING
&& !"receiveNoWait".equals(methodName)) {
- Transaction messageHandlingTransaction = helper.startJmsTransaction(message, clazz);
+ Transaction> messageHandlingTransaction = helper.startJmsTransaction(message, clazz);
if (messageHandlingTransaction != null) {
messageHandlingTransaction.withType(MESSAGE_HANDLING)
.withName(RECEIVE_NAME_PREFIX);
diff --git a/apm-agent-plugins/apm-jms-plugin/apm-jms-plugin-base/src/main/java/co/elastic/apm/agent/jms/JmsMessageListenerInstrumentation.java b/apm-agent-plugins/apm-jms-plugin/apm-jms-plugin-base/src/main/java/co/elastic/apm/agent/jms/JmsMessageListenerInstrumentation.java
index 2ba130b5d63..ad78a9722df 100644
--- a/apm-agent-plugins/apm-jms-plugin/apm-jms-plugin-base/src/main/java/co/elastic/apm/agent/jms/JmsMessageListenerInstrumentation.java
+++ b/apm-agent-plugins/apm-jms-plugin/apm-jms-plugin-base/src/main/java/co/elastic/apm/agent/jms/JmsMessageListenerInstrumentation.java
@@ -19,8 +19,8 @@
package co.elastic.apm.agent.jms;
import co.elastic.apm.agent.configuration.MessagingConfiguration;
-import co.elastic.apm.agent.impl.Tracer;
-import co.elastic.apm.agent.impl.transaction.Transaction;
+import co.elastic.apm.plugin.spi.Tracer;
+import co.elastic.apm.plugin.spi.Transaction;
import co.elastic.apm.agent.sdk.logging.Logger;
import co.elastic.apm.agent.sdk.logging.LoggerFactory;
import net.bytebuddy.asm.Advice;
@@ -123,7 +123,7 @@ public static Object beforeOnMessage(@Advice.Argument(0) @Nullable final Message
}
// Create a transaction - even if running on same JVM as the sender
- Transaction transaction = helper.startJmsTransaction(message, clazz);
+ Transaction> transaction = helper.startJmsTransaction(message, clazz);
if (transaction != null) {
transaction.withType(MESSAGING_TYPE)
.withName(RECEIVE_NAME_PREFIX);
@@ -143,8 +143,8 @@ public static Object beforeOnMessage(@Advice.Argument(0) @Nullable final Message
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class, inline = false)
public static void afterOnMessage(@Advice.Enter @Nullable final Object transactionObj,
@Advice.Thrown final Throwable throwable) {
- if (transactionObj instanceof Transaction) {
- Transaction transaction = (Transaction) transactionObj;
+ if (transactionObj instanceof Transaction>) {
+ Transaction> transaction = (Transaction>) transactionObj;
transaction.captureException(throwable);
transaction.deactivate().end();
}
diff --git a/apm-agent-plugins/apm-jms-plugin/apm-jms-plugin-base/src/main/java/co/elastic/apm/agent/jms/JmsMessageProducerInstrumentation.java b/apm-agent-plugins/apm-jms-plugin/apm-jms-plugin-base/src/main/java/co/elastic/apm/agent/jms/JmsMessageProducerInstrumentation.java
index cfa8f3fec4d..1fadff1a87f 100644
--- a/apm-agent-plugins/apm-jms-plugin/apm-jms-plugin-base/src/main/java/co/elastic/apm/agent/jms/JmsMessageProducerInstrumentation.java
+++ b/apm-agent-plugins/apm-jms-plugin/apm-jms-plugin-base/src/main/java/co/elastic/apm/agent/jms/JmsMessageProducerInstrumentation.java
@@ -18,7 +18,7 @@
*/
package co.elastic.apm.agent.jms;
-import co.elastic.apm.agent.impl.transaction.Span;
+import co.elastic.apm.plugin.spi.Span;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.NamedElement;
import net.bytebuddy.description.method.MethodDescription;
@@ -96,8 +96,8 @@ public static Object beforeSend(@Advice.Argument(0) final Message message,
public static void afterSend(@Advice.Enter @Nullable final Object spanObj,
@Advice.Thrown final Throwable throwable) {
- if (spanObj instanceof Span) {
- Span span = (Span) spanObj;
+ if (spanObj instanceof Span>) {
+ Span> span = (Span>) spanObj;
span.captureException(throwable);
span.deactivate().end();
}
@@ -133,8 +133,8 @@ public static Object startSpan(@Advice.Argument(0) final Destination destination
public static void endSpan(@Advice.Enter @Nullable final Object spanObj,
@Advice.Thrown final Throwable throwable) {
- if (spanObj instanceof Span) {
- Span span = (Span) spanObj;
+ if (spanObj instanceof Span>) {
+ Span> span = (Span>) spanObj;
span.captureException(throwable);
span.deactivate().end();
}
diff --git a/apm-agent-plugins/apm-jms-plugin/apm-jms-plugin-base/src/main/java/co/elastic/apm/agent/jms/JmsMessagePropertyAccessor.java b/apm-agent-plugins/apm-jms-plugin/apm-jms-plugin-base/src/main/java/co/elastic/apm/agent/jms/JmsMessagePropertyAccessor.java
index ee0b5c6ea9d..7ff873d47f6 100644
--- a/apm-agent-plugins/apm-jms-plugin/apm-jms-plugin-base/src/main/java/co/elastic/apm/agent/jms/JmsMessagePropertyAccessor.java
+++ b/apm-agent-plugins/apm-jms-plugin/apm-jms-plugin-base/src/main/java/co/elastic/apm/agent/jms/JmsMessagePropertyAccessor.java
@@ -18,10 +18,10 @@
*/
package co.elastic.apm.agent.jms;
-import co.elastic.apm.agent.impl.transaction.AbstractHeaderGetter;
-import co.elastic.apm.agent.impl.transaction.TextHeaderGetter;
-import co.elastic.apm.agent.impl.transaction.TextHeaderSetter;
-import co.elastic.apm.agent.impl.transaction.TraceContext;
+import co.elastic.apm.plugin.spi.AbstractHeaderGetter;
+import co.elastic.apm.plugin.spi.TextHeaderGetter;
+import co.elastic.apm.plugin.spi.TextHeaderSetter;
+import co.elastic.apm.plugin.spi.TraceContext;
import co.elastic.apm.agent.sdk.logging.Logger;
import co.elastic.apm.agent.sdk.logging.LoggerFactory;
diff --git a/apm-agent-plugins/apm-jsf-plugin/src/main/java/co/elastic/apm/agent/jsf/AbstractJsfLifecycleExecuteInstrumentation.java b/apm-agent-plugins/apm-jsf-plugin/src/main/java/co/elastic/apm/agent/jsf/AbstractJsfLifecycleExecuteInstrumentation.java
index 43e2d2248f4..bf1a243584c 100644
--- a/apm-agent-plugins/apm-jsf-plugin/src/main/java/co/elastic/apm/agent/jsf/AbstractJsfLifecycleExecuteInstrumentation.java
+++ b/apm-agent-plugins/apm-jsf-plugin/src/main/java/co/elastic/apm/agent/jsf/AbstractJsfLifecycleExecuteInstrumentation.java
@@ -18,15 +18,15 @@
*/
package co.elastic.apm.agent.jsf;
-import co.elastic.apm.agent.impl.transaction.AbstractSpan;
-import co.elastic.apm.agent.impl.transaction.Span;
-import co.elastic.apm.agent.impl.transaction.Transaction;
+import co.elastic.apm.plugin.spi.AbstractSpan;
+import co.elastic.apm.plugin.spi.Span;
+import co.elastic.apm.plugin.spi.Transaction;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.matcher.ElementMatcher;
import javax.annotation.Nullable;
-import static co.elastic.apm.agent.impl.transaction.AbstractSpan.PRIO_HIGH_LEVEL_FRAMEWORK;
+import static co.elastic.apm.plugin.spi.AbstractSpan.PRIO_HIGH_LEVEL_FRAMEWORK;
import static net.bytebuddy.matcher.ElementMatchers.named;
import static net.bytebuddy.matcher.ElementMatchers.takesArgument;
import static net.bytebuddy.matcher.ElementMatchers.takesArguments;
@@ -50,13 +50,13 @@ protected static Object createAndActivateSpan(boolean withExternalContext, @Null
if (parent == null) {
return null;
}
- if (parent instanceof Span) {
- Span parentSpan = (Span) parent;
+ if (parent instanceof Span>) {
+ Span> parentSpan = (Span>) parent;
if (SPAN_SUBTYPE.equals(parentSpan.getSubtype()) && SPAN_ACTION.equals(parentSpan.getAction())) {
return null;
}
}
- Transaction transaction = tracer.currentTransaction();
+ Transaction> transaction = tracer.currentTransaction();
if (transaction != null) {
try {
if (withExternalContext) {
@@ -70,7 +70,7 @@ protected static Object createAndActivateSpan(boolean withExternalContext, @Null
// do nothing- rely on the default servlet name logic
}
}
- Span span = parent.createSpan()
+ Span> span = parent.createSpan()
.withType(SPAN_TYPE)
.withSubtype(SPAN_SUBTYPE)
.withAction(SPAN_ACTION)
@@ -80,8 +80,8 @@ protected static Object createAndActivateSpan(boolean withExternalContext, @Null
}
protected static void endAndDeactivateSpan(@Nullable Object span, @Nullable Throwable t) {
- if (span instanceof Span) {
- ((Span) span).captureException(t).deactivate().end();
+ if (span instanceof Span>) {
+ ((Span>) span).captureException(t).deactivate().end();
}
}
}
diff --git a/apm-agent-plugins/apm-jsf-plugin/src/main/java/co/elastic/apm/agent/jsf/AbstractJsfLifecycleRenderInstrumentation.java b/apm-agent-plugins/apm-jsf-plugin/src/main/java/co/elastic/apm/agent/jsf/AbstractJsfLifecycleRenderInstrumentation.java
index 5522e51e5f8..5dffa5c01e7 100644
--- a/apm-agent-plugins/apm-jsf-plugin/src/main/java/co/elastic/apm/agent/jsf/AbstractJsfLifecycleRenderInstrumentation.java
+++ b/apm-agent-plugins/apm-jsf-plugin/src/main/java/co/elastic/apm/agent/jsf/AbstractJsfLifecycleRenderInstrumentation.java
@@ -18,8 +18,8 @@
*/
package co.elastic.apm.agent.jsf;
-import co.elastic.apm.agent.impl.transaction.AbstractSpan;
-import co.elastic.apm.agent.impl.transaction.Span;
+import co.elastic.apm.plugin.spi.AbstractSpan;
+import co.elastic.apm.plugin.spi.Span;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.matcher.ElementMatcher;
@@ -66,13 +66,13 @@ public static Object createRenderSpan() {
if (parent == null) {
return null;
}
- if (parent instanceof Span) {
- Span parentSpan = (Span) parent;
+ if (parent instanceof Span>) {
+ Span> parentSpan = (Span>) parent;
if (SPAN_SUBTYPE.equals(parentSpan.getSubtype()) && SPAN_ACTION.equals(parentSpan.getAction())) {
return null;
}
}
- Span span = parent.createSpan()
+ Span> span = parent.createSpan()
.withType(SPAN_TYPE)
.withSubtype(SPAN_SUBTYPE)
.withAction(SPAN_ACTION)
@@ -85,8 +85,8 @@ public static Object createRenderSpan() {
public static void endRenderSpan(@Advice.Enter @Nullable Object span,
@Advice.Thrown @Nullable Throwable t) {
- if (span instanceof Span) {
- ((Span) span).captureException(t).deactivate().end();
+ if (span instanceof Span>) {
+ ((Span>) span).captureException(t).deactivate().end();
}
}
}
diff --git a/apm-agent-plugins/apm-kafka-plugin/apm-kafka-base-plugin/src/main/java/co/elastic/apm/agent/kafka/KafkaConsumerInstrumentation.java b/apm-agent-plugins/apm-kafka-plugin/apm-kafka-base-plugin/src/main/java/co/elastic/apm/agent/kafka/KafkaConsumerInstrumentation.java
index 9c20b36f071..5461451e6c8 100644
--- a/apm-agent-plugins/apm-kafka-plugin/apm-kafka-base-plugin/src/main/java/co/elastic/apm/agent/kafka/KafkaConsumerInstrumentation.java
+++ b/apm-agent-plugins/apm-kafka-plugin/apm-kafka-base-plugin/src/main/java/co/elastic/apm/agent/kafka/KafkaConsumerInstrumentation.java
@@ -19,10 +19,10 @@
package co.elastic.apm.agent.kafka;
import co.elastic.apm.agent.configuration.MessagingConfiguration;
-import co.elastic.apm.agent.impl.GlobalTracer;
-import co.elastic.apm.agent.impl.transaction.AbstractSpan;
-import co.elastic.apm.agent.impl.transaction.Span;
-import co.elastic.apm.agent.impl.transaction.Transaction;
+import co.elastic.apm.plugin.spi.GlobalTracer;
+import co.elastic.apm.plugin.spi.AbstractSpan;
+import co.elastic.apm.plugin.spi.Span;
+import co.elastic.apm.plugin.spi.Transaction;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription;
@@ -68,15 +68,15 @@ public static void pollStart() {
return;
}
- if (messagingConfiguration.shouldEndMessagingTransactionOnPoll() && activeSpan instanceof Transaction) {
- Transaction transaction = (Transaction) activeSpan;
+ if (messagingConfiguration.shouldEndMessagingTransactionOnPoll() && activeSpan instanceof Transaction>) {
+ Transaction> transaction = (Transaction>) activeSpan;
if ("messaging".equals(transaction.getType())) {
transaction.deactivate().end();
return;
}
}
- Span span = activeSpan.createExitSpan();
+ Span> span = activeSpan.createExitSpan();
if (span == null) {
return;
}
@@ -111,7 +111,7 @@ public static class KafkaPollExitAdvice {
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class, inline = false)
public static void pollEnd(@Advice.Thrown final Throwable throwable) {
- Span span = tracer.getActiveSpan();
+ Span> span = tracer.getActiveSpan();
if (span != null &&
"kafka".equals(span.getSubtype()) &&
"poll".equals(span.getAction())
diff --git a/apm-agent-plugins/apm-kafka-plugin/apm-kafka-base-plugin/src/main/java/co/elastic/apm/agent/kafka/KafkaProducerInstrumentation.java b/apm-agent-plugins/apm-kafka-plugin/apm-kafka-base-plugin/src/main/java/co/elastic/apm/agent/kafka/KafkaProducerInstrumentation.java
index 68843736119..e6e6dbadc84 100644
--- a/apm-agent-plugins/apm-kafka-plugin/apm-kafka-base-plugin/src/main/java/co/elastic/apm/agent/kafka/KafkaProducerInstrumentation.java
+++ b/apm-agent-plugins/apm-kafka-plugin/apm-kafka-base-plugin/src/main/java/co/elastic/apm/agent/kafka/KafkaProducerInstrumentation.java
@@ -18,7 +18,7 @@
*/
package co.elastic.apm.agent.kafka;
-import co.elastic.apm.agent.impl.transaction.Span;
+import co.elastic.apm.plugin.spi.Span;
import co.elastic.apm.agent.kafka.helper.KafkaInstrumentationHelper;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.asm.Advice.AssignReturned.ToArguments.ToArgument;
@@ -70,7 +70,7 @@ public static class KafkaProducerAdvice {
@Advice.OnMethodEnter(suppress = Throwable.class, inline = false)
public static Callback beforeSend(@Advice.Argument(0) final ProducerRecord, ?> record,
@Advice.Argument(1) @Nullable Callback callback) {
- Span span = helper.onSendStart(record);
+ Span> span = helper.onSendStart(record);
if (span == null) {
return callback;
}
@@ -82,7 +82,7 @@ public static Callback beforeSend(@Advice.Argument(0) final ProducerRecord, ?>
public static void afterSend(@Advice.Argument(0) final ProducerRecord, ?> record,
@Advice.This final KafkaProducer, ?> thiz,
@Advice.Thrown final Throwable throwable) {
- final Span span = tracer.getActiveExitSpan();
+ final Span> span = tracer.getActiveExitSpan();
if (span != null) {
helper.onSendEnd(span, record, thiz, throwable);
}
diff --git a/apm-agent-plugins/apm-kafka-plugin/apm-kafka-base-plugin/src/main/java/co/elastic/apm/agent/kafka/helper/CallbackWrapper.java b/apm-agent-plugins/apm-kafka-plugin/apm-kafka-base-plugin/src/main/java/co/elastic/apm/agent/kafka/helper/CallbackWrapper.java
index 9e4ddaff9cf..0d97eb10ca3 100644
--- a/apm-agent-plugins/apm-kafka-plugin/apm-kafka-base-plugin/src/main/java/co/elastic/apm/agent/kafka/helper/CallbackWrapper.java
+++ b/apm-agent-plugins/apm-kafka-plugin/apm-kafka-base-plugin/src/main/java/co/elastic/apm/agent/kafka/helper/CallbackWrapper.java
@@ -18,7 +18,7 @@
*/
package co.elastic.apm.agent.kafka.helper;
-import co.elastic.apm.agent.impl.transaction.Span;
+import co.elastic.apm.plugin.spi.Span;
import co.elastic.apm.agent.objectpool.Recyclable;
import org.apache.kafka.clients.producer.Callback;
import org.apache.kafka.clients.producer.RecordMetadata;
@@ -32,13 +32,13 @@ class CallbackWrapper implements Callback, Recyclable {
@Nullable
private Callback delegate;
@SuppressWarnings("NotNullFieldNotInitialized")
- private volatile Span span;
+ private volatile Span> span;
CallbackWrapper(KafkaInstrumentationHelper helper) {
this.helper = helper;
}
- Callback wrap(@Nullable Callback delegate, Span span) {
+ Callback wrap(@Nullable Callback delegate, Span> span) {
this.delegate = delegate;
this.span = span;
return this;
diff --git a/apm-agent-plugins/apm-kafka-plugin/apm-kafka-base-plugin/src/main/java/co/elastic/apm/agent/kafka/helper/KafkaInstrumentationHelper.java b/apm-agent-plugins/apm-kafka-plugin/apm-kafka-base-plugin/src/main/java/co/elastic/apm/agent/kafka/helper/KafkaInstrumentationHelper.java
index 6fa00387620..54cbd466ba2 100644
--- a/apm-agent-plugins/apm-kafka-plugin/apm-kafka-base-plugin/src/main/java/co/elastic/apm/agent/kafka/helper/KafkaInstrumentationHelper.java
+++ b/apm-agent-plugins/apm-kafka-plugin/apm-kafka-base-plugin/src/main/java/co/elastic/apm/agent/kafka/helper/KafkaInstrumentationHelper.java
@@ -19,12 +19,8 @@
package co.elastic.apm.agent.kafka.helper;
import co.elastic.apm.agent.configuration.MessagingConfiguration;
-import co.elastic.apm.agent.impl.GlobalTracer;
-import co.elastic.apm.agent.impl.Tracer;
-import co.elastic.apm.agent.impl.transaction.Span;
+import co.elastic.apm.plugin.spi.*;
import co.elastic.apm.agent.common.util.WildcardMatcher;
-import co.elastic.apm.agent.objectpool.Allocator;
-import co.elastic.apm.agent.objectpool.ObjectPool;
import co.elastic.apm.agent.sdk.logging.Logger;
import co.elastic.apm.agent.sdk.logging.LoggerFactory;
import org.apache.kafka.clients.producer.Callback;
@@ -69,14 +65,14 @@ private boolean ignoreTopic(String topicName) {
}
@Nullable
- public Span onSendStart(ProducerRecord, ?> record) {
+ public Span> onSendStart(ProducerRecord, ?> record) {
String topic = record.topic();
if (ignoreTopic(topic)) {
return null;
}
- final Span span = tracer.createExitChildSpan();
+ final Span> span = tracer.createExitChildSpan();
if (span == null) {
return null;
}
@@ -98,7 +94,7 @@ public Span onSendStart(ProducerRecord, ?> record) {
}
@Nullable
- public Callback wrapCallback(@Nullable Callback callback, Span span) {
+ public Callback wrapCallback(@Nullable Callback callback, Span> span) {
if (callback instanceof CallbackWrapper) {
// don't wrap twice
return callback;
@@ -115,7 +111,7 @@ void recycle(CallbackWrapper callbackWrapper) {
callbackWrapperObjectPool.recycle(callbackWrapper);
}
- public void onSendEnd(Span span, ProducerRecord, ?> producerRecord, KafkaProducer, ?> kafkaProducer, @Nullable Throwable throwable) {
+ public void onSendEnd(Span> span, ProducerRecord, ?> producerRecord, KafkaProducer, ?> kafkaProducer, @Nullable Throwable throwable) {
// Topic address collection is normally very fast, as it uses cached cluster state information. However,
// when the cluster metadata is required to be updated, its query may block for a short period. In
diff --git a/apm-agent-plugins/apm-kafka-plugin/apm-kafka-headers-plugin/src/main/java/co/elastic/apm/agent/kafka/KafkaProducerHeadersInstrumentation.java b/apm-agent-plugins/apm-kafka-plugin/apm-kafka-headers-plugin/src/main/java/co/elastic/apm/agent/kafka/KafkaProducerHeadersInstrumentation.java
index bec7ec0916a..3c21e2ed42d 100644
--- a/apm-agent-plugins/apm-kafka-plugin/apm-kafka-headers-plugin/src/main/java/co/elastic/apm/agent/kafka/KafkaProducerHeadersInstrumentation.java
+++ b/apm-agent-plugins/apm-kafka-plugin/apm-kafka-headers-plugin/src/main/java/co/elastic/apm/agent/kafka/KafkaProducerHeadersInstrumentation.java
@@ -18,7 +18,7 @@
*/
package co.elastic.apm.agent.kafka;
-import co.elastic.apm.agent.impl.transaction.Span;
+import co.elastic.apm.plugin.spi.Span;
import co.elastic.apm.agent.kafka.helper.KafkaInstrumentationHeadersHelper;
import co.elastic.apm.agent.kafka.helper.KafkaInstrumentationHelper;
import net.bytebuddy.asm.Advice;
@@ -70,7 +70,7 @@ public static class KafkaProducerHeadersAdvice {
public static Object[] beforeSend(@Advice.FieldValue("apiVersions") final ApiVersions apiVersions,
@Advice.Argument(0) final ProducerRecord, ?> record,
@Nullable @Advice.Argument(value = 1) Callback callback) {
- Span span = helper.onSendStart(record);
+ Span> span = helper.onSendStart(record);
if (span == null) {
return null;
}
@@ -107,7 +107,7 @@ public static Object[] afterSend(@Advice.Enter @Nullable Object[] enter,
@Advice.This final KafkaProducer, ?> thiz,
@Advice.Thrown @Nullable final Throwable throwable) {
- Span span = enter != null ? (Span) enter[0] : null;
+ Span> span = enter != null ? (Span>) enter[0] : null;
if (span == null) {
return null;
}
diff --git a/apm-agent-plugins/apm-kafka-plugin/apm-kafka-headers-plugin/src/main/java/co/elastic/apm/agent/kafka/NewKafkaPollExitInstrumentation.java b/apm-agent-plugins/apm-kafka-plugin/apm-kafka-headers-plugin/src/main/java/co/elastic/apm/agent/kafka/NewKafkaPollExitInstrumentation.java
index bf18f65efbf..ad2318b5380 100644
--- a/apm-agent-plugins/apm-kafka-plugin/apm-kafka-headers-plugin/src/main/java/co/elastic/apm/agent/kafka/NewKafkaPollExitInstrumentation.java
+++ b/apm-agent-plugins/apm-kafka-plugin/apm-kafka-headers-plugin/src/main/java/co/elastic/apm/agent/kafka/NewKafkaPollExitInstrumentation.java
@@ -18,7 +18,7 @@
*/
package co.elastic.apm.agent.kafka;
-import co.elastic.apm.agent.impl.transaction.Span;
+import co.elastic.apm.plugin.spi.Span;
import co.elastic.apm.agent.kafka.helper.KafkaInstrumentationHeadersHelper;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.matcher.ElementMatcher;
@@ -51,7 +51,7 @@ public static class KafkaPollExitAdvice {
public static void pollEnd(@Advice.Thrown final Throwable throwable,
@Advice.Return @Nullable ConsumerRecords, ?> records) {
- Span span = tracer.getActiveSpan();
+ Span> span = tracer.getActiveSpan();
if (span != null &&
span.getSubtype() != null && span.getSubtype().equals("kafka") &&
span.getAction() != null && span.getAction().equals("poll")
diff --git a/apm-agent-plugins/apm-kafka-plugin/apm-kafka-headers-plugin/src/main/java/co/elastic/apm/agent/kafka/helper/ConsumerRecordsIterableWrapper.java b/apm-agent-plugins/apm-kafka-plugin/apm-kafka-headers-plugin/src/main/java/co/elastic/apm/agent/kafka/helper/ConsumerRecordsIterableWrapper.java
index 2e2b359e5ed..a8b4a3bca26 100644
--- a/apm-agent-plugins/apm-kafka-plugin/apm-kafka-headers-plugin/src/main/java/co/elastic/apm/agent/kafka/helper/ConsumerRecordsIterableWrapper.java
+++ b/apm-agent-plugins/apm-kafka-plugin/apm-kafka-headers-plugin/src/main/java/co/elastic/apm/agent/kafka/helper/ConsumerRecordsIterableWrapper.java
@@ -18,7 +18,7 @@
*/
package co.elastic.apm.agent.kafka.helper;
-import co.elastic.apm.agent.impl.Tracer;
+import co.elastic.apm.plugin.spi.Tracer;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import java.util.Iterator;
diff --git a/apm-agent-plugins/apm-kafka-plugin/apm-kafka-headers-plugin/src/main/java/co/elastic/apm/agent/kafka/helper/ConsumerRecordsIteratorWrapper.java b/apm-agent-plugins/apm-kafka-plugin/apm-kafka-headers-plugin/src/main/java/co/elastic/apm/agent/kafka/helper/ConsumerRecordsIteratorWrapper.java
index b59099ca96e..9de2953c41d 100644
--- a/apm-agent-plugins/apm-kafka-plugin/apm-kafka-headers-plugin/src/main/java/co/elastic/apm/agent/kafka/helper/ConsumerRecordsIteratorWrapper.java
+++ b/apm-agent-plugins/apm-kafka-plugin/apm-kafka-headers-plugin/src/main/java/co/elastic/apm/agent/kafka/helper/ConsumerRecordsIteratorWrapper.java
@@ -20,10 +20,10 @@
import co.elastic.apm.agent.configuration.CoreConfiguration;
import co.elastic.apm.agent.configuration.MessagingConfiguration;
-import co.elastic.apm.agent.impl.Tracer;
-import co.elastic.apm.agent.impl.context.Message;
-import co.elastic.apm.agent.impl.transaction.TraceContext;
-import co.elastic.apm.agent.impl.transaction.Transaction;
+import co.elastic.apm.plugin.spi.Tracer;
+import co.elastic.apm.plugin.spi.Message;
+import co.elastic.apm.plugin.spi.TraceContext;
+import co.elastic.apm.plugin.spi.Transaction;
import co.elastic.apm.agent.common.util.WildcardMatcher;
import co.elastic.apm.agent.util.PrivilegedActionUtils;
import org.apache.kafka.clients.consumer.ConsumerRecord;
@@ -59,7 +59,7 @@ public boolean hasNext() {
public void endCurrentTransaction() {
try {
- Transaction transaction = tracer.currentTransaction();
+ Transaction> transaction = tracer.currentTransaction();
if (transaction != null && "messaging".equals(transaction.getType())) {
transaction.deactivate().end();
}
@@ -75,7 +75,7 @@ public void endCurrentTransaction() {
try {
String topic = record.topic();
if (!WildcardMatcher.isAnyMatch(messagingConfiguration.getIgnoreMessageQueues(), topic)) {
- Transaction transaction = tracer.startChildTransaction(record, KafkaRecordHeaderAccessor.instance(), PrivilegedActionUtils.getClassLoader(ConsumerRecordsIteratorWrapper.class));
+ Transaction> transaction = tracer.startChildTransaction(record, KafkaRecordHeaderAccessor.instance(), PrivilegedActionUtils.getClassLoader(ConsumerRecordsIteratorWrapper.class));
if (transaction != null) {
transaction.withType("messaging").withName("Kafka record from " + topic).activate();
transaction.setFrameworkName(FRAMEWORK_NAME);
diff --git a/apm-agent-plugins/apm-kafka-plugin/apm-kafka-headers-plugin/src/main/java/co/elastic/apm/agent/kafka/helper/ConsumerRecordsListWrapper.java b/apm-agent-plugins/apm-kafka-plugin/apm-kafka-headers-plugin/src/main/java/co/elastic/apm/agent/kafka/helper/ConsumerRecordsListWrapper.java
index 5289049a432..1bc8dc1ce4e 100644
--- a/apm-agent-plugins/apm-kafka-plugin/apm-kafka-headers-plugin/src/main/java/co/elastic/apm/agent/kafka/helper/ConsumerRecordsListWrapper.java
+++ b/apm-agent-plugins/apm-kafka-plugin/apm-kafka-headers-plugin/src/main/java/co/elastic/apm/agent/kafka/helper/ConsumerRecordsListWrapper.java
@@ -18,7 +18,7 @@
*/
package co.elastic.apm.agent.kafka.helper;
-import co.elastic.apm.agent.impl.Tracer;
+import co.elastic.apm.plugin.spi.Tracer;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import java.util.Collection;
diff --git a/apm-agent-plugins/apm-kafka-plugin/apm-kafka-headers-plugin/src/main/java/co/elastic/apm/agent/kafka/helper/KafkaInstrumentationHeadersHelper.java b/apm-agent-plugins/apm-kafka-plugin/apm-kafka-headers-plugin/src/main/java/co/elastic/apm/agent/kafka/helper/KafkaInstrumentationHeadersHelper.java
index adb50d02a4c..c607774ccfc 100644
--- a/apm-agent-plugins/apm-kafka-plugin/apm-kafka-headers-plugin/src/main/java/co/elastic/apm/agent/kafka/helper/KafkaInstrumentationHeadersHelper.java
+++ b/apm-agent-plugins/apm-kafka-plugin/apm-kafka-headers-plugin/src/main/java/co/elastic/apm/agent/kafka/helper/KafkaInstrumentationHeadersHelper.java
@@ -18,11 +18,7 @@
*/
package co.elastic.apm.agent.kafka.helper;
-import co.elastic.apm.agent.impl.GlobalTracer;
-import co.elastic.apm.agent.impl.Tracer;
-import co.elastic.apm.agent.impl.transaction.AbstractSpan;
-import co.elastic.apm.agent.impl.transaction.Span;
-import co.elastic.apm.agent.impl.transaction.TraceContext;
+import co.elastic.apm.plugin.spi.*;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.apache.kafka.clients.consumer.ConsumerRecords;
import org.apache.kafka.clients.producer.ProducerRecord;
@@ -109,7 +105,7 @@ public void addSpanLinks(@Nullable ConsumerRecords, ?> records, AbstractSpan
try {
for (ConsumerRecord, ?> record : records) {
span.addSpanLink(
- TraceContext.getFromTraceContextBinaryHeaders(),
+ TraceContextUtil.getFromTraceContextBinaryHeaders(),
KafkaRecordHeaderAccessor.instance(),
record
);
@@ -120,11 +116,11 @@ public void addSpanLinks(@Nullable ConsumerRecords, ?> records, AbstractSpan
}
}
- public void setOutgoingTraceContextHeaders(Span span, ProducerRecord, ?> producerRecord) {
+ public void setOutgoingTraceContextHeaders(Span> span, ProducerRecord, ?> producerRecord) {
span.propagateTraceContext(producerRecord, KafkaRecordHeaderAccessor.instance());
}
public void removeTraceContextHeader(ProducerRecord, ?> producerRecord) {
- TraceContext.removeTraceContextHeaders(producerRecord, KafkaRecordHeaderAccessor.instance());
+ TraceContextUtil.removeTraceContextHeaders(producerRecord, KafkaRecordHeaderAccessor.instance());
}
}
diff --git a/apm-agent-plugins/apm-kafka-plugin/apm-kafka-headers-plugin/src/main/java/co/elastic/apm/agent/kafka/helper/KafkaRecordHeaderAccessor.java b/apm-agent-plugins/apm-kafka-plugin/apm-kafka-headers-plugin/src/main/java/co/elastic/apm/agent/kafka/helper/KafkaRecordHeaderAccessor.java
index 67f9d3d1733..780aa4ba1ff 100644
--- a/apm-agent-plugins/apm-kafka-plugin/apm-kafka-headers-plugin/src/main/java/co/elastic/apm/agent/kafka/helper/KafkaRecordHeaderAccessor.java
+++ b/apm-agent-plugins/apm-kafka-plugin/apm-kafka-headers-plugin/src/main/java/co/elastic/apm/agent/kafka/helper/KafkaRecordHeaderAccessor.java
@@ -18,9 +18,9 @@
*/
package co.elastic.apm.agent.kafka.helper;
-import co.elastic.apm.agent.impl.transaction.BinaryHeaderGetter;
-import co.elastic.apm.agent.impl.transaction.BinaryHeaderSetter;
-import co.elastic.apm.agent.impl.transaction.HeaderRemover;
+import co.elastic.apm.plugin.spi.BinaryHeaderGetter;
+import co.elastic.apm.plugin.spi.BinaryHeaderSetter;
+import co.elastic.apm.plugin.spi.HeaderRemover;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.apache.kafka.clients.producer.ProducerRecord;
import org.apache.kafka.common.header.Header;
diff --git a/apm-agent-plugins/apm-kafka-plugin/apm-kafka-spring-plugin/src/main/java/co/elastic/apm/agent/kafka/SpringKafkaBatchListenerInstrumentation.java b/apm-agent-plugins/apm-kafka-plugin/apm-kafka-spring-plugin/src/main/java/co/elastic/apm/agent/kafka/SpringKafkaBatchListenerInstrumentation.java
index d3d6dced5ae..ea91a198946 100644
--- a/apm-agent-plugins/apm-kafka-plugin/apm-kafka-spring-plugin/src/main/java/co/elastic/apm/agent/kafka/SpringKafkaBatchListenerInstrumentation.java
+++ b/apm-agent-plugins/apm-kafka-plugin/apm-kafka-spring-plugin/src/main/java/co/elastic/apm/agent/kafka/SpringKafkaBatchListenerInstrumentation.java
@@ -18,7 +18,7 @@
*/
package co.elastic.apm.agent.kafka;
-import co.elastic.apm.agent.impl.transaction.Transaction;
+import co.elastic.apm.plugin.spi.Transaction;
import co.elastic.apm.agent.sdk.logging.Logger;
import co.elastic.apm.agent.sdk.logging.LoggerFactory;
import co.elastic.apm.agent.util.LoggerUtils;
@@ -75,7 +75,7 @@ public static class SpringKafkaBatchListenerAdvice {
@Nullable
@Advice.OnMethodEnter(suppress = Throwable.class, inline = false)
public static Object onEnter(@Advice.This Object thiz) {
- Transaction transaction = tracer.startRootTransaction(PrivilegedActionUtils.getClassLoader(thiz.getClass()));
+ Transaction> transaction = tracer.startRootTransaction(PrivilegedActionUtils.getClassLoader(thiz.getClass()));
if (transaction != null) {
transaction
.withType("messaging")
@@ -91,7 +91,7 @@ public static Object onEnter(@Advice.This Object thiz) {
@Advice.OnMethodExit(suppress = Throwable.class, onThrowable = Throwable.class, inline = false)
public static void onExit(@Nullable @Advice.Enter Object transactionObj) {
- Transaction transaction = (Transaction) transactionObj;
+ Transaction> transaction = (Transaction>) transactionObj;
if (transaction != null) {
transaction.deactivate().end();
}
diff --git a/apm-agent-plugins/apm-logging-plugin/apm-log4j2-plugin/src/main/java/co/elastic/apm/agent/log4j2/correlation/Log4j2_7PlusLogCorrelationHelper.java b/apm-agent-plugins/apm-logging-plugin/apm-log4j2-plugin/src/main/java/co/elastic/apm/agent/log4j2/correlation/Log4j2_7PlusLogCorrelationHelper.java
index 21adbf2723d..3e7fb331fb5 100644
--- a/apm-agent-plugins/apm-logging-plugin/apm-log4j2-plugin/src/main/java/co/elastic/apm/agent/log4j2/correlation/Log4j2_7PlusLogCorrelationHelper.java
+++ b/apm-agent-plugins/apm-logging-plugin/apm-log4j2-plugin/src/main/java/co/elastic/apm/agent/log4j2/correlation/Log4j2_7PlusLogCorrelationHelper.java
@@ -18,9 +18,9 @@
*/
package co.elastic.apm.agent.log4j2.correlation;
-import co.elastic.apm.agent.impl.GlobalTracer;
-import co.elastic.apm.agent.impl.Tracer;
import co.elastic.apm.agent.impl.error.ErrorCapture;
+import co.elastic.apm.plugin.spi.GlobalTracer;
+import co.elastic.apm.plugin.spi.Tracer;
import co.elastic.apm.agent.loginstr.correlation.AbstractLogCorrelationHelper;
import co.elastic.apm.agent.loginstr.correlation.CorrelationIdMapAdapter;
import org.apache.logging.log4j.ThreadContext;
@@ -32,7 +32,7 @@
*/
public class Log4j2_7PlusLogCorrelationHelper extends AbstractLogCorrelationHelper {
- private final Tracer tracer = GlobalTracer.get();
+ private static final Tracer tracer = GlobalTracer.get();
@Override
protected boolean addToMdc() {
diff --git a/apm-agent-plugins/apm-mongodb/apm-mongodb-common/src/main/java/co/elastic/apm/agent/mongodb/MongoHelper.java b/apm-agent-plugins/apm-mongodb/apm-mongodb-common/src/main/java/co/elastic/apm/agent/mongodb/MongoHelper.java
index 17cd6818cee..5288df61d83 100644
--- a/apm-agent-plugins/apm-mongodb/apm-mongodb-common/src/main/java/co/elastic/apm/agent/mongodb/MongoHelper.java
+++ b/apm-agent-plugins/apm-mongodb/apm-mongodb-common/src/main/java/co/elastic/apm/agent/mongodb/MongoHelper.java
@@ -18,10 +18,10 @@
*/
package co.elastic.apm.agent.mongodb;
-import co.elastic.apm.agent.impl.GlobalTracer;
-import co.elastic.apm.agent.impl.Tracer;
-import co.elastic.apm.agent.impl.transaction.AbstractSpan;
-import co.elastic.apm.agent.impl.transaction.Span;
+import co.elastic.apm.plugin.spi.GlobalTracer;
+import co.elastic.apm.plugin.spi.Tracer;
+import co.elastic.apm.plugin.spi.AbstractSpan;
+import co.elastic.apm.plugin.spi.Span;
import co.elastic.apm.agent.common.util.WildcardMatcher;
import co.elastic.apm.agent.sdk.logging.Logger;
import co.elastic.apm.agent.sdk.logging.LoggerFactory;
@@ -34,16 +34,15 @@ public class MongoHelper {
private static final Logger logger = LoggerFactory.getLogger(MongoHelper.class);
- private final Tracer tracer;
+ private static final Tracer tracer = GlobalTracer.get();
private final MongoConfiguration config;
public MongoHelper() {
- this.tracer = GlobalTracer.get();
this.config = tracer.getConfig(MongoConfiguration.class);
}
- public Span startSpan(@Nullable String database, @Nullable String collection, @Nullable String command, String host, int port, @Nullable BsonDocument commandDocument) {
- Span span = null;
+ public Span> startSpan(@Nullable String database, @Nullable String collection, @Nullable String command, String host, int port, @Nullable BsonDocument commandDocument) {
+ Span> span = null;
final AbstractSpan> activeSpan = tracer.getActive();
if (activeSpan != null) {
span = activeSpan.createExitSpan();
diff --git a/apm-agent-plugins/apm-mongodb/apm-mongodb3-plugin/src/main/java/co/elastic/apm/agent/mongodb/v3/ConnectionCommandInstrumentation.java b/apm-agent-plugins/apm-mongodb/apm-mongodb3-plugin/src/main/java/co/elastic/apm/agent/mongodb/v3/ConnectionCommandInstrumentation.java
index f0d8aa462d1..0fe9a9fec3d 100644
--- a/apm-agent-plugins/apm-mongodb/apm-mongodb3-plugin/src/main/java/co/elastic/apm/agent/mongodb/v3/ConnectionCommandInstrumentation.java
+++ b/apm-agent-plugins/apm-mongodb/apm-mongodb3-plugin/src/main/java/co/elastic/apm/agent/mongodb/v3/ConnectionCommandInstrumentation.java
@@ -18,8 +18,7 @@
*/
package co.elastic.apm.agent.mongodb.v3;
-import co.elastic.apm.agent.impl.GlobalTracer;
-import co.elastic.apm.agent.impl.transaction.Span;
+import co.elastic.apm.plugin.spi.Span;
import co.elastic.apm.agent.mongodb.MongoHelper;
import com.mongodb.MongoNamespace;
import com.mongodb.ServerAddress;
@@ -80,8 +79,8 @@ public static Object onEnter(@Advice.This Connection thiz,
@Advice.OnMethodExit(suppress = Throwable.class, onThrowable = Throwable.class, inline = false)
public static void onExit(@Nullable @Advice.Enter Object spanObj, @Advice.Thrown Throwable thrown) {
- if (spanObj instanceof Span) {
- Span span = (Span) spanObj;
+ if (spanObj instanceof Span>) {
+ Span> span = (Span>) spanObj;
span.deactivate()
.captureException(thrown)
.end();
diff --git a/apm-agent-plugins/apm-mongodb/apm-mongodb3-plugin/src/main/java/co/elastic/apm/agent/mongodb/v3/ConnectionInstrumentation.java b/apm-agent-plugins/apm-mongodb/apm-mongodb3-plugin/src/main/java/co/elastic/apm/agent/mongodb/v3/ConnectionInstrumentation.java
index f34bcdfa0c7..3c83ecab07f 100644
--- a/apm-agent-plugins/apm-mongodb/apm-mongodb3-plugin/src/main/java/co/elastic/apm/agent/mongodb/v3/ConnectionInstrumentation.java
+++ b/apm-agent-plugins/apm-mongodb/apm-mongodb3-plugin/src/main/java/co/elastic/apm/agent/mongodb/v3/ConnectionInstrumentation.java
@@ -18,8 +18,7 @@
*/
package co.elastic.apm.agent.mongodb.v3;
-import co.elastic.apm.agent.impl.GlobalTracer;
-import co.elastic.apm.agent.impl.transaction.Span;
+import co.elastic.apm.plugin.spi.Span;
import co.elastic.apm.agent.mongodb.MongoHelper;
import com.mongodb.MongoNamespace;
import com.mongodb.ServerAddress;
@@ -93,8 +92,8 @@ public static Object onEnter(@Advice.This Connection thiz,
@Advice.OnMethodExit(suppress = Throwable.class, onThrowable = Throwable.class, inline = false)
public static void onExit(@Nullable @Advice.Enter Object spanObj, @Advice.Thrown Throwable thrown) {
- if (spanObj instanceof Span) {
- Span span = (Span) spanObj;
+ if (spanObj instanceof Span>) {
+ Span> span = (Span>) spanObj;
span.deactivate().captureException(thrown);
span.end();
}
diff --git a/apm-agent-plugins/apm-mongodb/apm-mongodb4-plugin/src/main/java/co/elastic/apm/agent/mongodb/v4/ConnectionCommandInstrumentation.java b/apm-agent-plugins/apm-mongodb/apm-mongodb4-plugin/src/main/java/co/elastic/apm/agent/mongodb/v4/ConnectionCommandInstrumentation.java
index 4e83bde60e6..73e53aeee16 100644
--- a/apm-agent-plugins/apm-mongodb/apm-mongodb4-plugin/src/main/java/co/elastic/apm/agent/mongodb/v4/ConnectionCommandInstrumentation.java
+++ b/apm-agent-plugins/apm-mongodb/apm-mongodb4-plugin/src/main/java/co/elastic/apm/agent/mongodb/v4/ConnectionCommandInstrumentation.java
@@ -18,8 +18,7 @@
*/
package co.elastic.apm.agent.mongodb.v4;
-import co.elastic.apm.agent.impl.GlobalTracer;
-import co.elastic.apm.agent.impl.transaction.Span;
+import co.elastic.apm.plugin.spi.Span;
import co.elastic.apm.agent.mongodb.MongoHelper;
import com.mongodb.ServerAddress;
import com.mongodb.internal.connection.Connection;
@@ -75,8 +74,8 @@ public static Object onEnter(@Advice.This Connection thiz,
@Advice.OnMethodExit(suppress = Throwable.class, onThrowable = Throwable.class, inline = false)
public static void onExit(@Nullable @Advice.Enter Object spanObj, @Advice.Thrown Throwable thrown) {
- if (spanObj instanceof Span) {
- Span span = (Span) spanObj;
+ if (spanObj instanceof Span>) {
+ Span> span = (Span>) spanObj;
span.deactivate()
.captureException(thrown)
.end();
diff --git a/apm-agent-plugins/apm-okhttp-plugin/src/main/java/co/elastic/apm/agent/okhttp/OkHttp3ClientAsyncInstrumentation.java b/apm-agent-plugins/apm-okhttp-plugin/src/main/java/co/elastic/apm/agent/okhttp/OkHttp3ClientAsyncInstrumentation.java
index 712787697d1..b5a3b80f9a2 100644
--- a/apm-agent-plugins/apm-okhttp-plugin/src/main/java/co/elastic/apm/agent/okhttp/OkHttp3ClientAsyncInstrumentation.java
+++ b/apm-agent-plugins/apm-okhttp-plugin/src/main/java/co/elastic/apm/agent/okhttp/OkHttp3ClientAsyncInstrumentation.java
@@ -19,10 +19,7 @@
package co.elastic.apm.agent.okhttp;
import co.elastic.apm.agent.httpclient.HttpClientHelper;
-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.impl.transaction.TraceContext;
+import co.elastic.apm.plugin.spi.*;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.asm.Advice.AssignReturned.ToArguments.ToArgument;
import net.bytebuddy.asm.Advice.AssignReturned.ToFields.ToField;
@@ -80,14 +77,14 @@ public static Object[] onBeforeEnqueue(final @Advice.Origin Class extends Call
Callback callback = originalCallback;
HttpUrl url = request.url();
- Span span = HttpClientHelper.startHttpClientSpan(parent, request.method(), url.toString(), url.scheme(),
+ Span> span = HttpClientHelper.startHttpClientSpan(parent, request.method(), url.toString(), url.scheme(),
OkHttpClientHelper.computeHostName(url.host()), url.port());
if (span != null) {
span.activate();
}
- if (!TraceContext.containsTraceContextTextHeaders(request, OkHttp3RequestHeaderGetter.INSTANCE)) {
+ if (!TraceContextUtil.containsTraceContextTextHeaders(request, OkHttp3RequestHeaderGetter.INSTANCE)) {
Request.Builder builder = originalRequest.newBuilder();
if (span != null) {
span.propagateTraceContext(builder, OkHttp3RequestHeaderSetter.INSTANCE);
@@ -103,7 +100,7 @@ public static Object[] onBeforeEnqueue(final @Advice.Origin Class extends Call
@Advice.OnMethodExit(suppress = Throwable.class, inline = false)
public static void onAfterEnqueue(@Advice.Enter @Nullable Object[] enter) {
- Span span = enter != null ? (Span) enter[2] : null;
+ Span> span = enter != null ? (Span>) enter[2] : null;
if (span != null) {
span.deactivate();
}
@@ -114,15 +111,15 @@ public static class CallbackWrapperCreator implements WrapperCreator {
public static final CallbackWrapperCreator INSTANCE = new CallbackWrapperCreator();
@Override
- public Callback wrap(final Callback delegate, Span span) {
+ public Callback wrap(final Callback delegate, Span> span) {
return new CallbackWrapper(span, delegate);
}
private static class CallbackWrapper implements Callback {
- private final Span span;
+ private final Span> span;
private final Callback delegate;
- CallbackWrapper(Span span, Callback delegate) {
+ CallbackWrapper(Span> span, Callback delegate) {
this.span = span;
this.delegate = delegate;
}
@@ -130,7 +127,7 @@ private static class CallbackWrapper implements Callback {
@Override
public void onFailure(Call call, IOException e) {
try {
- span.captureException(e).withOutcome(Outcome.FAILURE).end();
+ span.captureException(e).withOutcome(DefaultOutcome.FAILURE).end();
} catch (Throwable t) {
logger.error(t.getMessage(), t);
} finally {
diff --git a/apm-agent-plugins/apm-okhttp-plugin/src/main/java/co/elastic/apm/agent/okhttp/OkHttp3ClientInstrumentation.java b/apm-agent-plugins/apm-okhttp-plugin/src/main/java/co/elastic/apm/agent/okhttp/OkHttp3ClientInstrumentation.java
index 05bd8a643ff..e2528b4d103 100644
--- a/apm-agent-plugins/apm-okhttp-plugin/src/main/java/co/elastic/apm/agent/okhttp/OkHttp3ClientInstrumentation.java
+++ b/apm-agent-plugins/apm-okhttp-plugin/src/main/java/co/elastic/apm/agent/okhttp/OkHttp3ClientInstrumentation.java
@@ -19,10 +19,7 @@
package co.elastic.apm.agent.okhttp;
import co.elastic.apm.agent.httpclient.HttpClientHelper;
-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.impl.transaction.TraceContext;
+import co.elastic.apm.plugin.spi.*;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.asm.Advice.AssignReturned.ToFields.ToField;
import net.bytebuddy.description.method.MethodDescription;
@@ -63,14 +60,14 @@ public static Object[] onBeforeExecute(final @Advice.FieldValue("originalRequest
okhttp3.Request request = (okhttp3.Request) originalRequest;
HttpUrl url = request.url();
- Span span = HttpClientHelper.startHttpClientSpan(parent, request.method(), url.toString(), url.scheme(),
+ Span> span = HttpClientHelper.startHttpClientSpan(parent, request.method(), url.toString(), url.scheme(),
OkHttpClientHelper.computeHostName(url.host()), url.port());
if (span != null) {
span.activate();
}
- if (!TraceContext.containsTraceContextTextHeaders(request, OkHttp3RequestHeaderGetter.INSTANCE)) {
+ if (false) { // TODO !TraceContext.containsTraceContextTextHeaders(request, OkHttp3RequestHeaderGetter.INSTANCE)) {
Request.Builder builder = ((Request) originalRequest).newBuilder();
if (span != null) {
span.propagateTraceContext(builder, OkHttp3RequestHeaderSetter.INSTANCE);
@@ -86,9 +83,9 @@ public static Object[] onBeforeExecute(final @Advice.FieldValue("originalRequest
public static void onAfterExecute(@Advice.Return @Nullable okhttp3.Response response,
@Advice.Thrown @Nullable Throwable t,
@Advice.Enter @Nonnull Object[] enter) {
- Span span = null;
- if (enter[1] instanceof Span) {
- span = (Span) enter[1];
+ Span> span = null;
+ if (enter[1] instanceof Span>) {
+ span = (Span>) enter[1];
}
if (span != null) {
try {
@@ -96,7 +93,7 @@ public static void onAfterExecute(@Advice.Return @Nullable okhttp3.Response resp
int statusCode = response.code();
span.getContext().getHttp().withStatusCode(statusCode);
} else if (t != null) {
- span.withOutcome(Outcome.FAILURE);
+ span.withOutcome(DefaultOutcome.FAILURE);
}
span.captureException(t);
} finally {
diff --git a/apm-agent-plugins/apm-okhttp-plugin/src/main/java/co/elastic/apm/agent/okhttp/OkHttp3RequestHeaderGetter.java b/apm-agent-plugins/apm-okhttp-plugin/src/main/java/co/elastic/apm/agent/okhttp/OkHttp3RequestHeaderGetter.java
index a6e03f8de6d..d56540718c1 100644
--- a/apm-agent-plugins/apm-okhttp-plugin/src/main/java/co/elastic/apm/agent/okhttp/OkHttp3RequestHeaderGetter.java
+++ b/apm-agent-plugins/apm-okhttp-plugin/src/main/java/co/elastic/apm/agent/okhttp/OkHttp3RequestHeaderGetter.java
@@ -18,8 +18,8 @@
*/
package co.elastic.apm.agent.okhttp;
-import co.elastic.apm.agent.impl.transaction.AbstractHeaderGetter;
-import co.elastic.apm.agent.impl.transaction.TextHeaderGetter;
+import co.elastic.apm.plugin.spi.AbstractHeaderGetter;
+import co.elastic.apm.plugin.spi.TextHeaderGetter;
import okhttp3.Headers;
import okhttp3.Request;
diff --git a/apm-agent-plugins/apm-okhttp-plugin/src/main/java/co/elastic/apm/agent/okhttp/OkHttp3RequestHeaderSetter.java b/apm-agent-plugins/apm-okhttp-plugin/src/main/java/co/elastic/apm/agent/okhttp/OkHttp3RequestHeaderSetter.java
index e36e739296d..1fc850ec4d7 100644
--- a/apm-agent-plugins/apm-okhttp-plugin/src/main/java/co/elastic/apm/agent/okhttp/OkHttp3RequestHeaderSetter.java
+++ b/apm-agent-plugins/apm-okhttp-plugin/src/main/java/co/elastic/apm/agent/okhttp/OkHttp3RequestHeaderSetter.java
@@ -18,7 +18,7 @@
*/
package co.elastic.apm.agent.okhttp;
-import co.elastic.apm.agent.impl.transaction.TextHeaderSetter;
+import co.elastic.apm.plugin.spi.TextHeaderSetter;
import okhttp3.Request;
@SuppressWarnings("unused")
diff --git a/apm-agent-plugins/apm-okhttp-plugin/src/main/java/co/elastic/apm/agent/okhttp/OkHttpClientAsyncInstrumentation.java b/apm-agent-plugins/apm-okhttp-plugin/src/main/java/co/elastic/apm/agent/okhttp/OkHttpClientAsyncInstrumentation.java
index fe24707eea4..fb6410b6d50 100644
--- a/apm-agent-plugins/apm-okhttp-plugin/src/main/java/co/elastic/apm/agent/okhttp/OkHttpClientAsyncInstrumentation.java
+++ b/apm-agent-plugins/apm-okhttp-plugin/src/main/java/co/elastic/apm/agent/okhttp/OkHttpClientAsyncInstrumentation.java
@@ -19,10 +19,7 @@
package co.elastic.apm.agent.okhttp;
import co.elastic.apm.agent.httpclient.HttpClientHelper;
-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.impl.transaction.TraceContext;
+import co.elastic.apm.plugin.spi.*;
import com.squareup.okhttp.Call;
import com.squareup.okhttp.Callback;
import com.squareup.okhttp.Request;
@@ -76,14 +73,14 @@ public static Object[] onBeforeEnqueue(final @Advice.Origin Class extends Call
Callback callback = originalCallback;
URL url = request.url();
- Span span = HttpClientHelper.startHttpClientSpan(parent, request.method(), url.toString(), url.getProtocol(),
+ Span> span = HttpClientHelper.startHttpClientSpan(parent, request.method(), url.toString(), url.getProtocol(),
OkHttpClientHelper.computeHostName(url.getHost()), url.getPort());
if (span != null) {
span.activate();
}
- if (!TraceContext.containsTraceContextTextHeaders(request, OkHttpRequestHeaderGetter.INSTANCE)) {
+ if (!TraceContextUtil.containsTraceContextTextHeaders(request, OkHttpRequestHeaderGetter.INSTANCE)) {
Request.Builder builder = originalRequest.newBuilder();
if (span != null) {
span.propagateTraceContext(builder, OkHttpRequestHeaderSetter.INSTANCE);
@@ -99,7 +96,7 @@ public static Object[] onBeforeEnqueue(final @Advice.Origin Class extends Call
@Advice.OnMethodExit(suppress = Throwable.class, inline = false)
public static void onAfterEnqueue(@Advice.Enter @Nullable Object[] enter) {
- Span span = enter != null ? (Span) enter[2] : null;
+ Span> span = enter != null ? (Span>) enter[2] : null;
if (span != null) {
span.deactivate();
}
@@ -111,15 +108,15 @@ public static class CallbackWrapperCreator implements WrapperCreator {
public static final CallbackWrapperCreator INSTANCE = new CallbackWrapperCreator();
@Override
- public Callback wrap(final Callback delegate, Span span) {
+ public Callback wrap(final Callback delegate, Span> span) {
return new CallbackWrapper(span, delegate);
}
private static class CallbackWrapper implements Callback {
- private final Span span;
+ private final Span> span;
private final Callback delegate;
- CallbackWrapper(Span span, Callback delegate) {
+ CallbackWrapper(Span> span, Callback delegate) {
this.span = span;
this.delegate = delegate;
}
@@ -128,7 +125,7 @@ private static class CallbackWrapper implements Callback {
public void onFailure(Request req, IOException e) {
try {
span.captureException(e)
- .withOutcome(Outcome.FAILURE)
+ .withOutcome(DefaultOutcome.FAILURE)
.end();
} catch (Throwable t) {
logger.error(t.getMessage(), t);
diff --git a/apm-agent-plugins/apm-okhttp-plugin/src/main/java/co/elastic/apm/agent/okhttp/OkHttpClientInstrumentation.java b/apm-agent-plugins/apm-okhttp-plugin/src/main/java/co/elastic/apm/agent/okhttp/OkHttpClientInstrumentation.java
index 916692350c2..161e15fcf2a 100644
--- a/apm-agent-plugins/apm-okhttp-plugin/src/main/java/co/elastic/apm/agent/okhttp/OkHttpClientInstrumentation.java
+++ b/apm-agent-plugins/apm-okhttp-plugin/src/main/java/co/elastic/apm/agent/okhttp/OkHttpClientInstrumentation.java
@@ -19,10 +19,7 @@
package co.elastic.apm.agent.okhttp;
import co.elastic.apm.agent.httpclient.HttpClientHelper;
-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.impl.transaction.TraceContext;
+import co.elastic.apm.plugin.spi.*;
import com.squareup.okhttp.HttpUrl;
import com.squareup.okhttp.Request;
import net.bytebuddy.asm.Advice;
@@ -60,14 +57,14 @@ public static Object[] onBeforeExecute(@Advice.FieldValue("originalRequest") @Nu
com.squareup.okhttp.Request request = (com.squareup.okhttp.Request) originalRequest;
HttpUrl httpUrl = request.httpUrl();
- Span span = HttpClientHelper.startHttpClientSpan(parent, request.method(), httpUrl.toString(), httpUrl.scheme(),
+ Span> span = HttpClientHelper.startHttpClientSpan(parent, request.method(), httpUrl.toString(), httpUrl.scheme(),
OkHttpClientHelper.computeHostName(httpUrl.host()), httpUrl.port());
if (span != null) {
span.activate();
}
- if (!TraceContext.containsTraceContextTextHeaders(request, OkHttpRequestHeaderGetter.INSTANCE)) {
+ if (!TraceContextUtil.containsTraceContextTextHeaders(request, OkHttpRequestHeaderGetter.INSTANCE)) {
Request.Builder builder = ((Request) originalRequest).newBuilder();
if (span != null) {
span.propagateTraceContext(builder, OkHttpRequestHeaderSetter.INSTANCE);
@@ -84,9 +81,9 @@ public static Object[] onBeforeExecute(@Advice.FieldValue("originalRequest") @Nu
public static void onAfterExecute(@Advice.Return @Nullable com.squareup.okhttp.Response response,
@Advice.Thrown @Nullable Throwable t,
@Advice.Enter @Nonnull Object[] enter) {
- Span span = null;
- if (enter[1] instanceof Span) {
- span = (Span) enter[1];
+ Span> span = null;
+ if (enter[1] instanceof Span>) {
+ span = (Span>) enter[1];
}
if (span != null) {
try {
@@ -94,7 +91,7 @@ public static void onAfterExecute(@Advice.Return @Nullable com.squareup.okhttp.R
int statusCode = response.code();
span.getContext().getHttp().withStatusCode(statusCode);
} else if (t != null) {
- span.withOutcome(Outcome.FAILURE);
+ span.withOutcome(DefaultOutcome.FAILURE);
}
span.captureException(t);
} finally {
diff --git a/apm-agent-plugins/apm-okhttp-plugin/src/main/java/co/elastic/apm/agent/okhttp/OkHttpRequestHeaderGetter.java b/apm-agent-plugins/apm-okhttp-plugin/src/main/java/co/elastic/apm/agent/okhttp/OkHttpRequestHeaderGetter.java
index 69f73c13758..e79582fe316 100644
--- a/apm-agent-plugins/apm-okhttp-plugin/src/main/java/co/elastic/apm/agent/okhttp/OkHttpRequestHeaderGetter.java
+++ b/apm-agent-plugins/apm-okhttp-plugin/src/main/java/co/elastic/apm/agent/okhttp/OkHttpRequestHeaderGetter.java
@@ -18,8 +18,8 @@
*/
package co.elastic.apm.agent.okhttp;
-import co.elastic.apm.agent.impl.transaction.AbstractHeaderGetter;
-import co.elastic.apm.agent.impl.transaction.TextHeaderGetter;
+import co.elastic.apm.plugin.spi.AbstractHeaderGetter;
+import co.elastic.apm.plugin.spi.TextHeaderGetter;
import com.squareup.okhttp.Headers;
import com.squareup.okhttp.Request;
diff --git a/apm-agent-plugins/apm-okhttp-plugin/src/main/java/co/elastic/apm/agent/okhttp/OkHttpRequestHeaderSetter.java b/apm-agent-plugins/apm-okhttp-plugin/src/main/java/co/elastic/apm/agent/okhttp/OkHttpRequestHeaderSetter.java
index e250deb82f1..a7b475625b8 100644
--- a/apm-agent-plugins/apm-okhttp-plugin/src/main/java/co/elastic/apm/agent/okhttp/OkHttpRequestHeaderSetter.java
+++ b/apm-agent-plugins/apm-okhttp-plugin/src/main/java/co/elastic/apm/agent/okhttp/OkHttpRequestHeaderSetter.java
@@ -18,7 +18,7 @@
*/
package co.elastic.apm.agent.okhttp;
-import co.elastic.apm.agent.impl.transaction.TextHeaderSetter;
+import co.elastic.apm.plugin.spi.TextHeaderSetter;
import com.squareup.okhttp.Request;
@SuppressWarnings("unused")
diff --git a/apm-agent-plugins/apm-okhttp-plugin/src/main/java/co/elastic/apm/agent/okhttp/WrapperCreator.java b/apm-agent-plugins/apm-okhttp-plugin/src/main/java/co/elastic/apm/agent/okhttp/WrapperCreator.java
index e5ae857f03c..8b944ee82d9 100644
--- a/apm-agent-plugins/apm-okhttp-plugin/src/main/java/co/elastic/apm/agent/okhttp/WrapperCreator.java
+++ b/apm-agent-plugins/apm-okhttp-plugin/src/main/java/co/elastic/apm/agent/okhttp/WrapperCreator.java
@@ -18,7 +18,7 @@
*/
package co.elastic.apm.agent.okhttp;
-import co.elastic.apm.agent.impl.transaction.Span;
+import co.elastic.apm.plugin.spi.Span;
/**
* Used to create a wrapper for a callback or listener
@@ -37,5 +37,5 @@ public interface WrapperCreator {
* @param span the currently active span
* @return the wrapped callback
*/
- T wrap(T delegate, Span span);
+ T wrap(T delegate, Span> span);
}
diff --git a/apm-agent-plugins/apm-opentracing-plugin/src/main/java/co/elastic/apm/agent/opentracingimpl/OpenTracingTextMapBridge.java b/apm-agent-plugins/apm-opentracing-plugin/src/main/java/co/elastic/apm/agent/opentracingimpl/OpenTracingTextMapBridge.java
index 43cce696094..da1de44f496 100644
--- a/apm-agent-plugins/apm-opentracing-plugin/src/main/java/co/elastic/apm/agent/opentracingimpl/OpenTracingTextMapBridge.java
+++ b/apm-agent-plugins/apm-opentracing-plugin/src/main/java/co/elastic/apm/agent/opentracingimpl/OpenTracingTextMapBridge.java
@@ -18,6 +18,7 @@
*/
package co.elastic.apm.agent.opentracingimpl;
+import co.elastic.apm.agent.impl.transaction.HeaderGetter;
import co.elastic.apm.agent.impl.transaction.TextHeaderGetter;
import co.elastic.apm.agent.impl.transaction.TextHeaderSetter;
@@ -47,7 +48,16 @@ public String getFirstHeader(String headerName, Iterable void forEach(String headerName, Iterable> carrier, S state, HeaderConsumer consumer) {
+ public void forEach(String headerName, Iterable> carrier, S state, HeaderGetter.HeaderConsumer consumer) {
+ for (Map.Entry entry : carrier) {
+ if (entry.getKey().equalsIgnoreCase(headerName)) {
+ consumer.accept(entry.getValue(), state);
+ }
+ }
+ }
+
+ @Override
+ public void forEach(String headerName, Iterable> carrier, S state, co.elastic.apm.plugin.spi.HeaderGetter.HeaderConsumer consumer) {
for (Map.Entry entry : carrier) {
if (entry.getKey().equalsIgnoreCase(headerName)) {
consumer.accept(entry.getValue(), state);
diff --git a/apm-agent-plugins/apm-process-plugin/src/main/java/co/elastic/apm/agent/process/ProcessHelper.java b/apm-agent-plugins/apm-process-plugin/src/main/java/co/elastic/apm/agent/process/ProcessHelper.java
index 4c54050fa14..0838b3d81ac 100644
--- a/apm-agent-plugins/apm-process-plugin/src/main/java/co/elastic/apm/agent/process/ProcessHelper.java
+++ b/apm-agent-plugins/apm-process-plugin/src/main/java/co/elastic/apm/agent/process/ProcessHelper.java
@@ -19,9 +19,10 @@
package co.elastic.apm.agent.process;
import co.elastic.apm.agent.collections.WeakConcurrentProviderImpl;
-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.plugin.spi.AbstractSpan;
+import co.elastic.apm.plugin.spi.DefaultOutcome;
+import co.elastic.apm.plugin.spi.Outcome;
+import co.elastic.apm.plugin.spi.Span;
import co.elastic.apm.agent.sdk.state.GlobalVariables;
import co.elastic.apm.agent.sdk.weakconcurrent.WeakMap;
@@ -34,7 +35,7 @@
*/
class ProcessHelper {
- private static final ProcessHelper INSTANCE = new ProcessHelper(WeakConcurrentProviderImpl.createWeakSpanMap());
+ private static final ProcessHelper INSTANCE = new ProcessHelper(WeakConcurrentProviderImpl.>createWeakSpanMap());
/**
* A thread local used to indicate whether the currently invoked instrumented method is invoked by the plugin itself.
@@ -44,9 +45,9 @@ class ProcessHelper {
*/
private static final ThreadLocal inTracingContext = GlobalVariables.get(ProcessHelper.class, "inTracingContext", new ThreadLocal());
- private final WeakMap inFlightSpans;
+ private final WeakMap> inFlightSpans;
- ProcessHelper(WeakMap inFlightSpans) {
+ ProcessHelper(WeakMap> inFlightSpans) {
this.inFlightSpans = inFlightSpans;
}
@@ -80,7 +81,7 @@ void doStartProcess(@Nonnull AbstractSpan> parentContext, @Nonnull Process pro
String binaryName = getBinaryName(processName);
- Span span = parentContext.createSpan()
+ Span> span = parentContext.createSpan()
.withType("process")
.withName(binaryName);
@@ -104,12 +105,12 @@ private static String getBinaryName(String processName) {
*/
void doEndProcess(Process process, boolean checkTerminatedProcess) {
- Span span = inFlightSpans.get(process);
+ Span> span = inFlightSpans.get(process);
if (span == null) {
return;
}
- Outcome outcome = Outcome.UNKNOWN;
+ Outcome outcome = DefaultOutcome.UNKNOWN;
boolean endAndRemoveSpan = !checkTerminatedProcess;
if (checkTerminatedProcess) {
// borrowed from java 8 Process#isAlive()
@@ -119,11 +120,11 @@ void doEndProcess(Process process, boolean checkTerminatedProcess) {
try {
inTracingContext.set(Boolean.TRUE);
int exitValue = process.exitValue();
- outcome = exitValue == 0 ? Outcome.SUCCESS : Outcome.FAILURE;
+ outcome = exitValue == 0 ? DefaultOutcome.SUCCESS : DefaultOutcome.FAILURE;
endAndRemoveSpan = true;
} catch (IllegalThreadStateException e) {
// process hasn't terminated, we don't know it's actual return value
- outcome = Outcome.UNKNOWN;
+ outcome = DefaultOutcome.UNKNOWN;
endAndRemoveSpan = false;
} finally {
inTracingContext.remove();
@@ -141,14 +142,14 @@ void doEndProcess(Process process, boolean checkTerminatedProcess) {
* @param exitValue exit value of the terminated process
*/
void doEndProcessSpan(Process process, int exitValue) {
- removeAndEndSpan(process, exitValue == 0 ? Outcome.SUCCESS : Outcome.FAILURE);
+ removeAndEndSpan(process, exitValue == 0 ? DefaultOutcome.SUCCESS : DefaultOutcome.FAILURE);
}
private void removeAndEndSpan(Process process, Outcome outcome) {
- Span span = inFlightSpans.remove(process);
+ Span> span = inFlightSpans.remove(process);
if (span != null) {
- span.withOutcome(outcome).
- end();
+ span.withOutcome(outcome)
+ .end();
}
}
}
diff --git a/apm-agent-plugins/apm-process-plugin/src/main/java/co/elastic/apm/agent/process/ProcessStartInstrumentation.java b/apm-agent-plugins/apm-process-plugin/src/main/java/co/elastic/apm/agent/process/ProcessStartInstrumentation.java
index 027526137b0..63c64d89134 100644
--- a/apm-agent-plugins/apm-process-plugin/src/main/java/co/elastic/apm/agent/process/ProcessStartInstrumentation.java
+++ b/apm-agent-plugins/apm-process-plugin/src/main/java/co/elastic/apm/agent/process/ProcessStartInstrumentation.java
@@ -18,7 +18,7 @@
*/
package co.elastic.apm.agent.process;
-import co.elastic.apm.agent.impl.transaction.AbstractSpan;
+import co.elastic.apm.plugin.spi.AbstractSpan;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription;
diff --git a/apm-agent-plugins/apm-process-plugin/src/test/java/co/elastic/apm/agent/process/ProcessHelperTest.java b/apm-agent-plugins/apm-process-plugin/src/test/java/co/elastic/apm/agent/process/ProcessHelperTest.java
index 12d8cc08a8d..39b40d6fcb9 100644
--- a/apm-agent-plugins/apm-process-plugin/src/test/java/co/elastic/apm/agent/process/ProcessHelperTest.java
+++ b/apm-agent-plugins/apm-process-plugin/src/test/java/co/elastic/apm/agent/process/ProcessHelperTest.java
@@ -48,7 +48,7 @@ class ProcessHelperTest extends AbstractInstrumentationTest {
private Transaction transaction;
- private WeakMap storageMap;
+ private WeakMap> storageMap;
private ProcessHelper helper;
@BeforeEach
@@ -85,7 +85,7 @@ void startTwiceShouldIgnore() {
Process process = mock(Process.class);
helper.doStartProcess(transaction, process, "hello");
- Span span = storageMap.get(process);
+ Span span = (Span) storageMap.get(process);
helper.doStartProcess(transaction, process, "hello");
assertThat(storageMap.get(process))
diff --git a/apm-agent-plugins/apm-profiling-plugin/src/main/java/co/elastic/apm/agent/profiler/CallTree.java b/apm-agent-plugins/apm-profiling-plugin/src/main/java/co/elastic/apm/agent/profiler/CallTree.java
index 381d2be8da9..c7fda6819d1 100644
--- a/apm-agent-plugins/apm-profiling-plugin/src/main/java/co/elastic/apm/agent/profiler/CallTree.java
+++ b/apm-agent-plugins/apm-profiling-plugin/src/main/java/co/elastic/apm/agent/profiler/CallTree.java
@@ -78,7 +78,7 @@ public class CallTree implements Recyclable {
private boolean isSpan;
private int depth;
/**
- * @see co.elastic.apm.agent.impl.transaction.AbstractSpan#childIds
+ * @see co.elastic.apm.plugin.spi.AbstractSpan#childIds
*/
@Nullable
private LongList childIds;
diff --git a/apm-agent-plugins/apm-profiling-plugin/src/main/java/co/elastic/apm/agent/profiler/ProfilingActivationListener.java b/apm-agent-plugins/apm-profiling-plugin/src/main/java/co/elastic/apm/agent/profiler/ProfilingActivationListener.java
index a38311b359a..277759536fe 100644
--- a/apm-agent-plugins/apm-profiling-plugin/src/main/java/co/elastic/apm/agent/profiler/ProfilingActivationListener.java
+++ b/apm-agent-plugins/apm-profiling-plugin/src/main/java/co/elastic/apm/agent/profiler/ProfilingActivationListener.java
@@ -20,7 +20,6 @@
import co.elastic.apm.agent.impl.ActivationListener;
import co.elastic.apm.agent.impl.ElasticApmTracer;
-import co.elastic.apm.agent.impl.Tracer;
import co.elastic.apm.agent.impl.transaction.AbstractSpan;
import java.util.Objects;
diff --git a/apm-agent-plugins/apm-profiling-plugin/src/main/java/co/elastic/apm/agent/profiler/SamplingProfiler.java b/apm-agent-plugins/apm-profiling-plugin/src/main/java/co/elastic/apm/agent/profiler/SamplingProfiler.java
index 04a77a9ebcd..b2e76786f72 100644
--- a/apm-agent-plugins/apm-profiling-plugin/src/main/java/co/elastic/apm/agent/profiler/SamplingProfiler.java
+++ b/apm-agent-plugins/apm-profiling-plugin/src/main/java/co/elastic/apm/agent/profiler/SamplingProfiler.java
@@ -23,9 +23,8 @@
import co.elastic.apm.agent.context.AbstractLifecycleListener;
import co.elastic.apm.agent.impl.ElasticApmTracer;
import co.elastic.apm.agent.impl.Tracer;
-import co.elastic.apm.agent.impl.transaction.Span;
-import co.elastic.apm.agent.impl.transaction.StackFrame;
import co.elastic.apm.agent.impl.transaction.TraceContext;
+import co.elastic.apm.agent.impl.transaction.StackFrame;
import co.elastic.apm.agent.common.util.WildcardMatcher;
import co.elastic.apm.agent.objectpool.Allocator;
import co.elastic.apm.agent.objectpool.ObjectPool;
diff --git a/apm-agent-plugins/apm-quartz-job-plugin/apm-quartz-1-plugin/src/main/java/co/elastic/apm/agent/quartzjob/Quartz1JobTransactionNameInstrumentation.java b/apm-agent-plugins/apm-quartz-job-plugin/apm-quartz-1-plugin/src/main/java/co/elastic/apm/agent/quartzjob/Quartz1JobTransactionNameInstrumentation.java
index a4e31f72fb1..58f4c001658 100644
--- a/apm-agent-plugins/apm-quartz-job-plugin/apm-quartz-1-plugin/src/main/java/co/elastic/apm/agent/quartzjob/Quartz1JobTransactionNameInstrumentation.java
+++ b/apm-agent-plugins/apm-quartz-job-plugin/apm-quartz-1-plugin/src/main/java/co/elastic/apm/agent/quartzjob/Quartz1JobTransactionNameInstrumentation.java
@@ -19,7 +19,7 @@
package co.elastic.apm.agent.quartzjob;
import co.elastic.apm.agent.bci.bytebuddy.SimpleMethodSignatureOffsetMappingFactory;
-import co.elastic.apm.agent.impl.Tracer;
+import co.elastic.apm.plugin.spi.Tracer;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.matcher.ElementMatcher;
diff --git a/apm-agent-plugins/apm-quartz-job-plugin/apm-quartz-2-plugin/src/main/java/co/elastic/apm/agent/quartzjob/Quartz2JobTransactionNameInstrumentation.java b/apm-agent-plugins/apm-quartz-job-plugin/apm-quartz-2-plugin/src/main/java/co/elastic/apm/agent/quartzjob/Quartz2JobTransactionNameInstrumentation.java
index f2ce10e5c47..7542fc04f23 100644
--- a/apm-agent-plugins/apm-quartz-job-plugin/apm-quartz-2-plugin/src/main/java/co/elastic/apm/agent/quartzjob/Quartz2JobTransactionNameInstrumentation.java
+++ b/apm-agent-plugins/apm-quartz-job-plugin/apm-quartz-2-plugin/src/main/java/co/elastic/apm/agent/quartzjob/Quartz2JobTransactionNameInstrumentation.java
@@ -19,7 +19,7 @@
package co.elastic.apm.agent.quartzjob;
import co.elastic.apm.agent.bci.bytebuddy.SimpleMethodSignatureOffsetMappingFactory;
-import co.elastic.apm.agent.impl.Tracer;
+import co.elastic.apm.plugin.spi.Tracer;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.matcher.ElementMatcher;
diff --git a/apm-agent-plugins/apm-quartz-job-plugin/quartz-common/src/main/java/co/elastic/apm/agent/quartzjob/AbstractJobTransactionNameInstrumentation.java b/apm-agent-plugins/apm-quartz-job-plugin/quartz-common/src/main/java/co/elastic/apm/agent/quartzjob/AbstractJobTransactionNameInstrumentation.java
index a58ef6fec1e..9287d7572b5 100644
--- a/apm-agent-plugins/apm-quartz-job-plugin/quartz-common/src/main/java/co/elastic/apm/agent/quartzjob/AbstractJobTransactionNameInstrumentation.java
+++ b/apm-agent-plugins/apm-quartz-job-plugin/quartz-common/src/main/java/co/elastic/apm/agent/quartzjob/AbstractJobTransactionNameInstrumentation.java
@@ -19,12 +19,9 @@
package co.elastic.apm.agent.quartzjob;
import co.elastic.apm.agent.bci.TracerAwareInstrumentation;
-import co.elastic.apm.agent.impl.GlobalTracer;
-import co.elastic.apm.agent.impl.Tracer;
+import co.elastic.apm.plugin.spi.Tracer;
import co.elastic.apm.agent.impl.stacktrace.StacktraceConfiguration;
-import co.elastic.apm.agent.impl.transaction.AbstractSpan;
-import co.elastic.apm.agent.impl.transaction.Outcome;
-import co.elastic.apm.agent.impl.transaction.Transaction;
+import co.elastic.apm.plugin.spi.*;
import co.elastic.apm.agent.util.PrivilegedActionUtils;
import co.elastic.apm.agent.util.VersionUtils;
import net.bytebuddy.description.NamedElement;
@@ -73,9 +70,9 @@ static class BaseAdvice {
private static final Logger logger = LoggerFactory.getLogger(BaseAdvice.class);
@Nullable
- protected static Transaction createAndActivateTransaction(@Nullable T jobExecutionContext, String signature, Class> clazz, JobExecutionContextHandler helper) {
- Transaction transaction = null;
- AbstractSpan> active = GlobalTracer.get().getActive();
+ protected static Transaction> createAndActivateTransaction(@Nullable T jobExecutionContext, String signature, Class> clazz, JobExecutionContextHandler helper) {
+ Transaction> transaction = null;
+ AbstractSpan> active = tracer.getActive();
if (active == null) {
String transactionName = null;
if (jobExecutionContext != null) {
@@ -97,8 +94,8 @@ protected static void endTransaction(@Nullable T jobExecutionContext,
@Nullable Object transactionObj,
@Nullable Throwable t,
JobExecutionContextHandler helper) {
- if (transactionObj instanceof Transaction) {
- Transaction transaction = (Transaction) transactionObj;
+ if (transactionObj instanceof Transaction>) {
+ Transaction> transaction = (Transaction>) transactionObj;
if (jobExecutionContext != null) {
Object result = helper.getResult(jobExecutionContext);
if (result != null) {
@@ -106,15 +103,15 @@ protected static void endTransaction(@Nullable T jobExecutionContext,
}
}
transaction.captureException(t)
- .withOutcome(t != null ? Outcome.FAILURE : Outcome.SUCCESS)
+ .withOutcome(t != null ? DefaultOutcome.FAILURE : DefaultOutcome.SUCCESS)
.deactivate()
.end();
}
}
@Nullable
- private static Transaction createAndActivateTransaction(Class> originClass, String name) {
- Transaction transaction = GlobalTracer.get().startRootTransaction(PrivilegedActionUtils.getClassLoader(originClass));
+ private static Transaction> createAndActivateTransaction(Class> originClass, String name) {
+ Transaction> transaction = tracer.startRootTransaction(PrivilegedActionUtils.getClassLoader(originClass));
if (transaction != null) {
transaction.withName(name)
.withType(AbstractJobTransactionNameInstrumentation.TRANSACTION_TYPE)
diff --git a/apm-agent-plugins/apm-rabbitmq/apm-rabbitmq-plugin/src/main/java/co/elastic/apm/agent/rabbitmq/AbstractBaseInstrumentation.java b/apm-agent-plugins/apm-rabbitmq/apm-rabbitmq-plugin/src/main/java/co/elastic/apm/agent/rabbitmq/AbstractBaseInstrumentation.java
index 5db3d494459..d289187975b 100644
--- a/apm-agent-plugins/apm-rabbitmq/apm-rabbitmq-plugin/src/main/java/co/elastic/apm/agent/rabbitmq/AbstractBaseInstrumentation.java
+++ b/apm-agent-plugins/apm-rabbitmq/apm-rabbitmq-plugin/src/main/java/co/elastic/apm/agent/rabbitmq/AbstractBaseInstrumentation.java
@@ -21,10 +21,10 @@
import co.elastic.apm.agent.bci.TracerAwareInstrumentation;
import co.elastic.apm.agent.configuration.CoreConfiguration;
import co.elastic.apm.agent.configuration.MessagingConfiguration;
-import co.elastic.apm.agent.impl.GlobalTracer;
-import co.elastic.apm.agent.impl.context.Message;
-import co.elastic.apm.agent.impl.transaction.AbstractSpan;
+import co.elastic.apm.plugin.spi.GlobalTracer;
+import co.elastic.apm.plugin.spi.AbstractSpan;
import co.elastic.apm.agent.common.util.WildcardMatcher;
+import co.elastic.apm.plugin.spi.Message;
import javax.annotation.Nullable;
import java.util.Date;
diff --git a/apm-agent-plugins/apm-rabbitmq/apm-rabbitmq-plugin/src/main/java/co/elastic/apm/agent/rabbitmq/ChannelInstrumentation.java b/apm-agent-plugins/apm-rabbitmq/apm-rabbitmq-plugin/src/main/java/co/elastic/apm/agent/rabbitmq/ChannelInstrumentation.java
index 7d59af8ba03..230e5e2f8b3 100644
--- a/apm-agent-plugins/apm-rabbitmq/apm-rabbitmq-plugin/src/main/java/co/elastic/apm/agent/rabbitmq/ChannelInstrumentation.java
+++ b/apm-agent-plugins/apm-rabbitmq/apm-rabbitmq-plugin/src/main/java/co/elastic/apm/agent/rabbitmq/ChannelInstrumentation.java
@@ -18,13 +18,13 @@
*/
package co.elastic.apm.agent.rabbitmq;
-import co.elastic.apm.agent.impl.transaction.AbstractSpan;
-import co.elastic.apm.agent.impl.transaction.Span;
-import co.elastic.apm.agent.impl.transaction.TraceContext;
+import co.elastic.apm.plugin.spi.AbstractSpan;
+import co.elastic.apm.plugin.spi.Span;
import co.elastic.apm.agent.rabbitmq.header.RabbitMQTextHeaderGetter;
import co.elastic.apm.agent.rabbitmq.header.RabbitMQTextHeaderSetter;
import co.elastic.apm.agent.sdk.DynamicTransformer;
import co.elastic.apm.agent.sdk.ElasticApmInstrumentation;
+import co.elastic.apm.plugin.spi.TraceContextUtil;
import com.rabbitmq.client.AMQP;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
@@ -134,7 +134,7 @@ public static Object[] onBasicPublish(@Advice.This Channel channel,
return null;
}
- Span exitSpan = RabbitMqHelper.createExitSpan(exchange);
+ Span> exitSpan = RabbitMqHelper.createExitSpan(exchange);
if (exitSpan == null) {
// tracer disabled or ignored exchange or this is nested within another exit span
return null;
@@ -154,7 +154,7 @@ public static Object[] onBasicPublish(@Advice.This Channel channel,
return new Object[]{properties, exitSpan};
}
- private static AMQP.BasicProperties propagateTraceContext(Span exitSpan,
+ private static AMQP.BasicProperties propagateTraceContext(Span> exitSpan,
@Nullable AMQP.BasicProperties originalBasicProperties) {
AMQP.BasicProperties properties = originalBasicProperties;
if (properties == null) {
@@ -177,7 +177,7 @@ private static AMQP.BasicProperties propagateTraceContext(Span exitSpan,
public static void afterBasicPublish(@Advice.Enter @Nullable Object[] enterArray,
@Advice.Thrown @Nullable Throwable throwable) {
if (enterArray != null && enterArray.length >= 2 && enterArray[1] != null) {
- Span span = (Span) enterArray[1];
+ Span> span = (Span>) enterArray[1];
span.captureException(throwable)
.deactivate()
.end();
@@ -219,10 +219,10 @@ public static void onExit(@Advice.This Channel channel,
@Advice.Return @Nullable GetResponse rv,
@Advice.Thrown @Nullable Throwable thrown) {
- if (!(objSpan instanceof Span)) {
+ if (!(objSpan instanceof Span>)) {
return;
}
- Span span = (Span) objSpan;
+ Span> span = (Span>) objSpan;
if (isIgnored(queue)) {
// allow to ignore on queue name when there is no answer
@@ -255,7 +255,7 @@ public static void onExit(@Advice.This Channel channel,
if (properties != null) {
span.addSpanLink(
- TraceContext.getFromTraceContextTextHeaders(),
+ TraceContextUtil.getFromTraceContextTextHeaders(),
RabbitMQTextHeaderGetter.INSTANCE,
properties);
}
@@ -275,12 +275,12 @@ public static class RabbitMqHelper {
* @return exit span if applicable, {@literal null} otherwise
*/
@Nullable
- public static Span createExitSpan(@Nullable String exchangeOrQueue) {
+ public static Span> createExitSpan(@Nullable String exchangeOrQueue) {
AbstractSpan> context = tracer.getActive();
if (exchangeOrQueue == null || context == null || isIgnored(exchangeOrQueue)) {
return null;
}
- Span exitSpan = context.createExitSpan();
+ Span> exitSpan = context.createExitSpan();
if (exitSpan == null) {
return null;
}
@@ -298,7 +298,7 @@ public static Span createExitSpan(@Nullable String exchangeOrQueue) {
* @param port broker port
* @param span span
*/
- public static void captureDestination(String exchange, InetAddress brokerAddress, int port, Span span) {
+ public static void captureDestination(String exchange, InetAddress brokerAddress, int port, Span> span) {
span.getContext().getDestination()
.withInetAddress(brokerAddress)
.withPort(port);
diff --git a/apm-agent-plugins/apm-rabbitmq/apm-rabbitmq-plugin/src/main/java/co/elastic/apm/agent/rabbitmq/ConsumerInstrumentation.java b/apm-agent-plugins/apm-rabbitmq/apm-rabbitmq-plugin/src/main/java/co/elastic/apm/agent/rabbitmq/ConsumerInstrumentation.java
index daf76490384..e5637a18519 100644
--- a/apm-agent-plugins/apm-rabbitmq/apm-rabbitmq-plugin/src/main/java/co/elastic/apm/agent/rabbitmq/ConsumerInstrumentation.java
+++ b/apm-agent-plugins/apm-rabbitmq/apm-rabbitmq-plugin/src/main/java/co/elastic/apm/agent/rabbitmq/ConsumerInstrumentation.java
@@ -18,8 +18,8 @@
*/
package co.elastic.apm.agent.rabbitmq;
-import co.elastic.apm.agent.impl.context.Message;
-import co.elastic.apm.agent.impl.transaction.Transaction;
+import co.elastic.apm.plugin.spi.Message;
+import co.elastic.apm.plugin.spi.Transaction;
import co.elastic.apm.agent.rabbitmq.header.RabbitMQTextHeaderGetter;
import co.elastic.apm.agent.util.PrivilegedActionUtils;
import com.rabbitmq.client.AMQP;
@@ -96,7 +96,7 @@ public static Object onHandleDelivery(@Advice.Origin Class> originClazz,
return null;
}
- Transaction transaction = tracer.currentTransaction();
+ Transaction> transaction = tracer.currentTransaction();
if (transaction != null) {
return null;
}
@@ -122,8 +122,8 @@ public static Object onHandleDelivery(@Advice.Origin Class> originClazz,
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class, inline = false)
public static void afterHandleDelivery(@Advice.Enter @Nullable final Object transactionObject,
@Advice.Thrown @Nullable final Throwable throwable) {
- if (transactionObject instanceof Transaction) {
- Transaction transaction = (Transaction) transactionObject;
+ if (transactionObject instanceof Transaction>) {
+ Transaction> transaction = (Transaction>) transactionObject;
transaction.captureException(throwable)
.deactivate()
.end();
diff --git a/apm-agent-plugins/apm-rabbitmq/apm-rabbitmq-plugin/src/main/java/co/elastic/apm/agent/rabbitmq/header/AbstractTextHeaderGetter.java b/apm-agent-plugins/apm-rabbitmq/apm-rabbitmq-plugin/src/main/java/co/elastic/apm/agent/rabbitmq/header/AbstractTextHeaderGetter.java
index bb8869f8239..d9e61320acd 100644
--- a/apm-agent-plugins/apm-rabbitmq/apm-rabbitmq-plugin/src/main/java/co/elastic/apm/agent/rabbitmq/header/AbstractTextHeaderGetter.java
+++ b/apm-agent-plugins/apm-rabbitmq/apm-rabbitmq-plugin/src/main/java/co/elastic/apm/agent/rabbitmq/header/AbstractTextHeaderGetter.java
@@ -18,7 +18,7 @@
*/
package co.elastic.apm.agent.rabbitmq.header;
-import co.elastic.apm.agent.impl.transaction.TextHeaderGetter;
+import co.elastic.apm.plugin.spi.TextHeaderGetter;
import javax.annotation.Nullable;
import java.util.Map;
diff --git a/apm-agent-plugins/apm-rabbitmq/apm-rabbitmq-plugin/src/main/java/co/elastic/apm/agent/rabbitmq/header/RabbitMQTextHeaderSetter.java b/apm-agent-plugins/apm-rabbitmq/apm-rabbitmq-plugin/src/main/java/co/elastic/apm/agent/rabbitmq/header/RabbitMQTextHeaderSetter.java
index 6312c965c8c..1101fdf3058 100644
--- a/apm-agent-plugins/apm-rabbitmq/apm-rabbitmq-plugin/src/main/java/co/elastic/apm/agent/rabbitmq/header/RabbitMQTextHeaderSetter.java
+++ b/apm-agent-plugins/apm-rabbitmq/apm-rabbitmq-plugin/src/main/java/co/elastic/apm/agent/rabbitmq/header/RabbitMQTextHeaderSetter.java
@@ -18,7 +18,7 @@
*/
package co.elastic.apm.agent.rabbitmq.header;
-import co.elastic.apm.agent.impl.transaction.TextHeaderSetter;
+import co.elastic.apm.plugin.spi.TextHeaderSetter;
import java.util.HashMap;
diff --git a/apm-agent-plugins/apm-rabbitmq/apm-rabbitmq-spring/src/main/java/co/elastic/apm/agent/rabbitmq/MessageBatchHelper.java b/apm-agent-plugins/apm-rabbitmq/apm-rabbitmq-spring/src/main/java/co/elastic/apm/agent/rabbitmq/MessageBatchHelper.java
index 475ca37e3fe..dbe0677413f 100644
--- a/apm-agent-plugins/apm-rabbitmq/apm-rabbitmq-spring/src/main/java/co/elastic/apm/agent/rabbitmq/MessageBatchHelper.java
+++ b/apm-agent-plugins/apm-rabbitmq/apm-rabbitmq-spring/src/main/java/co/elastic/apm/agent/rabbitmq/MessageBatchHelper.java
@@ -18,7 +18,7 @@
*/
package co.elastic.apm.agent.rabbitmq;
-import co.elastic.apm.agent.impl.Tracer;
+import co.elastic.apm.plugin.spi.Tracer;
import co.elastic.apm.agent.sdk.logging.Logger;
import co.elastic.apm.agent.sdk.logging.LoggerFactory;
import org.springframework.amqp.core.Message;
diff --git a/apm-agent-plugins/apm-rabbitmq/apm-rabbitmq-spring/src/main/java/co/elastic/apm/agent/rabbitmq/MessageBatchIteratorWrapper.java b/apm-agent-plugins/apm-rabbitmq/apm-rabbitmq-spring/src/main/java/co/elastic/apm/agent/rabbitmq/MessageBatchIteratorWrapper.java
index 03630860f76..0af235af0a3 100644
--- a/apm-agent-plugins/apm-rabbitmq/apm-rabbitmq-spring/src/main/java/co/elastic/apm/agent/rabbitmq/MessageBatchIteratorWrapper.java
+++ b/apm-agent-plugins/apm-rabbitmq/apm-rabbitmq-spring/src/main/java/co/elastic/apm/agent/rabbitmq/MessageBatchIteratorWrapper.java
@@ -19,8 +19,8 @@
package co.elastic.apm.agent.rabbitmq;
-import co.elastic.apm.agent.impl.Tracer;
-import co.elastic.apm.agent.impl.transaction.Transaction;
+import co.elastic.apm.plugin.spi.Tracer;
+import co.elastic.apm.plugin.spi.Transaction;
import co.elastic.apm.agent.sdk.logging.Logger;
import co.elastic.apm.agent.sdk.logging.LoggerFactory;
import org.springframework.amqp.core.Message;
@@ -49,7 +49,7 @@ public boolean hasNext() {
public void endCurrentTransaction() {
try {
- Transaction transaction = tracer.currentTransaction();
+ Transaction> transaction = tracer.currentTransaction();
if (transaction != null && "messaging".equals(transaction.getType())) {
transaction.deactivate().end();
}
diff --git a/apm-agent-plugins/apm-rabbitmq/apm-rabbitmq-spring/src/main/java/co/elastic/apm/agent/rabbitmq/MessageBatchListWrapper.java b/apm-agent-plugins/apm-rabbitmq/apm-rabbitmq-spring/src/main/java/co/elastic/apm/agent/rabbitmq/MessageBatchListWrapper.java
index 37f3608a1d8..a8eff100e04 100644
--- a/apm-agent-plugins/apm-rabbitmq/apm-rabbitmq-spring/src/main/java/co/elastic/apm/agent/rabbitmq/MessageBatchListWrapper.java
+++ b/apm-agent-plugins/apm-rabbitmq/apm-rabbitmq-spring/src/main/java/co/elastic/apm/agent/rabbitmq/MessageBatchListWrapper.java
@@ -19,7 +19,7 @@
package co.elastic.apm.agent.rabbitmq;
-import co.elastic.apm.agent.impl.Tracer;
+import co.elastic.apm.plugin.spi.Tracer;
import org.springframework.amqp.core.Message;
import java.util.Collection;
diff --git a/apm-agent-plugins/apm-rabbitmq/apm-rabbitmq-spring/src/main/java/co/elastic/apm/agent/rabbitmq/SpringAmqpBatchMessageListenerInstrumentation.java b/apm-agent-plugins/apm-rabbitmq/apm-rabbitmq-spring/src/main/java/co/elastic/apm/agent/rabbitmq/SpringAmqpBatchMessageListenerInstrumentation.java
index 3f78e6b7170..bab80acca42 100644
--- a/apm-agent-plugins/apm-rabbitmq/apm-rabbitmq-spring/src/main/java/co/elastic/apm/agent/rabbitmq/SpringAmqpBatchMessageListenerInstrumentation.java
+++ b/apm-agent-plugins/apm-rabbitmq/apm-rabbitmq-spring/src/main/java/co/elastic/apm/agent/rabbitmq/SpringAmqpBatchMessageListenerInstrumentation.java
@@ -20,11 +20,7 @@
import co.elastic.apm.agent.configuration.MessagingConfiguration;
-import co.elastic.apm.agent.impl.GlobalTracer;
-import co.elastic.apm.agent.impl.Tracer;
-import co.elastic.apm.agent.impl.transaction.AbstractSpan;
-import co.elastic.apm.agent.impl.transaction.TraceContext;
-import co.elastic.apm.agent.impl.transaction.Transaction;
+import co.elastic.apm.plugin.spi.*;
import co.elastic.apm.agent.rabbitmq.header.SpringRabbitMQTextHeaderGetter;
import co.elastic.apm.agent.sdk.logging.Logger;
import co.elastic.apm.agent.sdk.logging.LoggerFactory;
@@ -75,7 +71,7 @@ public static Object[] beforeOnBatch(@Advice.This Object thiz,
@Advice.Argument(0) @Nullable final List messageBatch) {
List processedBatch = messageBatch;
- Transaction batchTransaction = null;
+ Transaction> batchTransaction = null;
if (tracer.isRunning() && messageBatch != null && !messageBatch.isEmpty()) {
AbstractSpan> active = tracer.getActive();
@@ -99,7 +95,7 @@ public static Object[] beforeOnBatch(@Advice.This Object thiz,
MessageProperties messageProperties = message.getMessageProperties();
if (messageProperties != null) {
active.addSpanLink(
- TraceContext.getFromTraceContextTextHeaders(),
+ TraceContextUtil.getFromTraceContextTextHeaders(),
SpringRabbitMQTextHeaderGetter.INSTANCE,
messageProperties
);
@@ -115,7 +111,7 @@ public static Object[] beforeOnBatch(@Advice.This Object thiz,
@Advice.OnMethodExit(suppress = Throwable.class, onThrowable = Throwable.class, inline = false)
public static void afterOnBatch(@Advice.Enter @Nullable Object[] enter,
@Advice.Thrown @Nullable Throwable throwable) {
- Transaction batchTransaction = enter != null ? (Transaction) enter[1] : null;
+ Transaction> batchTransaction = enter != null ? (Transaction>) enter[1] : null;
if (batchTransaction != null) {
try {
batchTransaction
diff --git a/apm-agent-plugins/apm-rabbitmq/apm-rabbitmq-spring/src/main/java/co/elastic/apm/agent/rabbitmq/SpringAmqpMessageListenerInstrumentation.java b/apm-agent-plugins/apm-rabbitmq/apm-rabbitmq-spring/src/main/java/co/elastic/apm/agent/rabbitmq/SpringAmqpMessageListenerInstrumentation.java
index db1264012b6..5feed8cf2f5 100644
--- a/apm-agent-plugins/apm-rabbitmq/apm-rabbitmq-spring/src/main/java/co/elastic/apm/agent/rabbitmq/SpringAmqpMessageListenerInstrumentation.java
+++ b/apm-agent-plugins/apm-rabbitmq/apm-rabbitmq-spring/src/main/java/co/elastic/apm/agent/rabbitmq/SpringAmqpMessageListenerInstrumentation.java
@@ -18,14 +18,13 @@
*/
package co.elastic.apm.agent.rabbitmq;
-import co.elastic.apm.agent.impl.transaction.Transaction;
+import co.elastic.apm.plugin.spi.Transaction;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessageListener;
-import org.springframework.amqp.core.MessageProperties;
import javax.annotation.Nullable;
@@ -76,8 +75,8 @@ public static Object beforeMessageHandle(@Advice.This MessageListener listener,
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class, inline = false)
public static void afterMessageHandle(@Advice.Enter @Nullable final Object transactionObject,
@Advice.Thrown @Nullable final Throwable throwable) {
- if (transactionObject instanceof Transaction) {
- Transaction transaction = (Transaction) transactionObject;
+ if (transactionObject instanceof Transaction>) {
+ Transaction> transaction = (Transaction>) transactionObject;
transaction.captureException(throwable)
.deactivate()
.end();
diff --git a/apm-agent-plugins/apm-rabbitmq/apm-rabbitmq-spring/src/main/java/co/elastic/apm/agent/rabbitmq/SpringAmqpTransactionHelper.java b/apm-agent-plugins/apm-rabbitmq/apm-rabbitmq-spring/src/main/java/co/elastic/apm/agent/rabbitmq/SpringAmqpTransactionHelper.java
index 6cb63aac0df..a13d8e2bb6d 100644
--- a/apm-agent-plugins/apm-rabbitmq/apm-rabbitmq-spring/src/main/java/co/elastic/apm/agent/rabbitmq/SpringAmqpTransactionHelper.java
+++ b/apm-agent-plugins/apm-rabbitmq/apm-rabbitmq-spring/src/main/java/co/elastic/apm/agent/rabbitmq/SpringAmqpTransactionHelper.java
@@ -18,8 +18,8 @@
*/
package co.elastic.apm.agent.rabbitmq;
-import co.elastic.apm.agent.impl.Tracer;
-import co.elastic.apm.agent.impl.transaction.Transaction;
+import co.elastic.apm.plugin.spi.Tracer;
+import co.elastic.apm.plugin.spi.Transaction;
import co.elastic.apm.agent.rabbitmq.header.SpringRabbitMQTextHeaderGetter;
import co.elastic.apm.agent.util.PrivilegedActionUtils;
import org.springframework.amqp.core.Message;
@@ -36,7 +36,7 @@ public SpringAmqpTransactionHelper(Tracer tracer) {
}
@Nullable
- public Transaction createTransaction(Message message, String transactionNamePrefix) {
+ public Transaction> createTransaction(Message message, String transactionNamePrefix) {
String exchange = null;
MessageProperties messageProperties = message.getMessageProperties();
if (messageProperties != null) {
@@ -46,7 +46,7 @@ public Transaction createTransaction(Message message, String transactionNamePref
return null;
}
- Transaction transaction = tracer.currentTransaction();
+ Transaction> transaction = tracer.currentTransaction();
if (transaction != null) {
return null;
}
diff --git a/apm-agent-plugins/apm-rabbitmq/apm-rabbitmq-spring/src/main/java/co/elastic/apm/agent/rabbitmq/SpringBaseInstrumentation.java b/apm-agent-plugins/apm-rabbitmq/apm-rabbitmq-spring/src/main/java/co/elastic/apm/agent/rabbitmq/SpringBaseInstrumentation.java
index 218b02b7fe1..c188843d8c9 100644
--- a/apm-agent-plugins/apm-rabbitmq/apm-rabbitmq-spring/src/main/java/co/elastic/apm/agent/rabbitmq/SpringBaseInstrumentation.java
+++ b/apm-agent-plugins/apm-rabbitmq/apm-rabbitmq-spring/src/main/java/co/elastic/apm/agent/rabbitmq/SpringBaseInstrumentation.java
@@ -18,8 +18,8 @@
*/
package co.elastic.apm.agent.rabbitmq;
-import co.elastic.apm.agent.impl.GlobalTracer;
-import co.elastic.apm.agent.impl.Tracer;
+import co.elastic.apm.plugin.spi.GlobalTracer;
+import co.elastic.apm.plugin.spi.Tracer;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;
diff --git a/apm-agent-plugins/apm-reactor-plugin/src/main/java/co/elastic/apm/agent/reactor/TracedSubscriber.java b/apm-agent-plugins/apm-reactor-plugin/src/main/java/co/elastic/apm/agent/reactor/TracedSubscriber.java
index c0d7a8771a9..18069a018b6 100644
--- a/apm-agent-plugins/apm-reactor-plugin/src/main/java/co/elastic/apm/agent/reactor/TracedSubscriber.java
+++ b/apm-agent-plugins/apm-reactor-plugin/src/main/java/co/elastic/apm/agent/reactor/TracedSubscriber.java
@@ -19,8 +19,8 @@
package co.elastic.apm.agent.reactor;
import co.elastic.apm.agent.collections.WeakConcurrentProviderImpl;
-import co.elastic.apm.agent.impl.Tracer;
-import co.elastic.apm.agent.impl.transaction.AbstractSpan;
+import co.elastic.apm.plugin.spi.Tracer;
+import co.elastic.apm.plugin.spi.AbstractSpan;
import co.elastic.apm.agent.sdk.logging.Logger;
import co.elastic.apm.agent.sdk.logging.LoggerFactory;
import co.elastic.apm.agent.sdk.state.GlobalVariables;
diff --git a/apm-agent-plugins/apm-redis-plugin/apm-jedis-4-plugin/src/main/java/co/elastic/apm/agent/jedis/Jedis4SendCommandAdvice.java b/apm-agent-plugins/apm-redis-plugin/apm-jedis-4-plugin/src/main/java/co/elastic/apm/agent/jedis/Jedis4SendCommandAdvice.java
index 5d5ec009da1..592bbf4ac51 100644
--- a/apm-agent-plugins/apm-redis-plugin/apm-jedis-4-plugin/src/main/java/co/elastic/apm/agent/jedis/Jedis4SendCommandAdvice.java
+++ b/apm-agent-plugins/apm-redis-plugin/apm-jedis-4-plugin/src/main/java/co/elastic/apm/agent/jedis/Jedis4SendCommandAdvice.java
@@ -18,7 +18,7 @@
*/
package co.elastic.apm.agent.jedis;
-import co.elastic.apm.agent.impl.transaction.Span;
+import co.elastic.apm.plugin.spi.Span;
import co.elastic.apm.agent.redis.RedisSpanUtils;
import net.bytebuddy.asm.Advice;
import redis.clients.jedis.CommandArguments;
@@ -40,7 +40,7 @@ public static Object sendCommandEntry(@Advice.Argument(0) CommandArguments comma
public static void sendCommandExit(@Advice.FieldValue("socketFactory") JedisSocketFactory socketFactory,
@Nullable @Advice.Enter Object spanObj,
@Nullable @Advice.Thrown Throwable thrown) {
- Span span = (Span) spanObj;
+ Span> span = (Span>) spanObj;
if (span != null) {
if (socketFactory instanceof DefaultJedisSocketFactory) {
HostAndPort hostAndPort = ((DefaultJedisSocketFactory) socketFactory).getHostAndPort();
diff --git a/apm-agent-plugins/apm-redis-plugin/apm-jedis-plugin/src/main/java/co/elastic/apm/agent/jedis/SendCommandAdvice.java b/apm-agent-plugins/apm-redis-plugin/apm-jedis-plugin/src/main/java/co/elastic/apm/agent/jedis/SendCommandAdvice.java
index 3fd171d4d59..103e6d4c2da 100644
--- a/apm-agent-plugins/apm-redis-plugin/apm-jedis-plugin/src/main/java/co/elastic/apm/agent/jedis/SendCommandAdvice.java
+++ b/apm-agent-plugins/apm-redis-plugin/apm-jedis-plugin/src/main/java/co/elastic/apm/agent/jedis/SendCommandAdvice.java
@@ -18,7 +18,7 @@
*/
package co.elastic.apm.agent.jedis;
-import co.elastic.apm.agent.impl.transaction.Span;
+import co.elastic.apm.plugin.spi.Span;
import co.elastic.apm.agent.redis.RedisSpanUtils;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.implementation.bytecode.assign.Assigner;
@@ -39,7 +39,7 @@ public static Object sendCommandEntry(@Advice.Argument(0) Object command) {
public static void sendCommandExit(@Advice.This(typing = Assigner.Typing.DYNAMIC) Connection thiz,
@Nullable @Advice.Enter Object spanObj,
@Nullable @Advice.Thrown Throwable thrown) {
- Span span = (Span) spanObj;
+ Span> span = (Span>) spanObj;
if (span != null) {
span.getContext().getDestination()
.withAddress(thiz.getHost())
diff --git a/apm-agent-plugins/apm-redis-plugin/apm-lettuce-plugin/src/main/java/co/elastic/apm/agent/lettuce/Lettuce34Instrumentation.java b/apm-agent-plugins/apm-redis-plugin/apm-lettuce-plugin/src/main/java/co/elastic/apm/agent/lettuce/Lettuce34Instrumentation.java
index 706da4bc46c..3c7cfa69271 100644
--- a/apm-agent-plugins/apm-redis-plugin/apm-lettuce-plugin/src/main/java/co/elastic/apm/agent/lettuce/Lettuce34Instrumentation.java
+++ b/apm-agent-plugins/apm-redis-plugin/apm-lettuce-plugin/src/main/java/co/elastic/apm/agent/lettuce/Lettuce34Instrumentation.java
@@ -20,7 +20,7 @@
import co.elastic.apm.agent.bci.TracerAwareInstrumentation;
import co.elastic.apm.agent.collections.WeakConcurrentProviderImpl;
-import co.elastic.apm.agent.impl.transaction.Span;
+import co.elastic.apm.plugin.spi.Span;
import co.elastic.apm.agent.sdk.weakconcurrent.WeakMap;
import com.lambdaworks.redis.protocol.RedisCommand;
import net.bytebuddy.matcher.ElementMatcher;
diff --git a/apm-agent-plugins/apm-redis-plugin/apm-lettuce-plugin/src/main/java/co/elastic/apm/agent/lettuce/Lettuce34StartSpanInstrumentation.java b/apm-agent-plugins/apm-redis-plugin/apm-lettuce-plugin/src/main/java/co/elastic/apm/agent/lettuce/Lettuce34StartSpanInstrumentation.java
index 6e54c4de85f..35376885ff0 100644
--- a/apm-agent-plugins/apm-redis-plugin/apm-lettuce-plugin/src/main/java/co/elastic/apm/agent/lettuce/Lettuce34StartSpanInstrumentation.java
+++ b/apm-agent-plugins/apm-redis-plugin/apm-lettuce-plugin/src/main/java/co/elastic/apm/agent/lettuce/Lettuce34StartSpanInstrumentation.java
@@ -18,7 +18,7 @@
*/
package co.elastic.apm.agent.lettuce;
-import co.elastic.apm.agent.impl.transaction.Span;
+import co.elastic.apm.plugin.spi.Span;
import co.elastic.apm.agent.redis.RedisSpanUtils;
import com.lambdaworks.redis.protocol.RedisCommand;
import net.bytebuddy.asm.Advice;
@@ -57,7 +57,7 @@ public static class AdviceClass {
@Advice.OnMethodEnter(suppress = Throwable.class, inline = false)
public static Object beforeDispatch(@Nullable @Advice.Argument(0) RedisCommand, ?, ?> command) {
if (command != null) {
- Span span = RedisSpanUtils.createRedisSpan(command.getType().toString());
+ Span> span = RedisSpanUtils.createRedisSpan(command.getType().toString());
if (span != null) {
commandToSpan.put(command, span);
return span;
@@ -68,7 +68,7 @@ public static Object beforeDispatch(@Nullable @Advice.Argument(0) RedisCommand
@Advice.OnMethodExit(suppress = Throwable.class, inline = false)
public static void afterDispatch(@Nullable @Advice.Enter Object spanObj) {
- Span span = (Span) spanObj;
+ Span> span = (Span>) spanObj;
if (span != null) {
span.deactivate();
}
diff --git a/apm-agent-plugins/apm-redis-plugin/apm-lettuce-plugin/src/main/java/co/elastic/apm/agent/lettuce/Lettuce34StopSpanInstrumentation.java b/apm-agent-plugins/apm-redis-plugin/apm-lettuce-plugin/src/main/java/co/elastic/apm/agent/lettuce/Lettuce34StopSpanInstrumentation.java
index ddd989a3549..df4d3f6213f 100644
--- a/apm-agent-plugins/apm-redis-plugin/apm-lettuce-plugin/src/main/java/co/elastic/apm/agent/lettuce/Lettuce34StopSpanInstrumentation.java
+++ b/apm-agent-plugins/apm-redis-plugin/apm-lettuce-plugin/src/main/java/co/elastic/apm/agent/lettuce/Lettuce34StopSpanInstrumentation.java
@@ -18,7 +18,7 @@
*/
package co.elastic.apm.agent.lettuce;
-import co.elastic.apm.agent.impl.transaction.Span;
+import co.elastic.apm.plugin.spi.Span;
import com.lambdaworks.redis.protocol.RedisCommand;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.NamedElement;
@@ -72,7 +72,7 @@ public static class OnComplete extends Lettuce34StopSpanInstrumentation {
public static class AdviceClass {
@Advice.OnMethodEnter(suppress = Throwable.class, inline = false)
public static void beforeComplete(@Advice.This RedisCommand, ?, ?> command) {
- Span span = commandToSpan.remove(command);
+ Span> span = commandToSpan.remove(command);
if (span != null) {
logger.debug("Command#complete");
span.end();
@@ -91,7 +91,7 @@ public static class OnCompleteExceptionally extends Lettuce34StopSpanInstrumenta
public static class AdviceClass {
@Advice.OnMethodEnter(suppress = Throwable.class, inline = false)
public static void beforeComplete(@Advice.This RedisCommand, ?, ?> command, @Advice.Argument(0) Throwable throwable) {
- Span span = commandToSpan.remove(command);
+ Span> span = commandToSpan.remove(command);
if (span != null) {
logger.debug("Command#completeExceptionally");
span.captureException(throwable).end();
@@ -110,7 +110,7 @@ public static class OnCancel extends Lettuce34StopSpanInstrumentation {
public static class AdviceClass {
@Advice.OnMethodEnter(suppress = Throwable.class, inline = false)
public static void beforeComplete(@Advice.This RedisCommand, ?, ?> command) {
- Span span = commandToSpan.remove(command);
+ Span> span = commandToSpan.remove(command);
if (span != null) {
logger.debug("Command#cancel");
span.end();
diff --git a/apm-agent-plugins/apm-redis-plugin/apm-lettuce-plugin/src/main/java/co/elastic/apm/agent/lettuce/Lettuce5StartSpanInstrumentation.java b/apm-agent-plugins/apm-redis-plugin/apm-lettuce-plugin/src/main/java/co/elastic/apm/agent/lettuce/Lettuce5StartSpanInstrumentation.java
index ad23a44fdce..521b021b442 100644
--- a/apm-agent-plugins/apm-redis-plugin/apm-lettuce-plugin/src/main/java/co/elastic/apm/agent/lettuce/Lettuce5StartSpanInstrumentation.java
+++ b/apm-agent-plugins/apm-redis-plugin/apm-lettuce-plugin/src/main/java/co/elastic/apm/agent/lettuce/Lettuce5StartSpanInstrumentation.java
@@ -20,7 +20,7 @@
import co.elastic.apm.agent.bci.TracerAwareInstrumentation;
import co.elastic.apm.agent.collections.WeakConcurrentProviderImpl;
-import co.elastic.apm.agent.impl.transaction.Span;
+import co.elastic.apm.plugin.spi.Span;
import co.elastic.apm.agent.redis.RedisSpanUtils;
import co.elastic.apm.agent.sdk.weakconcurrent.WeakMap;
import io.lettuce.core.protocol.RedisCommand;
@@ -46,7 +46,7 @@
*/
public class Lettuce5StartSpanInstrumentation extends TracerAwareInstrumentation {
- static final WeakMap, Span> commandToSpan = WeakConcurrentProviderImpl.createWeakSpanMap();
+ static final WeakMap, Span>> commandToSpan = WeakConcurrentProviderImpl.createWeakSpanMap();
@Override
public ElementMatcher super TypeDescription> getTypeMatcher() {
@@ -71,7 +71,7 @@ public static class AdviceClass {
@Advice.OnMethodEnter(suppress = Throwable.class, inline = false)
public static Object beforeDispatch(@Nullable @Advice.Argument(0) RedisCommand, ?, ?> command) {
if (command != null) {
- Span span = RedisSpanUtils.createRedisSpan(command.getType().name());
+ Span> span = RedisSpanUtils.createRedisSpan(command.getType().name());
if (span != null) {
commandToSpan.put(command, span);
return span;
@@ -82,7 +82,7 @@ public static Object beforeDispatch(@Nullable @Advice.Argument(0) RedisCommand
@Advice.OnMethodExit(suppress = Throwable.class, inline = false)
public static void afterDispatch(@Nullable @Advice.Enter Object spanObj) {
- Span span = (Span) spanObj;
+ Span> span = (Span>) spanObj;
if (span != null) {
span.deactivate();
}
diff --git a/apm-agent-plugins/apm-redis-plugin/apm-lettuce-plugin/src/main/java/co/elastic/apm/agent/lettuce/Lettuce5StopSpanInstrumentation.java b/apm-agent-plugins/apm-redis-plugin/apm-lettuce-plugin/src/main/java/co/elastic/apm/agent/lettuce/Lettuce5StopSpanInstrumentation.java
index e2a49eb10c1..805a257b7b4 100644
--- a/apm-agent-plugins/apm-redis-plugin/apm-lettuce-plugin/src/main/java/co/elastic/apm/agent/lettuce/Lettuce5StopSpanInstrumentation.java
+++ b/apm-agent-plugins/apm-redis-plugin/apm-lettuce-plugin/src/main/java/co/elastic/apm/agent/lettuce/Lettuce5StopSpanInstrumentation.java
@@ -19,7 +19,7 @@
package co.elastic.apm.agent.lettuce;
import co.elastic.apm.agent.bci.TracerAwareInstrumentation;
-import co.elastic.apm.agent.impl.transaction.Span;
+import co.elastic.apm.plugin.spi.Span;
import io.lettuce.core.protocol.RedisCommand;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.NamedElement;
@@ -72,7 +72,7 @@ public static class AdviceClass {
@Advice.OnMethodEnter(suppress = Throwable.class, inline = false)
public static void beforeComplete(@Advice.This RedisCommand, ?, ?> command) {
if (!command.isDone() && !command.isCancelled()) {
- Span span = Lettuce5StartSpanInstrumentation.commandToSpan.remove(command);
+ Span> span = Lettuce5StartSpanInstrumentation.commandToSpan.remove(command);
if (span != null) {
logger.debug("Command#complete");
span.end();
@@ -93,7 +93,7 @@ public static class AdviceClass {
@Advice.OnMethodEnter(suppress = Throwable.class, inline = false)
public static void beforeComplete(@Advice.This RedisCommand, ?, ?> command, @Advice.Argument(0) Throwable throwable) {
if (!command.isDone() && !command.isCancelled()) {
- Span span = Lettuce5StartSpanInstrumentation.commandToSpan.remove(command);
+ Span> span = Lettuce5StartSpanInstrumentation.commandToSpan.remove(command);
if (span != null) {
logger.debug("Command#completeExceptionally");
span.captureException(throwable).end();
@@ -114,7 +114,7 @@ public static class AdviceClass {
@Advice.OnMethodEnter(suppress = Throwable.class, inline = false)
public static void beforeComplete(@Advice.This RedisCommand, ?, ?> command) {
if (!command.isDone() && !command.isCancelled()) {
- Span span = commandToSpan.remove(command);
+ Span> span = commandToSpan.remove(command);
if (span != null) {
logger.debug("Command#cancel");
span.end();
diff --git a/apm-agent-plugins/apm-redis-plugin/apm-redis-common/src/main/java/co/elastic/apm/agent/redis/RedisSpanUtils.java b/apm-agent-plugins/apm-redis-plugin/apm-redis-common/src/main/java/co/elastic/apm/agent/redis/RedisSpanUtils.java
index a6ad14f3608..8316fc58e37 100644
--- a/apm-agent-plugins/apm-redis-plugin/apm-redis-common/src/main/java/co/elastic/apm/agent/redis/RedisSpanUtils.java
+++ b/apm-agent-plugins/apm-redis-plugin/apm-redis-common/src/main/java/co/elastic/apm/agent/redis/RedisSpanUtils.java
@@ -18,21 +18,24 @@
*/
package co.elastic.apm.agent.redis;
-import co.elastic.apm.agent.impl.GlobalTracer;
-import co.elastic.apm.agent.impl.transaction.AbstractSpan;
-import co.elastic.apm.agent.impl.transaction.Span;
+import co.elastic.apm.plugin.spi.GlobalTracer;
+import co.elastic.apm.plugin.spi.AbstractSpan;
+import co.elastic.apm.plugin.spi.Span;
+import co.elastic.apm.plugin.spi.Tracer;
import javax.annotation.Nullable;
public class RedisSpanUtils {
+
+ private static final Tracer tracer = GlobalTracer.get();
@Nullable
- public static Span createRedisSpan(String command) {
- AbstractSpan> activeSpan = GlobalTracer.get().getActive();
+ public static Span> createRedisSpan(String command) {
+ AbstractSpan> activeSpan = tracer.getActive();
if (activeSpan == null) {
return null;
}
- Span span = activeSpan.createExitSpan();
+ Span> span = activeSpan.createExitSpan();
if (span == null) {
return null;
}
diff --git a/apm-agent-plugins/apm-redis-plugin/apm-redisson-plugin/src/main/java/co/elastic/apm/agent/redisson/RedisConnectionInstrumentation.java b/apm-agent-plugins/apm-redis-plugin/apm-redisson-plugin/src/main/java/co/elastic/apm/agent/redisson/RedisConnectionInstrumentation.java
index fe0575e7ff0..76c406ea0a4 100644
--- a/apm-agent-plugins/apm-redis-plugin/apm-redisson-plugin/src/main/java/co/elastic/apm/agent/redisson/RedisConnectionInstrumentation.java
+++ b/apm-agent-plugins/apm-redis-plugin/apm-redisson-plugin/src/main/java/co/elastic/apm/agent/redisson/RedisConnectionInstrumentation.java
@@ -19,7 +19,7 @@
package co.elastic.apm.agent.redisson;
import co.elastic.apm.agent.bci.TracerAwareInstrumentation;
-import co.elastic.apm.agent.impl.transaction.Span;
+import co.elastic.apm.plugin.spi.Span;
import co.elastic.apm.agent.redis.RedisSpanUtils;
import io.netty.channel.Channel;
import net.bytebuddy.asm.Advice;
@@ -47,7 +47,7 @@ public static class AdviceClass {
@Advice.OnMethodEnter(inline = false)
public static Object beforeSend(@Advice.This RedisConnection connection,
@Advice.Argument(0) Object args) {
- Span span = RedisSpanUtils.createRedisSpan("");
+ Span> span = RedisSpanUtils.createRedisSpan("");
if (span != null) {
// get command
if (args instanceof CommandsData) {
@@ -72,7 +72,7 @@ public static Object beforeSend(@Advice.This RedisConnection connection,
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class, inline = false)
public static void afterSend(@Nullable @Advice.Enter Object spanObj,
@Nullable @Advice.Thrown Throwable thrown) {
- Span span = (Span) spanObj;
+ Span> span = (Span>) spanObj;
if (span != null) {
span.captureException(thrown)
.deactivate()
diff --git a/apm-agent-plugins/apm-scala-concurrent-plugin/src/main/java/co/elastic/apm/agent/scalaconcurrent/FutureInstrumentation.java b/apm-agent-plugins/apm-scala-concurrent-plugin/src/main/java/co/elastic/apm/agent/scalaconcurrent/FutureInstrumentation.java
index 2e4660a0408..e445bfc5542 100644
--- a/apm-agent-plugins/apm-scala-concurrent-plugin/src/main/java/co/elastic/apm/agent/scalaconcurrent/FutureInstrumentation.java
+++ b/apm-agent-plugins/apm-scala-concurrent-plugin/src/main/java/co/elastic/apm/agent/scalaconcurrent/FutureInstrumentation.java
@@ -20,7 +20,7 @@
import co.elastic.apm.agent.bci.TracerAwareInstrumentation;
import co.elastic.apm.agent.collections.WeakConcurrentProviderImpl;
-import co.elastic.apm.agent.impl.transaction.AbstractSpan;
+import co.elastic.apm.plugin.spi.AbstractSpan;
import co.elastic.apm.agent.sdk.weakconcurrent.WeakMap;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.method.MethodDescription;
diff --git a/apm-agent-plugins/apm-scheduled-annotation-plugin/src/main/java/co/elastic/apm/agent/scheduled/ScheduledTransactionNameInstrumentation.java b/apm-agent-plugins/apm-scheduled-annotation-plugin/src/main/java/co/elastic/apm/agent/scheduled/ScheduledTransactionNameInstrumentation.java
index 9e56f0a43d7..091661a46bb 100644
--- a/apm-agent-plugins/apm-scheduled-annotation-plugin/src/main/java/co/elastic/apm/agent/scheduled/ScheduledTransactionNameInstrumentation.java
+++ b/apm-agent-plugins/apm-scheduled-annotation-plugin/src/main/java/co/elastic/apm/agent/scheduled/ScheduledTransactionNameInstrumentation.java
@@ -20,11 +20,8 @@
import co.elastic.apm.agent.bci.TracerAwareInstrumentation;
import co.elastic.apm.agent.bci.bytebuddy.SimpleMethodSignatureOffsetMappingFactory.SimpleMethodSignature;
-import co.elastic.apm.agent.impl.Tracer;
+import co.elastic.apm.plugin.spi.*;
import co.elastic.apm.agent.impl.stacktrace.StacktraceConfiguration;
-import co.elastic.apm.agent.impl.transaction.AbstractSpan;
-import co.elastic.apm.agent.impl.transaction.Outcome;
-import co.elastic.apm.agent.impl.transaction.Transaction;
import co.elastic.apm.agent.util.PrivilegedActionUtils;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.NamedElement;
@@ -63,7 +60,7 @@ public static Object setTransactionName(@SimpleMethodSignature String signature,
@Advice.Origin Class> clazz) {
AbstractSpan> active = tracer.getActive();
if (active == null) {
- Transaction transaction = tracer.startRootTransaction(PrivilegedActionUtils.getClassLoader(clazz));
+ Transaction> transaction = tracer.startRootTransaction(PrivilegedActionUtils.getClassLoader(clazz));
if (transaction != null) {
transaction.withName(signature)
.withType("scheduled")
@@ -79,10 +76,10 @@ public static Object setTransactionName(@SimpleMethodSignature String signature,
@Advice.OnMethodExit(suppress = Throwable.class, onThrowable = Throwable.class, inline = false)
public static void onMethodExit(@Advice.Enter @Nullable Object transactionObj,
@Advice.Thrown @Nullable Throwable t) {
- if (transactionObj instanceof Transaction) {
- Transaction transaction = (Transaction) transactionObj;
+ if (transactionObj instanceof Transaction>) {
+ Transaction> transaction = (Transaction>) transactionObj;
transaction.captureException(t)
- .withOutcome(t != null ? Outcome.FAILURE : Outcome.SUCCESS)
+ .withOutcome(t != null ? DefaultOutcome.FAILURE : DefaultOutcome.SUCCESS)
.deactivate()
.end();
}
diff --git a/apm-agent-plugins/apm-scheduled-annotation-plugin/src/main/java/co/elastic/apm/agent/scheduled/TimerTaskInstrumentation.java b/apm-agent-plugins/apm-scheduled-annotation-plugin/src/main/java/co/elastic/apm/agent/scheduled/TimerTaskInstrumentation.java
index 440a10f25ea..028b5574430 100644
--- a/apm-agent-plugins/apm-scheduled-annotation-plugin/src/main/java/co/elastic/apm/agent/scheduled/TimerTaskInstrumentation.java
+++ b/apm-agent-plugins/apm-scheduled-annotation-plugin/src/main/java/co/elastic/apm/agent/scheduled/TimerTaskInstrumentation.java
@@ -20,10 +20,10 @@
import co.elastic.apm.agent.bci.TracerAwareInstrumentation;
import co.elastic.apm.agent.bci.bytebuddy.SimpleMethodSignatureOffsetMappingFactory;
-import co.elastic.apm.agent.impl.Tracer;
+import co.elastic.apm.plugin.spi.Tracer;
import co.elastic.apm.agent.impl.stacktrace.StacktraceConfiguration;
-import co.elastic.apm.agent.impl.transaction.AbstractSpan;
-import co.elastic.apm.agent.impl.transaction.Transaction;
+import co.elastic.apm.plugin.spi.AbstractSpan;
+import co.elastic.apm.plugin.spi.Transaction;
import co.elastic.apm.agent.util.PrivilegedActionUtils;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.NamedElement;
@@ -62,7 +62,7 @@ public static Object setTransactionName(@SimpleMethodSignatureOffsetMappingFacto
@Advice.Origin Class> clazz) {
AbstractSpan> active = tracer.getActive();
if (active == null) {
- Transaction transaction = tracer.startRootTransaction(PrivilegedActionUtils.getClassLoader(clazz));
+ Transaction> transaction = tracer.startRootTransaction(PrivilegedActionUtils.getClassLoader(clazz));
if (transaction != null) {
transaction.withName(signature)
.withType("scheduled")
@@ -79,8 +79,8 @@ public static Object setTransactionName(@SimpleMethodSignatureOffsetMappingFacto
@Advice.OnMethodExit(suppress = Throwable.class, onThrowable = Throwable.class, inline = false)
public static void onMethodExit(@Advice.Enter @Nullable Object transactionObj,
@Advice.Thrown Throwable t) {
- if (transactionObj instanceof Transaction) {
- Transaction transaction = (Transaction) transactionObj;
+ if (transactionObj instanceof Transaction>) {
+ Transaction> transaction = (Transaction>) transactionObj;
transaction.captureException(t)
.deactivate()
.end();
diff --git a/apm-agent-plugins/apm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/JakartaAsyncInstrumentation.java b/apm-agent-plugins/apm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/JakartaAsyncInstrumentation.java
index 4fead910dcd..5f36d290091 100644
--- a/apm-agent-plugins/apm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/JakartaAsyncInstrumentation.java
+++ b/apm-agent-plugins/apm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/JakartaAsyncInstrumentation.java
@@ -18,7 +18,7 @@
*/
package co.elastic.apm.agent.servlet;
-import co.elastic.apm.agent.impl.GlobalTracer;
+import co.elastic.apm.plugin.spi.GlobalTracer;
import co.elastic.apm.agent.servlet.helper.AsyncContextAdviceHelper;
import co.elastic.apm.agent.servlet.helper.JakartaAsyncContextAdviceHelper;
import jakarta.servlet.AsyncContext;
diff --git a/apm-agent-plugins/apm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/JakartaRequestStreamRecordingInstrumentation.java b/apm-agent-plugins/apm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/JakartaRequestStreamRecordingInstrumentation.java
index 4eab1884f8f..a67cb3dea1f 100644
--- a/apm-agent-plugins/apm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/JakartaRequestStreamRecordingInstrumentation.java
+++ b/apm-agent-plugins/apm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/JakartaRequestStreamRecordingInstrumentation.java
@@ -18,7 +18,7 @@
*/
package co.elastic.apm.agent.servlet;
-import co.elastic.apm.agent.impl.transaction.Transaction;
+import co.elastic.apm.plugin.spi.Transaction;
import co.elastic.apm.agent.sdk.state.CallDepth;
import co.elastic.apm.agent.servlet.helper.JakartaRecordingServletInputStreamWrapper;
import jakarta.servlet.ServletInputStream;
@@ -54,7 +54,7 @@ public static ServletInputStream afterGetInputStream(@Advice.Return @Nullable Se
if (callDepth.isNestedCallAndDecrement() || inputStream == null) {
return inputStream;
}
- final Transaction transaction = tracer.currentTransaction();
+ final Transaction> transaction = tracer.currentTransaction();
// only wrap if the body buffer has been initialized via ServletTransactionHelper.startCaptureBody
if (transaction != null && transaction.getContext().getRequest().getBodyBuffer() != null) {
return new JakartaRecordingServletInputStreamWrapper(transaction.getContext().getRequest(), inputStream);
diff --git a/apm-agent-plugins/apm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/JavaxAsyncInstrumentation.java b/apm-agent-plugins/apm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/JavaxAsyncInstrumentation.java
index 3473ae22dc7..16554547707 100644
--- a/apm-agent-plugins/apm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/JavaxAsyncInstrumentation.java
+++ b/apm-agent-plugins/apm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/JavaxAsyncInstrumentation.java
@@ -18,7 +18,7 @@
*/
package co.elastic.apm.agent.servlet;
-import co.elastic.apm.agent.impl.GlobalTracer;
+import co.elastic.apm.plugin.spi.GlobalTracer;
import co.elastic.apm.agent.servlet.helper.AsyncContextAdviceHelper;
import co.elastic.apm.agent.servlet.helper.JavaxAsyncContextAdviceHelper;
import javax.servlet.ServletRequest;
diff --git a/apm-agent-plugins/apm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/JavaxRequestStreamRecordingInstrumentation.java b/apm-agent-plugins/apm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/JavaxRequestStreamRecordingInstrumentation.java
index 2b85480420c..50ab2c1e697 100644
--- a/apm-agent-plugins/apm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/JavaxRequestStreamRecordingInstrumentation.java
+++ b/apm-agent-plugins/apm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/JavaxRequestStreamRecordingInstrumentation.java
@@ -18,7 +18,7 @@
*/
package co.elastic.apm.agent.servlet;
-import co.elastic.apm.agent.impl.transaction.Transaction;
+import co.elastic.apm.plugin.spi.Transaction;
import co.elastic.apm.agent.sdk.state.CallDepth;
import co.elastic.apm.agent.servlet.helper.JavaxRecordingServletInputStreamWrapper;
import net.bytebuddy.asm.Advice;
@@ -54,7 +54,7 @@ public static ServletInputStream afterGetInputStream(@Advice.Return @Nullable Se
if (callDepth.isNestedCallAndDecrement() || inputStream == null) {
return inputStream;
}
- final Transaction transaction = tracer.currentTransaction();
+ final Transaction> transaction = tracer.currentTransaction();
// only wrap if the body buffer has been initialized via ServletTransactionHelper.startCaptureBody
if (transaction != null && transaction.getContext().getRequest().getBodyBuffer() != null) {
return new JavaxRecordingServletInputStreamWrapper(transaction.getContext().getRequest(), inputStream);
diff --git a/apm-agent-plugins/apm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/ServletApiAdvice.java b/apm-agent-plugins/apm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/ServletApiAdvice.java
index 7233bbaec9c..38b8c6d384d 100644
--- a/apm-agent-plugins/apm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/ServletApiAdvice.java
+++ b/apm-agent-plugins/apm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/ServletApiAdvice.java
@@ -19,15 +19,7 @@
package co.elastic.apm.agent.servlet;
import co.elastic.apm.agent.configuration.CoreConfiguration;
-import co.elastic.apm.agent.impl.GlobalTracer;
-import co.elastic.apm.agent.impl.Scope;
-import co.elastic.apm.agent.impl.Tracer;
-import co.elastic.apm.agent.impl.context.Request;
-import co.elastic.apm.agent.impl.context.Response;
-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.impl.transaction.Transaction;
+import co.elastic.apm.plugin.spi.*;
import co.elastic.apm.agent.sdk.state.GlobalVariables;
import co.elastic.apm.agent.sdk.weakconcurrent.DetachedThreadLocal;
import co.elastic.apm.agent.sdk.weakconcurrent.WeakConcurrent;
@@ -40,15 +32,17 @@
import java.util.List;
import java.util.Map;
-import static co.elastic.apm.agent.impl.transaction.AbstractSpan.PRIO_LOW_LEVEL_FRAMEWORK;
+import static co.elastic.apm.plugin.spi.AbstractSpan.PRIO_LOW_LEVEL_FRAMEWORK;
import static co.elastic.apm.agent.servlet.ServletTransactionHelper.TRANSACTION_ATTRIBUTE;
public abstract class ServletApiAdvice {
private static final String FRAMEWORK_NAME = "Servlet API";
+
+ private static final Tracer tracer = GlobalTracer.get();
static final String SPAN_TYPE = "servlet";
static final String SPAN_SUBTYPE = "request-dispatcher";
- private static final ServletTransactionHelper servletTransactionHelper = new ServletTransactionHelper(GlobalTracer.requireTracerImpl());
+ private static final ServletTransactionHelper servletTransactionHelper = new ServletTransactionHelper(GlobalTracer.get());
private static final DetachedThreadLocal excluded = GlobalVariables.get(ServletApiAdvice.class, "excluded", WeakConcurrent.buildThreadLocal());
private static final DetachedThreadLocal servletPathTL = GlobalVariables.get(ServletApiAdvice.class, "servletPath", WeakConcurrent.buildThreadLocal());
@@ -61,15 +55,13 @@ public static adapter,
Object servletRequest) {
- Tracer tracer = GlobalTracer.get();
-
final HttpServletRequest httpServletRequest = adapter.asHttpServletRequest(servletRequest);
if (httpServletRequest == null) {
return null;
}
AbstractSpan> ret = null;
// re-activate transactions for async requests
- final Transaction transactionAttr = (Transaction) adapter.getAttribute(httpServletRequest, TRANSACTION_ATTRIBUTE);
+ final Transaction> transactionAttr = (Transaction>) adapter.getAttribute(httpServletRequest, TRANSACTION_ATTRIBUTE);
if (tracer.currentTransaction() == null && transactionAttr != null) {
return transactionAttr.activateInScope();
}
@@ -87,7 +79,7 @@ public static transaction = servletTransactionHelper.createAndActivateTransaction(adapter, adapter, httpServletRequest);
if (transaction == null) {
// if the httpServletRequest is excluded, avoid matching all exclude patterns again on each filter invocation
@@ -164,15 +156,15 @@ public static transaction = null;
Scope scope = null;
- Span span = null;
- if (transactionOrScopeOrSpan instanceof Transaction) {
- transaction = (Transaction) transactionOrScopeOrSpan;
+ Span> span = null;
+ if (transactionOrScopeOrSpan instanceof Transaction>) {
+ transaction = (Transaction>) transactionOrScopeOrSpan;
} else if (transactionOrScopeOrSpan instanceof Scope) {
scope = (Scope) transactionOrScopeOrSpan;
- } else if (transactionOrScopeOrSpan instanceof Span) {
- span = (Span) transactionOrScopeOrSpan;
+ } else if (transactionOrScopeOrSpan instanceof Span>) {
+ span = (Span>) transactionOrScopeOrSpan;
}
excluded.remove();
@@ -182,7 +174,7 @@ public static currentTransaction = tracer.currentTransaction();
if (currentTransaction != null) {
TransactionNameUtils.setTransactionNameByServletClass(adapter.getMethod(httpServletRequest), thiz.getClass(), currentTransaction.getAndOverrideName(PRIO_LOW_LEVEL_FRAMEWORK));
@@ -261,7 +253,7 @@ public static Transaction createAndActivateTransaction(
+ public Transaction> createAndActivateTransaction(
ServletRequestAdapter requestAdapter,
ServletContextAdapter contextAdapter,
HttpServletRequest request) {
@@ -83,14 +78,14 @@ public Transaction createAndActivateTransac
return null;
}
ClassLoader cl = contextAdapter.getClassLoader(requestAdapter.getServletContext(request));
- Transaction transaction = tracer.startChildTransaction(request, requestAdapter.getRequestHeaderGetter(), cl);
+ Transaction> transaction = tracer.startChildTransaction(request, requestAdapter.getRequestHeaderGetter(), cl);
if (transaction != null) {
transaction.activate();
}
return transaction;
}
- public void fillRequestContext(Transaction transaction, String protocol, String method, boolean secure,
+ public void fillRequestContext(Transaction> transaction, String protocol, String method, boolean secure,
String scheme, String serverName, int serverPort, String requestURI, String queryString,
String remoteAddr, @Nullable String contentTypeHeader) {
@@ -114,7 +109,7 @@ public void fillRequestContext(Transaction transaction, String protocol, String
}
- private void startCaptureBody(Transaction transaction, String method, @Nullable String contentTypeHeader) {
+ private void startCaptureBody(Transaction> transaction, String method, @Nullable String contentTypeHeader) {
Request request = transaction.getContext().getRequest();
if (hasBody(contentTypeHeader, method)) {
if (coreConfiguration.getCaptureBody() != OFF
@@ -223,7 +218,7 @@ public String normalizeServletPath(String requestURI, @Nullable String contextPa
return path;
}
- public void onAfter(Transaction transaction, @Nullable Throwable exception, boolean committed, int status,
+ public void onAfter(Transaction> transaction, @Nullable Throwable exception, boolean committed, int status,
boolean overrideStatusCodeOnThrowable, String method, @Nullable Map parameterMap,
@Nullable String servletPath, @Nullable String pathInfo, @Nullable String contentTypeHeader, boolean deactivate) {
try {
@@ -244,7 +239,7 @@ public void onAfter(Transaction transaction, @Nullable Throwable exception, bool
transaction.end();
}
- private void doOnAfter(Transaction transaction, @Nullable Throwable exception, boolean committed, int status,
+ private void doOnAfter(Transaction> transaction, @Nullable Throwable exception, boolean committed, int status,
boolean overrideStatusCodeOnThrowable, String method, @Nullable Map parameterMap,
String servletPath, @Nullable String pathInfo, @Nullable String contentTypeHeader) {
fillRequestParameters(transaction, method, parameterMap, contentTypeHeader);
@@ -259,7 +254,7 @@ private void doOnAfter(Transaction transaction, @Nullable Throwable exception, b
applyDefaultTransactionName(method, servletPath, pathInfo, transaction);
}
- void applyDefaultTransactionName(String method, String servletPath, @Nullable String pathInfo, Transaction transaction) {
+ void applyDefaultTransactionName(String method, String servletPath, @Nullable String pathInfo, Transaction> transaction) {
// JSPs don't contain path params and the name is more telling than the generated servlet class
if (webConfiguration.isUsePathAsName() || ENDS_WITH_JSP.matches(servletPath, pathInfo)) {
// should override ServletName#doGet
@@ -276,7 +271,7 @@ void applyDefaultTransactionName(String method, String servletPath, @Nullable St
* for example when the amount of query parameters is longer than the application server allows.
* In that case, we rather not want that the agent looks like the cause for this.
*/
- private void fillRequestParameters(Transaction transaction, String method, @Nullable Map parameterMap, @Nullable String contentTypeHeader) {
+ private void fillRequestParameters(Transaction> transaction, String method, @Nullable Map parameterMap, @Nullable String contentTypeHeader) {
Request request = transaction.getContext().getRequest();
if (hasBody(contentTypeHeader, method)) {
if (coreConfiguration.getCaptureBody() != OFF && parameterMap != null) {
diff --git a/apm-agent-plugins/apm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/adapter/JakartaServletApiAdapter.java b/apm-agent-plugins/apm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/adapter/JakartaServletApiAdapter.java
index cf1aa47bab6..eb5af97852d 100644
--- a/apm-agent-plugins/apm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/adapter/JakartaServletApiAdapter.java
+++ b/apm-agent-plugins/apm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/adapter/JakartaServletApiAdapter.java
@@ -18,8 +18,8 @@
*/
package co.elastic.apm.agent.servlet.adapter;
-import co.elastic.apm.agent.impl.context.Request;
-import co.elastic.apm.agent.impl.transaction.TextHeaderGetter;
+import co.elastic.apm.plugin.spi.Request;
+import co.elastic.apm.plugin.spi.TextHeaderGetter;
import co.elastic.apm.agent.servlet.helper.JakartaServletRequestHeaderGetter;
import jakarta.servlet.DispatcherType;
import jakarta.servlet.FilterConfig;
diff --git a/apm-agent-plugins/apm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/adapter/JavaxServletApiAdapter.java b/apm-agent-plugins/apm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/adapter/JavaxServletApiAdapter.java
index 05a5bda8c8c..229e2aff194 100644
--- a/apm-agent-plugins/apm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/adapter/JavaxServletApiAdapter.java
+++ b/apm-agent-plugins/apm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/adapter/JavaxServletApiAdapter.java
@@ -18,8 +18,8 @@
*/
package co.elastic.apm.agent.servlet.adapter;
-import co.elastic.apm.agent.impl.context.Request;
-import co.elastic.apm.agent.impl.transaction.TextHeaderGetter;
+import co.elastic.apm.plugin.spi.Request;
+import co.elastic.apm.plugin.spi.TextHeaderGetter;
import co.elastic.apm.agent.servlet.helper.JavaxServletRequestHeaderGetter;
import javax.annotation.Nullable;
diff --git a/apm-agent-plugins/apm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/adapter/ServletRequestAdapter.java b/apm-agent-plugins/apm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/adapter/ServletRequestAdapter.java
index a8d2f71fc5b..3babc50d578 100644
--- a/apm-agent-plugins/apm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/adapter/ServletRequestAdapter.java
+++ b/apm-agent-plugins/apm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/adapter/ServletRequestAdapter.java
@@ -18,8 +18,8 @@
*/
package co.elastic.apm.agent.servlet.adapter;
-import co.elastic.apm.agent.impl.context.Request;
-import co.elastic.apm.agent.impl.transaction.TextHeaderGetter;
+import co.elastic.apm.plugin.spi.Request;
+import co.elastic.apm.plugin.spi.TextHeaderGetter;
import co.elastic.apm.agent.sdk.state.GlobalState;
import javax.annotation.Nullable;
diff --git a/apm-agent-plugins/apm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/helper/AbstractServletRequestHeaderGetter.java b/apm-agent-plugins/apm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/helper/AbstractServletRequestHeaderGetter.java
index 73beb5cb7ea..3ef433a7f87 100644
--- a/apm-agent-plugins/apm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/helper/AbstractServletRequestHeaderGetter.java
+++ b/apm-agent-plugins/apm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/helper/AbstractServletRequestHeaderGetter.java
@@ -18,7 +18,7 @@
*/
package co.elastic.apm.agent.servlet.helper;
-import co.elastic.apm.agent.impl.transaction.TextHeaderGetter;
+import co.elastic.apm.plugin.spi.TextHeaderGetter;
import java.util.Enumeration;
diff --git a/apm-agent-plugins/apm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/helper/JakartaApmAsyncListener.java b/apm-agent-plugins/apm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/helper/JakartaApmAsyncListener.java
index a689a9a3eea..1b7972a8db4 100644
--- a/apm-agent-plugins/apm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/helper/JakartaApmAsyncListener.java
+++ b/apm-agent-plugins/apm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/helper/JakartaApmAsyncListener.java
@@ -18,8 +18,8 @@
*/
package co.elastic.apm.agent.servlet.helper;
-import co.elastic.apm.agent.impl.context.Response;
-import co.elastic.apm.agent.impl.transaction.Transaction;
+import co.elastic.apm.plugin.spi.Response;
+import co.elastic.apm.plugin.spi.Transaction;
import co.elastic.apm.agent.objectpool.Recyclable;
import co.elastic.apm.agent.servlet.ServletTransactionHelper;
@@ -57,7 +57,7 @@ public class JakartaApmAsyncListener implements AsyncListener, Recyclable {
private final JakartaAsyncContextAdviceHelper asyncContextAdviceHelperImpl;
private final ServletTransactionHelper servletTransactionHelper;
@Nullable
- private volatile Transaction transaction;
+ private volatile Transaction> transaction;
@Nullable
private volatile Throwable throwable;
@@ -66,7 +66,7 @@ public class JakartaApmAsyncListener implements AsyncListener, Recyclable {
this.servletTransactionHelper = asyncContextAdviceHelperImpl.getServletTransactionHelper();
}
- JakartaApmAsyncListener withTransaction(Transaction transaction) {
+ JakartaApmAsyncListener withTransaction(Transaction> transaction) {
this.transaction = transaction;
return this;
}
diff --git a/apm-agent-plugins/apm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/helper/JakartaAsyncContextAdviceHelper.java b/apm-agent-plugins/apm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/helper/JakartaAsyncContextAdviceHelper.java
index adca4c22714..cf4d7ca2efa 100644
--- a/apm-agent-plugins/apm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/helper/JakartaAsyncContextAdviceHelper.java
+++ b/apm-agent-plugins/apm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/helper/JakartaAsyncContextAdviceHelper.java
@@ -18,10 +18,10 @@
*/
package co.elastic.apm.agent.servlet.helper;
-import co.elastic.apm.agent.impl.Tracer;
-import co.elastic.apm.agent.impl.transaction.Transaction;
-import co.elastic.apm.agent.objectpool.Allocator;
-import co.elastic.apm.agent.objectpool.ObjectPool;
+import co.elastic.apm.plugin.spi.Allocator;
+import co.elastic.apm.plugin.spi.ObjectPool;
+import co.elastic.apm.plugin.spi.Tracer;
+import co.elastic.apm.plugin.spi.Transaction;
import co.elastic.apm.agent.servlet.ServletTransactionHelper;
import jakarta.servlet.AsyncContext;
import jakarta.servlet.ServletRequest;
@@ -62,7 +62,7 @@ public void onExitStartAsync(AsyncContext asyncContext) {
if (request.getAttribute(ASYNC_LISTENER_ADDED) != null) {
return;
}
- final Transaction transaction = tracer.currentTransaction();
+ final Transaction> transaction = tracer.currentTransaction();
if (transaction != null && transaction.isSampled() && request.getAttribute(ASYNC_LISTENER_ADDED) == null) {
// makes sure that the listener is only added once, even if the request is wrapped
// which leads to multiple invocations of startAsync for the same underlying request
diff --git a/apm-agent-plugins/apm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/helper/JakartaRecordingServletInputStreamWrapper.java b/apm-agent-plugins/apm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/helper/JakartaRecordingServletInputStreamWrapper.java
index cde1c51de9d..ced027c0024 100644
--- a/apm-agent-plugins/apm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/helper/JakartaRecordingServletInputStreamWrapper.java
+++ b/apm-agent-plugins/apm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/helper/JakartaRecordingServletInputStreamWrapper.java
@@ -18,9 +18,9 @@
*/
package co.elastic.apm.agent.servlet.helper;
-import co.elastic.apm.agent.impl.context.Request;
import co.elastic.apm.agent.util.IOUtils;
+import co.elastic.apm.plugin.spi.Request;
import jakarta.servlet.ReadListener;
import jakarta.servlet.ServletInputStream;
import java.io.IOException;
diff --git a/apm-agent-plugins/apm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/helper/JakartaServletRequestHeaderGetter.java b/apm-agent-plugins/apm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/helper/JakartaServletRequestHeaderGetter.java
index 69404eeea7d..94438d9dab0 100644
--- a/apm-agent-plugins/apm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/helper/JakartaServletRequestHeaderGetter.java
+++ b/apm-agent-plugins/apm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/helper/JakartaServletRequestHeaderGetter.java
@@ -18,7 +18,7 @@
*/
package co.elastic.apm.agent.servlet.helper;
-import co.elastic.apm.agent.impl.transaction.TextHeaderGetter;
+import co.elastic.apm.plugin.spi.TextHeaderGetter;
import jakarta.servlet.http.HttpServletRequest;
import java.util.Enumeration;
diff --git a/apm-agent-plugins/apm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/helper/JavaxApmAsyncListener.java b/apm-agent-plugins/apm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/helper/JavaxApmAsyncListener.java
index 4fc8d2e0770..01f869b78a2 100644
--- a/apm-agent-plugins/apm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/helper/JavaxApmAsyncListener.java
+++ b/apm-agent-plugins/apm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/helper/JavaxApmAsyncListener.java
@@ -18,8 +18,8 @@
*/
package co.elastic.apm.agent.servlet.helper;
-import co.elastic.apm.agent.impl.context.Response;
-import co.elastic.apm.agent.impl.transaction.Transaction;
+import co.elastic.apm.plugin.spi.Response;
+import co.elastic.apm.plugin.spi.Transaction;
import co.elastic.apm.agent.objectpool.Recyclable;
import co.elastic.apm.agent.servlet.ServletTransactionHelper;
@@ -57,7 +57,7 @@ public class JavaxApmAsyncListener implements AsyncListener, Recyclable {
private final JavaxAsyncContextAdviceHelper asyncContextAdviceHelperImpl;
private final ServletTransactionHelper servletTransactionHelper;
@Nullable
- private volatile Transaction transaction;
+ private volatile Transaction> transaction;
@Nullable
private volatile Throwable throwable;
@@ -66,7 +66,7 @@ public class JavaxApmAsyncListener implements AsyncListener, Recyclable {
this.servletTransactionHelper = asyncContextAdviceHelperImpl.getServletTransactionHelper();
}
- JavaxApmAsyncListener withTransaction(Transaction transaction) {
+ JavaxApmAsyncListener withTransaction(Transaction> transaction) {
this.transaction = transaction;
return this;
}
diff --git a/apm-agent-plugins/apm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/helper/JavaxAsyncContextAdviceHelper.java b/apm-agent-plugins/apm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/helper/JavaxAsyncContextAdviceHelper.java
index ee5add938e3..b14ff8c679d 100644
--- a/apm-agent-plugins/apm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/helper/JavaxAsyncContextAdviceHelper.java
+++ b/apm-agent-plugins/apm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/helper/JavaxAsyncContextAdviceHelper.java
@@ -18,10 +18,10 @@
*/
package co.elastic.apm.agent.servlet.helper;
-import co.elastic.apm.agent.impl.Tracer;
-import co.elastic.apm.agent.impl.transaction.Transaction;
-import co.elastic.apm.agent.objectpool.Allocator;
-import co.elastic.apm.agent.objectpool.ObjectPool;
+import co.elastic.apm.plugin.spi.Allocator;
+import co.elastic.apm.plugin.spi.ObjectPool;
+import co.elastic.apm.plugin.spi.Tracer;
+import co.elastic.apm.plugin.spi.Transaction;
import co.elastic.apm.agent.servlet.ServletTransactionHelper;
import javax.servlet.AsyncContext;
@@ -62,7 +62,7 @@ public void onExitStartAsync(AsyncContext asyncContext) {
if (request.getAttribute(ASYNC_LISTENER_ADDED) != null) {
return;
}
- final Transaction transaction = tracer.currentTransaction();
+ final Transaction> transaction = tracer.currentTransaction();
if (transaction != null && transaction.isSampled() && request.getAttribute(ASYNC_LISTENER_ADDED) == null) {
// makes sure that the listener is only added once, even if the request is wrapped
// which leads to multiple invocations of startAsync for the same underlying request
diff --git a/apm-agent-plugins/apm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/helper/JavaxRecordingServletInputStreamWrapper.java b/apm-agent-plugins/apm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/helper/JavaxRecordingServletInputStreamWrapper.java
index e949f975588..f22cb0fbb91 100644
--- a/apm-agent-plugins/apm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/helper/JavaxRecordingServletInputStreamWrapper.java
+++ b/apm-agent-plugins/apm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/helper/JavaxRecordingServletInputStreamWrapper.java
@@ -18,8 +18,8 @@
*/
package co.elastic.apm.agent.servlet.helper;
-import co.elastic.apm.agent.impl.context.Request;
import co.elastic.apm.agent.util.IOUtils;
+import co.elastic.apm.plugin.spi.Request;
import javax.servlet.ReadListener;
import javax.servlet.ServletInputStream;
diff --git a/apm-agent-plugins/apm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/helper/JavaxServletRequestHeaderGetter.java b/apm-agent-plugins/apm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/helper/JavaxServletRequestHeaderGetter.java
index 145e27a8d15..702f6872249 100644
--- a/apm-agent-plugins/apm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/helper/JavaxServletRequestHeaderGetter.java
+++ b/apm-agent-plugins/apm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/helper/JavaxServletRequestHeaderGetter.java
@@ -18,7 +18,7 @@
*/
package co.elastic.apm.agent.servlet.helper;
-import co.elastic.apm.agent.impl.transaction.TextHeaderGetter;
+import co.elastic.apm.plugin.spi.TextHeaderGetter;
import javax.servlet.http.HttpServletRequest;
import java.util.Enumeration;
diff --git a/apm-agent-plugins/apm-sparkjava-plugin/src/main/java/co/elastic/apm/agent/sparkjava/RoutesAdvice.java b/apm-agent-plugins/apm-sparkjava-plugin/src/main/java/co/elastic/apm/agent/sparkjava/RoutesAdvice.java
index cc385cd3b36..7343a1d8d9a 100644
--- a/apm-agent-plugins/apm-sparkjava-plugin/src/main/java/co/elastic/apm/agent/sparkjava/RoutesAdvice.java
+++ b/apm-agent-plugins/apm-sparkjava-plugin/src/main/java/co/elastic/apm/agent/sparkjava/RoutesAdvice.java
@@ -18,17 +18,17 @@
*/
package co.elastic.apm.agent.sparkjava;
-import co.elastic.apm.agent.impl.GlobalTracer;
-import co.elastic.apm.agent.impl.Tracer;
+import co.elastic.apm.plugin.spi.GlobalTracer;
+import co.elastic.apm.plugin.spi.Tracer;
import co.elastic.apm.agent.impl.context.web.WebConfiguration;
-import co.elastic.apm.agent.impl.transaction.Transaction;
+import co.elastic.apm.plugin.spi.Transaction;
import co.elastic.apm.agent.util.TransactionNameUtils;
import co.elastic.apm.agent.util.VersionUtils;
import net.bytebuddy.asm.Advice;
import spark.Route;
import spark.routematch.RouteMatch;
-import static co.elastic.apm.agent.impl.transaction.AbstractSpan.PRIO_LOW_LEVEL_FRAMEWORK;
+import static co.elastic.apm.plugin.spi.AbstractSpan.PRIO_LOW_LEVEL_FRAMEWORK;
public class RoutesAdvice {
@@ -36,7 +36,7 @@ public class RoutesAdvice {
@Advice.OnMethodExit(suppress = Throwable.class, inline = false)
public static void onExitFind(@Advice.Return RouteMatch routeMatch) {
- Transaction transaction = tracer.currentTransaction();
+ Transaction> transaction = tracer.currentTransaction();
if (transaction == null || routeMatch == null) {
return;
}
diff --git a/apm-agent-plugins/apm-spring-resttemplate/apm-spring-resttemplate-plugin/src/main/java/co/elastic/apm/agent/resttemplate/SpringRestRequestHeaderSetter.java b/apm-agent-plugins/apm-spring-resttemplate/apm-spring-resttemplate-plugin/src/main/java/co/elastic/apm/agent/resttemplate/SpringRestRequestHeaderSetter.java
index 40d428371ac..888bab065e5 100644
--- a/apm-agent-plugins/apm-spring-resttemplate/apm-spring-resttemplate-plugin/src/main/java/co/elastic/apm/agent/resttemplate/SpringRestRequestHeaderSetter.java
+++ b/apm-agent-plugins/apm-spring-resttemplate/apm-spring-resttemplate-plugin/src/main/java/co/elastic/apm/agent/resttemplate/SpringRestRequestHeaderSetter.java
@@ -18,7 +18,7 @@
*/
package co.elastic.apm.agent.resttemplate;
-import co.elastic.apm.agent.impl.transaction.TextHeaderSetter;
+import co.elastic.apm.plugin.spi.TextHeaderSetter;
import org.springframework.http.HttpRequest;
public class SpringRestRequestHeaderSetter implements TextHeaderSetter {
diff --git a/apm-agent-plugins/apm-spring-resttemplate/apm-spring-resttemplate-plugin/src/main/java/co/elastic/apm/agent/resttemplate/SpringRestTemplateAdvice.java b/apm-agent-plugins/apm-spring-resttemplate/apm-spring-resttemplate-plugin/src/main/java/co/elastic/apm/agent/resttemplate/SpringRestTemplateAdvice.java
index 15bdde6228e..e7116f3af71 100644
--- a/apm-agent-plugins/apm-spring-resttemplate/apm-spring-resttemplate-plugin/src/main/java/co/elastic/apm/agent/resttemplate/SpringRestTemplateAdvice.java
+++ b/apm-agent-plugins/apm-spring-resttemplate/apm-spring-resttemplate-plugin/src/main/java/co/elastic/apm/agent/resttemplate/SpringRestTemplateAdvice.java
@@ -20,9 +20,9 @@
import co.elastic.apm.agent.bci.TracerAwareInstrumentation;
import co.elastic.apm.agent.httpclient.HttpClientHelper;
-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.plugin.spi.AbstractSpan;
+import co.elastic.apm.plugin.spi.DefaultOutcome;
+import co.elastic.apm.plugin.spi.Span;
import net.bytebuddy.asm.Advice;
import co.elastic.apm.agent.sdk.logging.Logger;
import co.elastic.apm.agent.sdk.logging.LoggerFactory;
@@ -48,7 +48,7 @@ public static Object beforeExecute(@Advice.This ClientHttpRequest request) {
return null;
}
URI uri = request.getURI();
- Span span = HttpClientHelper.startHttpClientSpan(parent, Objects.toString(request.getMethod()), uri, uri.getHost());
+ Span> span = HttpClientHelper.startHttpClientSpan(parent, Objects.toString(request.getMethod()), uri, uri.getHost());
if (span != null) {
span.activate();
span.propagateTraceContext(request, SpringRestRequestHeaderSetter.INSTANCE);
@@ -63,15 +63,15 @@ public static void afterExecute(@Advice.Return @Nullable ClientHttpResponse clie
@Advice.Enter @Nullable Object spanObj,
@Advice.Thrown @Nullable Throwable t) throws IOException {
logger.trace("Exit advice for RestTemplate client execute() method, span object: {}", spanObj);
- if (spanObj instanceof Span) {
- Span span = (Span) spanObj;
+ if (spanObj instanceof Span>) {
+ Span> span = (Span>) spanObj;
try {
if (clientHttpResponse != null) {
// getRawStatusCode has been introduced in 3.1.1
span.getContext().getHttp().withStatusCode(clientHttpResponse.getRawStatusCode());
}
if (t != null) {
- span.withOutcome(Outcome.FAILURE);
+ span.withOutcome(DefaultOutcome.FAILURE);
}
span.captureException(t);
} finally {
diff --git a/apm-agent-plugins/apm-spring-webflux/apm-spring-webclient-plugin/src/main/java/co/elastic/apm/agent/springwebclient/WebClientExchangeFunctionInstrumentation.java b/apm-agent-plugins/apm-spring-webflux/apm-spring-webclient-plugin/src/main/java/co/elastic/apm/agent/springwebclient/WebClientExchangeFunctionInstrumentation.java
index caea36a19f6..585426f4f7a 100644
--- a/apm-agent-plugins/apm-spring-webflux/apm-spring-webclient-plugin/src/main/java/co/elastic/apm/agent/springwebclient/WebClientExchangeFunctionInstrumentation.java
+++ b/apm-agent-plugins/apm-spring-webflux/apm-spring-webclient-plugin/src/main/java/co/elastic/apm/agent/springwebclient/WebClientExchangeFunctionInstrumentation.java
@@ -20,8 +20,8 @@
import co.elastic.apm.agent.bci.TracerAwareInstrumentation;
import co.elastic.apm.agent.httpclient.HttpClientHelper;
-import co.elastic.apm.agent.impl.transaction.AbstractSpan;
-import co.elastic.apm.agent.impl.transaction.Span;
+import co.elastic.apm.plugin.spi.AbstractSpan;
+import co.elastic.apm.plugin.spi.Span;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.asm.Advice.AssignReturned.ToArguments.ToArgument;
import net.bytebuddy.description.NamedElement;
@@ -80,7 +80,7 @@ public static Object[] onBefore(@Advice.Argument(0) ClientRequest clientRequest)
}
ClientRequest.Builder builder = ClientRequest.from(clientRequest);
URI uri = clientRequest.url();
- Span span = HttpClientHelper.startHttpClientSpan(parent, clientRequest.method().name(), uri, uri.getHost());
+ Span> span = HttpClientHelper.startHttpClientSpan(parent, clientRequest.method().name(), uri, uri.getHost());
if (span != null) {
span.activate();
span.propagateTraceContext(builder, WebClientRequestHeaderSetter.INSTANCE);
@@ -101,10 +101,10 @@ public static Object afterExecute(@Advice.Return @Nullable Publisher> returnVa
return returnValue;
}
Object spanObj = spanRequestObj[1];
- if (!(spanObj instanceof Span)) {
+ if (!(spanObj instanceof Span>)) {
return returnValue;
}
- Span span = (Span) spanObj;
+ Span> span = (Span>) spanObj;
span = span.captureException(t).deactivate();
if (t != null || returnValue == null) {
return returnValue;
diff --git a/apm-agent-plugins/apm-spring-webflux/apm-spring-webclient-plugin/src/main/java/co/elastic/apm/agent/springwebclient/WebClientHelper.java b/apm-agent-plugins/apm-spring-webflux/apm-spring-webclient-plugin/src/main/java/co/elastic/apm/agent/springwebclient/WebClientHelper.java
index edc81b9cf6c..13159dc4627 100755
--- a/apm-agent-plugins/apm-spring-webflux/apm-spring-webclient-plugin/src/main/java/co/elastic/apm/agent/springwebclient/WebClientHelper.java
+++ b/apm-agent-plugins/apm-spring-webflux/apm-spring-webclient-plugin/src/main/java/co/elastic/apm/agent/springwebclient/WebClientHelper.java
@@ -18,8 +18,8 @@
*/
package co.elastic.apm.agent.springwebclient;
-import co.elastic.apm.agent.impl.Tracer;
-import co.elastic.apm.agent.impl.transaction.Span;
+import co.elastic.apm.plugin.spi.Tracer;
+import co.elastic.apm.plugin.spi.Span;
import org.reactivestreams.Publisher;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -35,7 +35,7 @@ public class WebClientHelper {
private static final Logger log = LoggerFactory.getLogger(WebClientHelper.class);
- public static Publisher wrapSubscriber(Publisher publisher, final Span span, final Tracer tracer) {
+ public static Publisher wrapSubscriber(Publisher publisher, final Span> span, final Tracer tracer) {
Function super Publisher