diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/BasicTracer.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/BasicTracer.java new file mode 100644 index 00000000000..9166e00e02b --- /dev/null +++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/BasicTracer.java @@ -0,0 +1,451 @@ +/* + * 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.agent.impl; + +import co.elastic.apm.agent.configuration.ServiceInfo; +import co.elastic.apm.agent.impl.error.ErrorCapture; +import co.elastic.apm.agent.impl.sampling.Sampler; +import co.elastic.apm.agent.impl.transaction.*; +import co.elastic.apm.agent.objectpool.ObjectPool; +import co.elastic.apm.agent.objectpool.ObjectPoolFactory; +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 org.stagemonitor.configuration.ConfigurationOptionProvider; + +import javax.annotation.Nullable; +import java.util.Collections; + +public class BasicTracer implements SpanAwareTracer { + + private static final Logger logger = LoggerFactory.getLogger(BasicTracer.class); + + private static final WeakMap serviceInfoByClassLoader = WeakConcurrent.buildMap(); + + private final ObjectPoolFactory objectPoolFactory; + protected final ObjectPool transactionPool; + protected final ObjectPool errorPool; + protected final ObjectPool spanPool; + protected final ObjectPool spanLinkPool; + + protected Sampler sampler; + protected boolean assertionsEnabled; + + protected final ThreadLocal activeStack; + + protected BasicTracer( + int maxPooledElements, + final int transactionMaxSpans, + ObjectPoolFactory objectPoolFactory + ) { + this.objectPoolFactory = objectPoolFactory; + this.transactionPool = objectPoolFactory.createTransactionPool(maxPooledElements, this); + // we are assuming that we don't need as many errors as spans or transactions + this.errorPool = objectPoolFactory.createErrorPool(maxPooledElements / 2, this); + this.spanPool = objectPoolFactory.createSpanPool(maxPooledElements, this); + // span links pool allows for 10X the maximum allowed span links per span + this.spanLinkPool = objectPoolFactory.createSpanLinkPool(AbstractSpan.MAX_ALLOWED_SPAN_LINKS * 10, this); + activeStack = new ThreadLocal() { + @Override + protected ActiveStack initialValue() { + return new ActiveStack(transactionMaxSpans); + } + }; + // sets the assertionsEnabled flag to true if indeed enabled + boolean assertionsEnabled = false; + //noinspection AssertWithSideEffects + assert assertionsEnabled = true; + this.assertionsEnabled = assertionsEnabled; + } + + @Override + public ObjectPoolFactory getObjectPoolFactory() { + return objectPoolFactory; + } + + @Override + @Nullable + public Transaction startRootTransaction(@Nullable ClassLoader initiatingClassLoader) { + return startRootTransaction(sampler, -1, initiatingClassLoader); + } + + @Override + @Nullable + public Transaction startRootTransaction(@Nullable ClassLoader initiatingClassLoader, long epochMicro) { + return startRootTransaction(sampler, epochMicro, initiatingClassLoader); + } + + @Override + @Nullable + public Transaction startRootTransaction(Sampler sampler, long epochMicros, @Nullable ClassLoader initiatingClassLoader) { + Transaction transaction = null; + if (isRunning()) { + transaction = createTransaction().startRoot(epochMicros, sampler); + afterTransactionStart(initiatingClassLoader, transaction); + } + return transaction; + } + + @Override + @Nullable + public Transaction startChildTransaction(@Nullable C headerCarrier, TextHeaderGetter textHeadersGetter, @Nullable ClassLoader initiatingClassLoader) { + return startChildTransaction(headerCarrier, textHeadersGetter, sampler, -1, initiatingClassLoader); + } + + @Override + @Nullable + public Transaction startChildTransaction(@Nullable C headerCarrier, TextHeaderGetter textHeadersGetter, @Nullable ClassLoader initiatingClassLoader, long epochMicros) { + return startChildTransaction(headerCarrier, textHeadersGetter, sampler, epochMicros, initiatingClassLoader); + } + + @Override + @Nullable + public Transaction startChildTransaction(@Nullable C headerCarrier, TextHeaderGetter textHeadersGetter, Sampler sampler, + long epochMicros, @Nullable ClassLoader initiatingClassLoader) { + Transaction transaction = null; + if (isRunning()) { + transaction = createTransaction().start(TraceContext.getFromTraceContextTextHeaders(), headerCarrier, + textHeadersGetter, epochMicros, sampler); + afterTransactionStart(initiatingClassLoader, transaction); + } + return transaction; + } + + @Override + @Nullable + public Transaction startChildTransaction(@Nullable C headerCarrier, BinaryHeaderGetter binaryHeadersGetter, @Nullable ClassLoader initiatingClassLoader) { + return startChildTransaction(headerCarrier, binaryHeadersGetter, sampler, -1, initiatingClassLoader); + } + + @Override + @Nullable + public Transaction startChildTransaction(@Nullable C headerCarrier, BinaryHeaderGetter binaryHeadersGetter, + Sampler sampler, long epochMicros, @Nullable ClassLoader initiatingClassLoader) { + Transaction transaction = null; + if (isRunning()) { + transaction = createTransaction().start(TraceContext.getFromTraceContextBinaryHeaders(), headerCarrier, + binaryHeadersGetter, epochMicros, sampler); + afterTransactionStart(initiatingClassLoader, transaction); + } + return transaction; + } + + private void afterTransactionStart(@Nullable ClassLoader initiatingClassLoader, Transaction transaction) { + if (logger.isDebugEnabled()) { + logger.debug("startTransaction {}", transaction); + if (logger.isTraceEnabled()) { + logger.trace("starting transaction at", + new RuntimeException("this exception is just used to record where the transaction has been started from")); + } + } + final ServiceInfo serviceInfo = getServiceInfoForClassLoader(initiatingClassLoader); + if (serviceInfo != null) { + transaction.getTraceContext().setServiceInfo(serviceInfo.getServiceName(), serviceInfo.getServiceVersion()); + } + } + + protected Transaction createTransaction() { + Transaction transaction = transactionPool.createInstance(); + while (transaction.getReferenceCount() != 0) { + logger.warn("Tried to start a transaction with a non-zero reference count {} {}", transaction.getReferenceCount(), transaction); + transaction = transactionPool.createInstance(); + } + return transaction; + } + + @Override + @Nullable + public Transaction currentTransaction() { + return activeStack.get().currentTransaction(); + } + + @Override + public void endTransaction(Transaction transaction) { + if (transaction.isNoop() || !transaction.isSampled()) { + transaction.decrementReferences(); + } + } + + @Override + public void captureAndReportException(@Nullable Throwable e, ClassLoader initiatingClassLoader) { + ErrorCapture errorCapture = captureException(System.currentTimeMillis() * 1000, e, getActive(), initiatingClassLoader); + if (errorCapture != null) { + errorCapture.end(); + } + } + + @Override + public void endSpan(Span span) { + if (!span.isSampled() || span.isDiscarded()) { + Transaction transaction = span.getTransaction(); + if (transaction != null) { + transaction.captureDroppedSpan(span); + } + span.decrementReferences(); + } + } + + @Override + @Nullable + public String captureAndReportException(long epochMicros, @Nullable Throwable e, @Nullable AbstractSpan parent) { + String id = null; + ErrorCapture errorCapture = captureException(epochMicros, e, parent, null); + if (errorCapture != null) { + id = errorCapture.getTraceContext().getId().toString(); + errorCapture.end(); + } + return id; + } + + @Override + @Nullable + public ErrorCapture captureException(@Nullable Throwable e, @Nullable AbstractSpan parent, @Nullable ClassLoader initiatingClassLoader) { + return captureException(System.currentTimeMillis() * 1000, e, parent, initiatingClassLoader); + } + + @Nullable + private ErrorCapture captureException(long epochMicros, @Nullable Throwable e, @Nullable AbstractSpan parent, @Nullable ClassLoader initiatingClassLoader) { + if (!isRunning()) { + return null; + } + // note: if we add inheritance support for exception filtering, caching would be required for performance + if (e != null && !isIgnoredException(e)) { + ErrorCapture error = errorPool.createInstance(); + error.withTimestamp(epochMicros); + error.setException(e); + Transaction currentTransaction = currentTransaction(); + if (currentTransaction != null) { + if (currentTransaction.getNameForSerialization().length() > 0) { + error.setTransactionName(currentTransaction.getNameForSerialization()); + } + error.setTransactionType(currentTransaction.getType()); + error.setTransactionSampled(currentTransaction.isSampled()); + } + if (parent != null) { + error.asChildOf(parent); + // don't discard spans leading up to an error, otherwise they'd point to an invalid parent + parent.setNonDiscardable(); + } else { + error.getTraceContext().getId().setToRandomValue(); + ServiceInfo serviceInfo = getServiceInfoForClassLoader(initiatingClassLoader); + if (serviceInfo != null) { + error.getTraceContext().setServiceInfo(serviceInfo.getServiceName(), serviceInfo.getServiceVersion()); + } + } + return error; + } + return null; + } + + protected boolean isIgnoredException(Throwable e) { + return true; + } + + @Override + @Nullable + public AbstractSpan getActive() { + ElasticContext active = currentContext(); + return active != null ? active.getSpan() : null; + } + + /** + * @return the currently active context, {@literal null} if there is none. + */ + @Nullable + public ElasticContext currentContext() { + return activeStack.get().currentContext(); + } + + @Nullable + @Override + public Span getActiveSpan() { + final AbstractSpan active = getActive(); + if (active instanceof Span) { + return (Span) active; + } + return null; + } + + @Nullable + @Override + public Span getActiveExitSpan() { + final Span span = getActiveSpan(); + if (span != null && span.isExit()) { + return span; + } + return null; + } + + @Override + @Nullable + public Span createExitChildSpan() { + AbstractSpan active = getActive(); + if (active == null) { + return null; + } + return active.createExitSpan(); + } + + @Override + public void setServiceInfoForClassLoader(@Nullable ClassLoader classLoader, ServiceInfo serviceInfo) { + // overriding the service name/version for the bootstrap class loader is not an actual use-case + // null may also mean we don't know about the initiating class loader + if (classLoader == null + || !serviceInfo.hasServiceName() + // if the service name is set explicitly, don't override it + || hasServiceName()) { + return; + } + + logger.debug("Using `{}` as the service name and `{}` as the service version for class loader [{}]", serviceInfo.getServiceName(), serviceInfo.getServiceVersion(), classLoader); + if (!serviceInfoByClassLoader.containsKey(classLoader)) { + serviceInfoByClassLoader.putIfAbsent(classLoader, serviceInfo); + } + } + + protected boolean hasServiceName() { + return false; + } + + @Nullable + @Override + public ServiceInfo getServiceInfoForClassLoader(@Nullable ClassLoader initiatingClassLoader) { + if (initiatingClassLoader == null) { + return null; + } + return serviceInfoByClassLoader.get(initiatingClassLoader); + } + + @Override + public TraceContext createSpanLink() { + return spanLinkPool.createInstance(); + } + + /** + * Starts a span with a given parent context. + *

+ * This method makes it possible to start a span after the parent has already ended. + *

+ * + * @param parentContext the trace context of the parent + * @return a new started span + */ + public Span startSpan(TraceContext.ChildContextCreator childContextCreator, T parentContext) { + return startSpan(childContextCreator, parentContext, -1); + } + + public Span startSpan(AbstractSpan parent, long epochMicros) { + return startSpan(TraceContext.fromParent(), parent, epochMicros); + } + + /** + * @param parentContext the trace context of the parent + * @param epochMicros the start timestamp of the span in microseconds after epoch + * @return a new started span + * @see #startSpan(TraceContext.ChildContextCreator, Object) + */ + public Span startSpan(TraceContext.ChildContextCreator childContextCreator, T parentContext, long epochMicros) { + return createSpan().start(childContextCreator, parentContext, epochMicros); + } + + private Span createSpan() { + Span span = spanPool.createInstance(); + while (span.getReferenceCount() != 0) { + logger.warn("Tried to start a span with a non-zero reference count {} {}", span.getReferenceCount(), span); + span = spanPool.createInstance(); + } + return span; + } + + @Override + public void recycle(Transaction transaction) { + transactionPool.recycle(transaction); + } + + @Override + public void recycle(Span span) { + spanPool.recycle(span); + } + + @Override + public void recycle(ErrorCapture error) { + errorPool.recycle(error); + } + + @Override + public void recycle(TraceContext traceContext) { + spanLinkPool.recycle(traceContext); + } + + @Override + public void activate(ElasticContext context) { + activeStack.get().activate(context, Collections.emptyList()); + } + + @Override + public void deactivate(ElasticContext context) { + activeStack.get().deactivate(context, Collections.emptyList(), assertionsEnabled); + } + + @Override + public Scope activateInScope(final ElasticContext context) { + // already in scope + if (currentContext() == context) { + return Scope.NoopScope.INSTANCE; + } + context.activate(); + + if (context instanceof Scope) { + // we can take shortcut and avoid creating a separate object + return (Scope) context; + } + return new Scope() { + @Override + public void close() { + context.deactivate(); + } + }; + } + + @Override + public void endError(ErrorCapture errorCapture) { } + + @Override + public void stop() { } + + @Override + public boolean isRunning() { + return true; + } + + @Override + public TracerState getState() { + return TracerState.RUNNING; + } + + @Override + public T getConfig(Class configProvider) { + try { + return configProvider.getConstructor().newInstance(); + } catch (Exception e) { + throw new IllegalStateException("Failed to create empty configuration for " + configProvider.getName(), e); + } + } +} diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/ElasticApmTracer.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/ElasticApmTracer.java index 4ceafc421fa..bbbed71fd7d 100644 --- a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/ElasticApmTracer.java +++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/ElasticApmTracer.java @@ -19,6 +19,7 @@ package co.elastic.apm.agent.impl; import co.elastic.apm.agent.common.JvmRuntimeInfo; +import co.elastic.apm.agent.common.util.WildcardMatcher; import co.elastic.apm.agent.configuration.CoreConfiguration; import co.elastic.apm.agent.configuration.ServiceInfo; import co.elastic.apm.agent.configuration.SpanConfiguration; @@ -30,16 +31,11 @@ import co.elastic.apm.agent.impl.sampling.Sampler; import co.elastic.apm.agent.impl.stacktrace.StacktraceConfiguration; import co.elastic.apm.agent.impl.transaction.AbstractSpan; -import co.elastic.apm.agent.impl.transaction.BinaryHeaderGetter; import co.elastic.apm.agent.impl.transaction.ElasticContext; 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.logging.LoggingConfiguration; -import co.elastic.apm.agent.common.util.WildcardMatcher; import co.elastic.apm.agent.metrics.MetricRegistry; -import co.elastic.apm.agent.objectpool.ObjectPool; import co.elastic.apm.agent.objectpool.ObjectPoolFactory; import co.elastic.apm.agent.report.ApmServerClient; import co.elastic.apm.agent.report.Reporter; @@ -71,7 +67,7 @@ * Note that this is a internal API, so there are no guarantees in terms of backwards compatibility. *

*/ -public class ElasticApmTracer implements Tracer { +public class ElasticApmTracer extends BasicTracer implements MetricsAwareTracer { private static final Logger logger = LoggerFactory.getLogger(ElasticApmTracer.class); private static final WeakMap serviceInfoByClassLoader = WeakConcurrent.buildMap(); @@ -80,29 +76,13 @@ public class ElasticApmTracer implements Tracer { private final StacktraceConfiguration stacktraceConfiguration; private final ApmServerClient apmServerClient; private final List lifecycleListeners = new CopyOnWriteArrayList<>(); - private final ObjectPool transactionPool; - private final ObjectPool spanPool; - private final ObjectPool errorPool; - private final ObjectPool spanLinkPool; private final Reporter reporter; - private final ObjectPoolFactory objectPoolFactory; - - private final ThreadLocal activeStack = new ThreadLocal() { - @Override - protected ActiveStack initialValue() { - return new ActiveStack(transactionMaxSpans); - } - }; - + private final int approximateContextSize; private final CoreConfiguration coreConfiguration; - private final int transactionMaxSpans; private final SpanConfiguration spanConfiguration; private final List activationListeners; private final MetricRegistry metricRegistry; private final ScheduledThreadPoolExecutor sharedPool; - private final int approximateContextSize; - private Sampler sampler; - boolean assertionsEnabled = false; /** * The tracer state is volatile to ensure thread safety when queried through {@link ElasticApmTracer#isRunning()} or @@ -116,263 +96,124 @@ protected ActiveStack initialValue() { private final String ephemeralId; private final MetaDataFuture metaDataFuture; - ElasticApmTracer(ConfigurationRegistry configurationRegistry, MetricRegistry metricRegistry, Reporter reporter, ObjectPoolFactory poolFactory, - ApmServerClient apmServerClient, final String ephemeralId, MetaDataFuture metaDataFuture) { - this.metricRegistry = metricRegistry; - this.configurationRegistry = configurationRegistry; - this.reporter = reporter; - this.stacktraceConfiguration = configurationRegistry.getConfig(StacktraceConfiguration.class); - this.apmServerClient = apmServerClient; - this.ephemeralId = ephemeralId; - this.metaDataFuture = metaDataFuture; + static ElasticApmTracer of( + ConfigurationRegistry configurationRegistry, + MetricRegistry metricRegistry, + Reporter reporter, + ObjectPoolFactory objectPoolFactory, + ApmServerClient apmServerClient, + final String ephemeralId, + MetaDataFuture metaDataFuture) { + int maxPooledElements = configurationRegistry.getConfig(ReporterConfiguration.class).getMaxQueueSize() * 2; - coreConfiguration = configurationRegistry.getConfig(CoreConfiguration.class); - transactionMaxSpans = coreConfiguration.getTransactionMaxSpans(); - spanConfiguration = configurationRegistry.getConfig(SpanConfiguration.class); + CoreConfiguration coreConfiguration = configurationRegistry.getConfig(CoreConfiguration.class); + int transactionMaxSpans = coreConfiguration.getTransactionMaxSpans(); + SpanConfiguration spanConfiguration = configurationRegistry.getConfig(SpanConfiguration.class); TracerConfiguration tracerConfiguration = configurationRegistry.getConfig(TracerConfiguration.class); - recordingConfigOptionSet = tracerConfiguration.getRecordingConfig().get(); - tracerConfiguration.getRecordingConfig().addChangeListener(new ConfigurationOption.ChangeListener() { - @Override - public void onChange(ConfigurationOption configurationOption, Boolean oldValue, Boolean newValue) { - ElasticApmTracer.this.recordingConfigChanged(oldValue, newValue); - } - }); + boolean recordingConfigOptionSet = tracerConfiguration.getRecordingConfig().get(); - this.objectPoolFactory = poolFactory; - transactionPool = poolFactory.createTransactionPool(maxPooledElements, this); - spanPool = poolFactory.createSpanPool(maxPooledElements, this); + StacktraceConfiguration stacktraceConfiguration = configurationRegistry.getConfig(StacktraceConfiguration.class); - // we are assuming that we don't need as many errors as spans or transactions - errorPool = poolFactory.createErrorPool(maxPooledElements / 2, this); + Sampler sampler = ProbabilitySampler.of(coreConfiguration.getSampleRate().get()); + ScheduledThreadPoolExecutor sharedPool = ExecutorUtils.createSingleThreadSchedulingDaemonPool("shared"); - // span links pool allows for 10X the maximum allowed span links per span - spanLinkPool = poolFactory.createSpanLinkPool(AbstractSpan.MAX_ALLOWED_SPAN_LINKS * 10, this); - - sampler = ProbabilitySampler.of(coreConfiguration.getSampleRate().get()); + // The estimated number of wrappers is linear to the number of the number of external/OTel plugins + // - for an internal agent context, there will be at most one wrapper per external/OTel plugin. + // - for a context created by an external/OTel, we have one less wrapper required + int approximateContextSize = coreConfiguration.getExternalPluginsCount() + 1; // +1 extra is for the OTel API plugin + + return new ElasticApmTracer( + maxPooledElements, + transactionMaxSpans, + approximateContextSize, + configurationRegistry, + stacktraceConfiguration, + apmServerClient, + reporter, + objectPoolFactory, + coreConfiguration, + tracerConfiguration, + spanConfiguration, + metricRegistry, + sharedPool, + sampler, + recordingConfigOptionSet, + ephemeralId, + metaDataFuture); + } + + private ElasticApmTracer( + int maxPooledElements, + int transactionMaxSpans, + int approximateContextSize, + ConfigurationRegistry configurationRegistry, + StacktraceConfiguration stacktraceConfiguration, + ApmServerClient apmServerClient, + Reporter reporter, + ObjectPoolFactory objectPoolFactory, + CoreConfiguration coreConfiguration, + TracerConfiguration tracerConfiguration, + SpanConfiguration spanConfiguration, + MetricRegistry metricRegistry, + ScheduledThreadPoolExecutor sharedPool, + Sampler sampler, + boolean recordingConfigOptionSet, + String ephemeralId, + MetaDataFuture metaDataFuture) { + super(maxPooledElements, transactionMaxSpans, objectPoolFactory); + this.configurationRegistry = configurationRegistry; + this.approximateContextSize = approximateContextSize; + this.stacktraceConfiguration = stacktraceConfiguration; + this.apmServerClient = apmServerClient; + this.reporter = reporter; + this.coreConfiguration = coreConfiguration; + this.spanConfiguration = spanConfiguration; + this.activationListeners = DependencyInjectingServiceLoader.load(ActivationListener.class, this); + this.metricRegistry = metricRegistry; + this.sharedPool = sharedPool; + this.sampler = sampler; + this.recordingConfigOptionSet = recordingConfigOptionSet; + this.ephemeralId = ephemeralId; + this.metaDataFuture = metaDataFuture; coreConfiguration.getSampleRate().addChangeListener(new ConfigurationOption.ChangeListener() { @Override public void onChange(ConfigurationOption configurationOption, Double oldValue, Double newValue) { - sampler = ProbabilitySampler.of(newValue); + ElasticApmTracer.this.sampler = ProbabilitySampler.of(newValue); + } + }); + tracerConfiguration.getRecordingConfig().addChangeListener(new ConfigurationOption.ChangeListener() { + @Override + public void onChange(ConfigurationOption configurationOption, Boolean oldValue, Boolean newValue) { + ElasticApmTracer.this.recordingConfigChanged(oldValue, newValue); } }); - this.activationListeners = DependencyInjectingServiceLoader.load(ActivationListener.class, this); - sharedPool = ExecutorUtils.createSingleThreadSchedulingDaemonPool("shared"); - - // The estimated number of wrappers is linear to the number of the number of external/OTel plugins - // - for an internal agent context, there will be at most one wrapper per external/OTel plugin. - // - for a context created by an external/OTel, we have one less wrapper required - approximateContextSize = coreConfiguration.getExternalPluginsCount() + 1; // +1 extra is for the OTel API plugin - - // sets the assertionsEnabled flag to true if indeed enabled - //noinspection AssertWithSideEffects - assert assertionsEnabled = true; - } - - @Override - @Nullable - public Transaction startRootTransaction(@Nullable ClassLoader initiatingClassLoader) { - return startRootTransaction(sampler, -1, initiatingClassLoader); - } - - @Override - @Nullable - public Transaction startRootTransaction(@Nullable ClassLoader initiatingClassLoader, long epochMicro) { - return startRootTransaction(sampler, epochMicro, initiatingClassLoader); - } - - @Override - @Nullable - public Transaction startRootTransaction(Sampler sampler, long epochMicros, @Nullable ClassLoader initiatingClassLoader) { - Transaction transaction = null; - if (isRunning()) { - transaction = createTransaction().startRoot(epochMicros, sampler); - afterTransactionStart(initiatingClassLoader, transaction); - } - return transaction; - } - - @Override - @Nullable - public Transaction startChildTransaction(@Nullable C headerCarrier, TextHeaderGetter textHeadersGetter, @Nullable ClassLoader initiatingClassLoader) { - return startChildTransaction(headerCarrier, textHeadersGetter, sampler, -1, initiatingClassLoader); - } - - @Override - @Nullable - public Transaction startChildTransaction(@Nullable C headerCarrier, TextHeaderGetter textHeadersGetter, @Nullable ClassLoader initiatingClassLoader, long epochMicros) { - return startChildTransaction(headerCarrier, textHeadersGetter, sampler, epochMicros, initiatingClassLoader); - } - - @Override - @Nullable - public Transaction startChildTransaction(@Nullable C headerCarrier, TextHeaderGetter textHeadersGetter, Sampler sampler, - long epochMicros, @Nullable ClassLoader initiatingClassLoader) { - Transaction transaction = null; - if (isRunning()) { - transaction = createTransaction().start(TraceContext.getFromTraceContextTextHeaders(), headerCarrier, - textHeadersGetter, epochMicros, sampler); - afterTransactionStart(initiatingClassLoader, transaction); - } - return transaction; } @Override - @Nullable - public Transaction startChildTransaction(@Nullable C headerCarrier, BinaryHeaderGetter binaryHeadersGetter, @Nullable ClassLoader initiatingClassLoader) { - return startChildTransaction(headerCarrier, binaryHeadersGetter, sampler, -1, initiatingClassLoader); + protected boolean isIgnoredException(Throwable e) { + return WildcardMatcher.isAnyMatch(coreConfiguration.getIgnoreExceptions(), e.getClass().getName()); } @Override - @Nullable - public Transaction startChildTransaction(@Nullable C headerCarrier, BinaryHeaderGetter binaryHeadersGetter, - Sampler sampler, long epochMicros, @Nullable ClassLoader initiatingClassLoader) { - Transaction transaction = null; - if (isRunning()) { - transaction = createTransaction().start(TraceContext.getFromTraceContextBinaryHeaders(), headerCarrier, - binaryHeadersGetter, epochMicros, sampler); - afterTransactionStart(initiatingClassLoader, transaction); - } - return transaction; - } - - private void afterTransactionStart(@Nullable ClassLoader initiatingClassLoader, Transaction transaction) { - if (logger.isDebugEnabled()) { - logger.debug("startTransaction {}", transaction); - if (logger.isTraceEnabled()) { - logger.trace("starting transaction at", - new RuntimeException("this exception is just used to record where the transaction has been started from")); - } - } - final ServiceInfo serviceInfo = getServiceInfoForClassLoader(initiatingClassLoader); - if (serviceInfo != null) { - transaction.getTraceContext().setServiceInfo(serviceInfo.getServiceName(), serviceInfo.getServiceVersion()); - } + protected boolean hasServiceName() { + return coreConfiguration.getServiceNameConfig().getUsedKey() != null; } public Transaction noopTransaction() { return createTransaction().startNoop(); } - private Transaction createTransaction() { - Transaction transaction = transactionPool.createInstance(); - while (transaction.getReferenceCount() != 0) { - logger.warn("Tried to start a transaction with a non-zero reference count {} {}", transaction.getReferenceCount(), transaction); - transaction = transactionPool.createInstance(); - } - return transaction; - } - - @Override - @Nullable - public Transaction currentTransaction() { - return activeStack.get().currentTransaction(); - } - - /** - * Starts a span with a given parent context. - *

- * This method makes it possible to start a span after the parent has already ended. - *

- * - * @param parentContext the trace context of the parent - * @return a new started span - */ - public Span startSpan(TraceContext.ChildContextCreator childContextCreator, T parentContext) { - return startSpan(childContextCreator, parentContext, -1); - } - - public Span startSpan(AbstractSpan parent, long epochMicros) { - return startSpan(TraceContext.fromParent(), parent, epochMicros); - } - - /** - * @param parentContext the trace context of the parent - * @param epochMicros the start timestamp of the span in microseconds after epoch - * @return a new started span - * @see #startSpan(TraceContext.ChildContextCreator, Object) - */ - public Span startSpan(TraceContext.ChildContextCreator childContextCreator, T parentContext, long epochMicros) { - return createSpan().start(childContextCreator, parentContext, epochMicros); - } - - private Span createSpan() { - Span span = spanPool.createInstance(); - while (span.getReferenceCount() != 0) { - logger.warn("Tried to start a span with a non-zero reference count {} {}", span.getReferenceCount(), span); - span = spanPool.createInstance(); - } - return span; - } - - @Override - public void captureAndReportException(@Nullable Throwable e, ClassLoader initiatingClassLoader) { - ErrorCapture errorCapture = captureException(System.currentTimeMillis() * 1000, e, getActive(), initiatingClassLoader); - if (errorCapture != null) { - errorCapture.end(); - } - } - - @Override - @Nullable - public String captureAndReportException(long epochMicros, @Nullable Throwable e, @Nullable AbstractSpan parent) { - String id = null; - ErrorCapture errorCapture = captureException(epochMicros, e, parent, null); - if (errorCapture != null) { - id = errorCapture.getTraceContext().getId().toString(); - errorCapture.end(); - } - return id; - } - - @Override - @Nullable - public ErrorCapture captureException(@Nullable Throwable e, @Nullable AbstractSpan parent, @Nullable ClassLoader initiatingClassLoader) { - return captureException(System.currentTimeMillis() * 1000, e, parent, initiatingClassLoader); - } - - @Nullable - private ErrorCapture captureException(long epochMicros, @Nullable Throwable e, @Nullable AbstractSpan parent, @Nullable ClassLoader initiatingClassLoader) { - if (!isRunning()) { - return null; - } - // note: if we add inheritance support for exception filtering, caching would be required for performance - if (e != null && !WildcardMatcher.isAnyMatch(coreConfiguration.getIgnoreExceptions(), e.getClass().getName())) { - ErrorCapture error = errorPool.createInstance(); - error.withTimestamp(epochMicros); - error.setException(e); - Transaction currentTransaction = currentTransaction(); - if (currentTransaction != null) { - if (currentTransaction.getNameForSerialization().length() > 0) { - error.setTransactionName(currentTransaction.getNameForSerialization()); - } - error.setTransactionType(currentTransaction.getType()); - error.setTransactionSampled(currentTransaction.isSampled()); - } - if (parent != null) { - error.asChildOf(parent); - // don't discard spans leading up to an error, otherwise they'd point to an invalid parent - parent.setNonDiscardable(); - } else { - error.getTraceContext().getId().setToRandomValue(); - ServiceInfo serviceInfo = getServiceInfoForClassLoader(initiatingClassLoader); - if (serviceInfo != null) { - error.getTraceContext().setServiceInfo(serviceInfo.getServiceName(), serviceInfo.getServiceVersion()); - } - } - return error; - } - return null; - } - public ConfigurationRegistry getConfigurationRegistry() { return configurationRegistry; } + @Override public T getConfig(Class configProvider) { return configurationRegistry.getConfig(configProvider); } + @Override public void endTransaction(Transaction transaction) { if (logger.isDebugEnabled()) { logger.debug("endTransaction {}", transaction); @@ -390,6 +231,7 @@ public void endTransaction(Transaction transaction) { } } + @Override public void endSpan(Span span) { if (logger.isDebugEnabled()) { logger.debug("endSpan {}", span); @@ -451,30 +293,12 @@ private void reportSpan(Span span) { reporter.report(span); } + @Override public void endError(ErrorCapture error) { reporter.report(error); } - public TraceContext createSpanLink() { - return spanLinkPool.createInstance(); - } - - public void recycle(Transaction transaction) { - transactionPool.recycle(transaction); - } - - public void recycle(Span span) { - spanPool.recycle(span); - } - - public void recycle(ErrorCapture error) { - errorPool.recycle(error); - } - - public void recycle(TraceContext traceContext) { - spanLinkPool.recycle(traceContext); - } - + @Override public synchronized void stop() { if (tracerState == TracerState.STOPPED) { // may happen if explicitly stopped in a unit test and executed again within a shutdown hook @@ -511,37 +335,6 @@ public Sampler getSampler() { return sampler; } - public ObjectPoolFactory getObjectPoolFactory() { - return objectPoolFactory; - } - - @Override - @Nullable - public AbstractSpan getActive() { - ElasticContext active = currentContext(); - return active != null ? active.getSpan() : null; - } - - @Nullable - @Override - public Span getActiveSpan() { - final AbstractSpan active = getActive(); - if (active instanceof Span) { - return (Span) active; - } - return null; - } - - @Nullable - @Override - public Span getActiveExitSpan() { - final Span span = getActiveSpan(); - if (span != null && span.isExit()) { - return span; - } - return null; - } - public void registerSpanListener(ActivationListener activationListener) { this.activationListeners.add(activationListener); } @@ -723,14 +516,6 @@ public T getLifecycleListener(Class listenerClass) { return null; } - /** - * @return the currently active context, {@literal null} if there is none. - */ - @Nullable - public ElasticContext currentContext() { - return activeStack.get().currentContext(); - } - /** * Lazily wraps the currently active context if required, wrapper instance is cached with wrapperClass as key. * Wrapping is transparently handled by {@link #currentContext()}. @@ -744,33 +529,17 @@ public > T wrapActiveContextIfRequired(Class wrap return activeStack.get().wrapActiveContextIfRequired(wrapperClass, wrapFunction, approximateContextSize); } + @Override public void activate(ElasticContext context) { activeStack.get().activate(context, activationListeners); } - public Scope activateInScope(final ElasticContext context) { - // already in scope - if (currentContext() == context) { - return Scope.NoopScope.INSTANCE; - } - context.activate(); - - if (context instanceof Scope) { - // we can take shortcut and avoid creating a separate object - return (Scope) context; - } - return new Scope() { - @Override - public void close() { - context.deactivate(); - } - }; - } - + @Override public void deactivate(ElasticContext context) { activeStack.get().deactivate(context, activationListeners, assertionsEnabled); } + @Override public MetricRegistry getMetricRegistry() { return metricRegistry; } diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/ElasticApmTracerBuilder.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/ElasticApmTracerBuilder.java index cd43e22600f..b132633f08c 100644 --- a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/ElasticApmTracerBuilder.java +++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/ElasticApmTracerBuilder.java @@ -99,7 +99,7 @@ public ElasticApmTracerBuilder(List configSources) { this.ephemeralId = UUID.randomUUID().toString(); LoggingConfiguration.init(configSources, ephemeralId); logger = LoggerFactory.getLogger(getClass()); - objectPoolFactory = new ObjectPoolFactory(); + objectPoolFactory = ObjectPoolFactory.INSTANCE; extraLifecycleListeners = new ArrayList<>(); } @@ -182,7 +182,7 @@ private ElasticApmTracer build(boolean startTracer) { reporter = new ReporterFactory().createReporter(configurationRegistry, apmServerClient, metaDataFuture, healthMetrics); } - ElasticApmTracer tracer = new ElasticApmTracer(configurationRegistry, metricRegistry, reporter, objectPoolFactory, apmServerClient, ephemeralId, metaDataFuture); + ElasticApmTracer tracer = ElasticApmTracer.of(configurationRegistry, metricRegistry, reporter, objectPoolFactory, apmServerClient, ephemeralId, metaDataFuture); lifecycleListeners.addAll(DependencyInjectingServiceLoader.load(LifecycleListener.class, tracer)); lifecycleListeners.addAll(extraLifecycleListeners); tracer.init(lifecycleListeners); diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/GlobalTracer.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/GlobalTracer.java index 017be270c83..b8821fc0002 100644 --- a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/GlobalTracer.java +++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/GlobalTracer.java @@ -26,8 +26,10 @@ 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.agent.objectpool.ObjectPoolFactory; import co.elastic.apm.agent.util.PrivilegedActionUtils; import co.elastic.apm.agent.util.VersionUtils; +import org.stagemonitor.configuration.ConfigurationOptionProvider; import javax.annotation.Nullable; import java.io.File; @@ -51,14 +53,23 @@ public static Tracer get() { } @Nullable - public static ElasticApmTracer getTracerImpl() { + public static T get(Class type) { Tracer tracer = INSTANCE.tracer; - if (tracer instanceof ElasticApmTracer) { - return ((ElasticApmTracer) 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()); + } + + @Nullable + public static ElasticApmTracer getTracerImpl() { + return get(ElasticApmTracer.class); + } + public static ElasticApmTracer requireTracerImpl() { return Objects.requireNonNull(getTracerImpl(), "Registered tracer is not an instance of ElasticApmTracer"); } @@ -231,4 +242,39 @@ public boolean isRunning() { public Span createExitChildSpan() { return tracer.createExitChildSpan(); } + + @Override + public void recycle(Transaction transaction) { + tracer.recycle(transaction); + } + + @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 void recycle(ErrorCapture errorCapture) { + tracer.recycle(errorCapture); + } } diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/MetricsAwareTracer.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/MetricsAwareTracer.java new file mode 100644 index 00000000000..f5792d89987 --- /dev/null +++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/MetricsAwareTracer.java @@ -0,0 +1,26 @@ +/* + * 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.agent.impl; + +import co.elastic.apm.agent.metrics.MetricRegistry; + +public interface MetricsAwareTracer extends SpanAwareTracer { + + MetricRegistry getMetricRegistry(); +} diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/NoopTracer.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/NoopTracer.java index b0e35cdf76e..49f58d15651 100644 --- a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/NoopTracer.java +++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/NoopTracer.java @@ -26,6 +26,8 @@ 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.agent.objectpool.ObjectPoolFactory; +import org.stagemonitor.configuration.ConfigurationOptionProvider; import javax.annotation.Nullable; @@ -154,4 +156,29 @@ public boolean isRunning() { public Span createExitChildSpan() { return null; } + + @Override + public void recycle(Transaction transaction) { } + + @Override + public void recycle(ErrorCapture errorCapture) { } + + @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; + } } diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/SpanAwareTracer.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/SpanAwareTracer.java new file mode 100644 index 00000000000..cbb087fcded --- /dev/null +++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/SpanAwareTracer.java @@ -0,0 +1,41 @@ +/* + * 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.agent.impl; + +import co.elastic.apm.agent.impl.transaction.AbstractSpan; +import co.elastic.apm.agent.impl.transaction.ElasticContext; +import co.elastic.apm.agent.impl.transaction.Span; +import co.elastic.apm.agent.impl.transaction.TraceContext; + +public interface SpanAwareTracer extends Tracer { + + TraceContext createSpanLink(); + + void recycle(TraceContext context); + + void recycle(Span span); + + Span startSpan(AbstractSpan parent, long epochMicros); + + void activate(ElasticContext context); + + void deactivate(ElasticContext context); + + Scope activateInScope(ElasticContext context); +} 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 c4b23583b82..904f26c8a88 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 @@ -27,6 +27,8 @@ 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.agent.objectpool.ObjectPoolFactory; +import org.stagemonitor.configuration.ConfigurationOptionProvider; import javax.annotation.Nullable; @@ -151,8 +153,6 @@ Transaction startChildTransaction(@Nullable C headerCarrier, BinaryHeaderGet @Nullable Span getActiveExitSpan(); - TracerState getState(); - @Nullable ServiceInfo getServiceInfoForClassLoader(@Nullable ClassLoader classLoader); @@ -176,9 +176,25 @@ Transaction startChildTransaction(@Nullable C headerCarrier, BinaryHeaderGet boolean isRunning(); + TracerState getState(); + @Nullable Span createExitChildSpan(); + void recycle(Transaction transaction); + + void recycle(ErrorCapture errorCapture); + + void endSpan(Span span); + + void endTransaction(Transaction transaction); + + void endError(ErrorCapture errorCapture); + + T getConfig(Class configuration); + + ObjectPoolFactory getObjectPoolFactory(); + /** * An enumeration used to represent the current tracer state. */ 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 2f1a503a9b8..927073d15ed 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 @@ -19,7 +19,7 @@ package co.elastic.apm.agent.impl.error; import co.elastic.apm.agent.configuration.CoreConfiguration; -import co.elastic.apm.agent.impl.ElasticApmTracer; +import co.elastic.apm.agent.impl.Tracer; import co.elastic.apm.agent.impl.context.TransactionContext; import co.elastic.apm.agent.impl.stacktrace.StacktraceConfiguration; import co.elastic.apm.agent.impl.transaction.AbstractSpan; @@ -52,7 +52,7 @@ public class ErrorCapture implements Recyclable { * Any arbitrary contextual information regarding the event, captured by the agent, optionally provided by the user */ private final TransactionContext context = new TransactionContext(); - private final ElasticApmTracer tracer; + private final Tracer tracer; /** * Information about the originally thrown error. */ @@ -71,7 +71,7 @@ public class ErrorCapture implements Recyclable { private final StringBuilder culprit = new StringBuilder(); - public ErrorCapture(ElasticApmTracer tracer) { + public ErrorCapture(Tracer tracer) { this.tracer = tracer; traceContext = TraceContext.with128BitId(this.tracer); } 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 4ea3d06eb38..1be9e7c70d3 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 @@ -20,8 +20,8 @@ import co.elastic.apm.agent.collections.LongList; import co.elastic.apm.agent.configuration.CoreConfiguration; -import co.elastic.apm.agent.impl.ElasticApmTracer; import co.elastic.apm.agent.impl.Scope; +import co.elastic.apm.agent.impl.SpanAwareTracer; import co.elastic.apm.agent.impl.context.AbstractContext; import co.elastic.apm.agent.common.util.WildcardMatcher; import co.elastic.apm.agent.objectpool.Recyclable; @@ -56,7 +56,7 @@ public abstract class AbstractSpan> implements Recycla */ protected final StringBuilder name = new StringBuilder(); protected final boolean collectBreakdownMetrics; - protected final ElasticApmTracer tracer; + protected final SpanAwareTracer tracer; protected final AtomicLong timestamp = new AtomicLong(); protected final AtomicLong endTimestamp = new AtomicLong(); @@ -210,7 +210,7 @@ public long getDuration() { } } - public AbstractSpan(ElasticApmTracer tracer) { + public AbstractSpan(SpanAwareTracer tracer) { this.tracer = tracer; traceContext = TraceContext.with64BitId(this.tracer); boolean selfTimeCollectionEnabled = !WildcardMatcher.isAnyMatch(tracer.getConfig(ReporterConfiguration.class).getDisableMetrics(), "span.self_time"); diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/MetricsAwareTransaction.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/MetricsAwareTransaction.java new file mode 100644 index 00000000000..4a17108a99a --- /dev/null +++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/MetricsAwareTransaction.java @@ -0,0 +1,91 @@ +/* + * 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.agent.impl.transaction; + +import co.elastic.apm.agent.impl.MetricsAwareTracer; +import co.elastic.apm.agent.metrics.Labels; +import co.elastic.apm.agent.metrics.MetricRegistry; +import co.elastic.apm.agent.metrics.Timer; +import co.elastic.apm.agent.util.KeyListConcurrentHashMap; + +import java.util.List; + +public class MetricsAwareTransaction extends Transaction { + + private static final ThreadLocal labelsThreadLocal = new ThreadLocal() { + @Override + protected Labels.Mutable initialValue() { + return Labels.Mutable.of(); + } + }; + + public MetricsAwareTransaction(MetricsAwareTracer tracer) { + super(tracer); + } + + protected void trackMetrics() { + try { + phaser.readerLock(); + phaser.flipPhase(); + // timers are guaranteed to be stable now + // - no concurrent updates possible as finished is true + // - no other thread is running the incrementTimer method, + // as flipPhase only returns when all threads have exited that method + + final String type = getType(); + if (type == null) { + return; + } + final Labels.Mutable labels = labelsThreadLocal.get(); + labels.resetState(); + labels.serviceName(getTraceContext().getServiceName()) + .serviceVersion(getTraceContext().getServiceVersion()) + .transactionName(name) + .transactionType(type); // TODO: + final MetricRegistry metricRegistry = ((MetricsAwareTracer) tracer).getMetricRegistry(); + long criticalValueAtEnter = metricRegistry.writerCriticalSectionEnter(); + try { + if (collectBreakdownMetrics) { + List types = timerBySpanTypeAndSubtype.keyList(); + for (int i = 0; i < types.size(); i++) { + String spanType = types.get(i); + KeyListConcurrentHashMap timerBySubtype = timerBySpanTypeAndSubtype.get(spanType); + List subtypes = timerBySubtype.keyList(); + for (int j = 0; j < subtypes.size(); j++) { + String subtype = subtypes.get(j); + final Timer timer = timerBySubtype.get(subtype); + if (timer.getCount() > 0) { + if (subtype.equals("")) { + subtype = null; + } + labels.spanType(spanType).spanSubType(subtype); + metricRegistry.updateTimer("span.self_time", labels, timer.getTotalTimeUs(), timer.getCount()); + timer.resetState(); + } + } + } + } + } finally { + metricRegistry.writerCriticalSectionExit(criticalValueAtEnter); + } + } finally { + phaser.readerUnlock(); + } + } +} 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 9ad0f0a6829..fda687afbd3 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 @@ -20,6 +20,7 @@ import co.elastic.apm.agent.configuration.CoreConfiguration; import co.elastic.apm.agent.impl.ElasticApmTracer; +import co.elastic.apm.agent.impl.SpanAwareTracer; import co.elastic.apm.agent.impl.context.Db; import co.elastic.apm.agent.impl.context.Message; import co.elastic.apm.agent.impl.context.ServiceTarget; @@ -82,7 +83,7 @@ public void setNonDiscardable() { } } - public Span(ElasticApmTracer tracer) { + public Span(SpanAwareTracer tracer) { super(tracer); } 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 bfd849a4e72..75e474fe9c7 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,6 +20,7 @@ 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; @@ -209,7 +210,7 @@ public static void copyTraceContextTextHeaders(S source, TextHeaderGetter // ???????0 -> not recorded private static final byte FLAG_RECORDED = 0b0000_0001; private final Id traceId = Id.new128BitId(); - private final ElasticApmTracer tracer; + private final Tracer tracer; private final Id id; private final Id parentId = Id.new64BitId(); private final Id transactionId = Id.new64BitId(); @@ -234,7 +235,7 @@ public static void copyTraceContextTextHeaders(S source, TextHeaderGetter @Nullable private String serviceVersion; - private TraceContext(ElasticApmTracer tracer, Id id) { + private TraceContext(Tracer tracer, Id id) { coreConfiguration = tracer.getConfig(CoreConfiguration.class); traceState = new TraceState(); traceState.setSizeLimit(coreConfiguration.getTracestateSizeLimit()); @@ -249,7 +250,7 @@ private TraceContext(ElasticApmTracer tracer, Id id) { *

* @param tracer a valid tracer */ - public static TraceContext with64BitId(ElasticApmTracer tracer) { + public static TraceContext with64BitId(Tracer tracer) { return new TraceContext(tracer, Id.new64BitId()); } @@ -260,7 +261,7 @@ public static TraceContext with64BitId(ElasticApmTracer tracer) { * * @param tracer a valid tracer */ - public static TraceContext with128BitId(ElasticApmTracer tracer) { + public static TraceContext with128BitId(Tracer tracer) { return new TraceContext(tracer, Id.new128BitId()); } @@ -701,11 +702,18 @@ public String getServiceVersion() { } public Span createSpan() { - return tracer.startSpan(fromParentContext(), this); + return requireTracerImpl().startSpan(fromParentContext(), this); } public Span createSpan(long epochMicros) { - return tracer.startSpan(fromParentContext(), this, epochMicros); + return requireTracerImpl().startSpan(fromParentContext(), this, epochMicros); + } + + private ElasticApmTracer requireTracerImpl() { + if (tracer instanceof ElasticApmTracer) { + return (ElasticApmTracer) tracer; + } + throw new IllegalStateException("Can only start spans from elastic APM tracer"); } @Override diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/Transaction.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/Transaction.java index 868c23a119c..29f792cd6bb 100644 --- a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/Transaction.java +++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/Transaction.java @@ -20,20 +20,17 @@ import co.elastic.apm.agent.configuration.CoreConfiguration; import co.elastic.apm.agent.configuration.SpanConfiguration; -import co.elastic.apm.agent.impl.ElasticApmTracer; +import co.elastic.apm.agent.impl.SpanAwareTracer; import co.elastic.apm.agent.impl.context.Response; import co.elastic.apm.agent.impl.context.TransactionContext; import co.elastic.apm.agent.impl.context.web.ResultUtil; import co.elastic.apm.agent.impl.sampling.Sampler; import co.elastic.apm.agent.common.util.WildcardMatcher; -import co.elastic.apm.agent.metrics.Labels; -import co.elastic.apm.agent.metrics.MetricRegistry; import co.elastic.apm.agent.metrics.Timer; import co.elastic.apm.agent.util.KeyListConcurrentHashMap; import org.HdrHistogram.WriterReaderPhaser; import javax.annotation.Nullable; -import java.util.List; import static co.elastic.apm.agent.configuration.CoreConfiguration.TraceContinuationStrategy.RESTART; import static co.elastic.apm.agent.configuration.CoreConfiguration.TraceContinuationStrategy.RESTART_EXTERNAL; @@ -43,13 +40,6 @@ */ public class Transaction extends AbstractSpan { - private static final ThreadLocal labelsThreadLocal = new ThreadLocal() { - @Override - protected Labels.Mutable initialValue() { - return Labels.Mutable.of(); - } - }; - public static final String TYPE_REQUEST = "request"; /** @@ -69,8 +59,8 @@ protected Labels.Mutable initialValue() { * That is done in order to minimize {@link java.util.Map.Entry} garbage. *

*/ - private final KeyListConcurrentHashMap> timerBySpanTypeAndSubtype = new KeyListConcurrentHashMap<>(); - private final WriterReaderPhaser phaser = new WriterReaderPhaser(); + final KeyListConcurrentHashMap> timerBySpanTypeAndSubtype = new KeyListConcurrentHashMap<>(); + final WriterReaderPhaser phaser = new WriterReaderPhaser(); private final CoreConfiguration coreConfig; private final SpanConfiguration spanConfig; @@ -114,7 +104,7 @@ public Transaction getTransaction() { return this; } - public Transaction(ElasticApmTracer tracer) { + public Transaction(SpanAwareTracer tracer) { super(tracer); coreConfig = tracer.getConfig(CoreConfiguration.class); spanConfig = tracer.getConfig(SpanConfiguration.class); @@ -457,53 +447,5 @@ void incrementTimer(@Nullable String type, @Nullable String subtype, long durati } } - private void trackMetrics() { - try { - phaser.readerLock(); - phaser.flipPhase(); - // timers are guaranteed to be stable now - // - no concurrent updates possible as finished is true - // - no other thread is running the incrementTimer method, - // as flipPhase only returns when all threads have exited that method - - final String type = getType(); - if (type == null) { - return; - } - final Labels.Mutable labels = labelsThreadLocal.get(); - labels.resetState(); - labels.serviceName(getTraceContext().getServiceName()) - .serviceVersion(getTraceContext().getServiceVersion()) - .transactionName(name) - .transactionType(type); - final MetricRegistry metricRegistry = tracer.getMetricRegistry(); - long criticalValueAtEnter = metricRegistry.writerCriticalSectionEnter(); - try { - if (collectBreakdownMetrics) { - List types = timerBySpanTypeAndSubtype.keyList(); - for (int i = 0; i < types.size(); i++) { - String spanType = types.get(i); - KeyListConcurrentHashMap timerBySubtype = timerBySpanTypeAndSubtype.get(spanType); - List subtypes = timerBySubtype.keyList(); - for (int j = 0; j < subtypes.size(); j++) { - String subtype = subtypes.get(j); - final Timer timer = timerBySubtype.get(subtype); - if (timer.getCount() > 0) { - if (subtype.equals("")) { - subtype = null; - } - labels.spanType(spanType).spanSubType(subtype); - metricRegistry.updateTimer("span.self_time", labels, timer.getTotalTimeUs(), timer.getCount()); - timer.resetState(); - } - } - } - } - } finally { - metricRegistry.writerCriticalSectionExit(criticalValueAtEnter); - } - } finally { - phaser.readerUnlock(); - } - } + protected void trackMetrics() { } } diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/objectpool/ObjectPoolFactory.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/objectpool/ObjectPoolFactory.java index 4939117fb28..f39f1d1e2f8 100644 --- a/apm-agent-core/src/main/java/co/elastic/apm/agent/objectpool/ObjectPoolFactory.java +++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/objectpool/ObjectPoolFactory.java @@ -18,8 +18,10 @@ */ package co.elastic.apm.agent.objectpool; -import co.elastic.apm.agent.impl.ElasticApmTracer; +import co.elastic.apm.agent.impl.MetricsAwareTracer; +import co.elastic.apm.agent.impl.SpanAwareTracer; import co.elastic.apm.agent.impl.error.ErrorCapture; +import co.elastic.apm.agent.impl.transaction.MetricsAwareTransaction; import co.elastic.apm.agent.impl.transaction.Span; import co.elastic.apm.agent.impl.transaction.TraceContext; import co.elastic.apm.agent.impl.transaction.Transaction; @@ -28,20 +30,32 @@ public class ObjectPoolFactory { + public static final ObjectPoolFactory INSTANCE = new ObjectPoolFactory(); + public ObjectPool createRecyclableObjectPool(int maxCapacity, Allocator allocator) { return QueueBasedObjectPool.ofRecyclable(new MpmcAtomicArrayQueue((maxCapacity)), false, allocator); } - public ObjectPool createTransactionPool(int maxCapacity, final ElasticApmTracer tracer) { - return createRecyclableObjectPool(maxCapacity, new Allocator() { - @Override - public Transaction createInstance() { - return new Transaction(tracer); - } - }); + public ObjectPool createTransactionPool(int maxCapacity, final SpanAwareTracer tracer) { + if (tracer instanceof MetricsAwareTracer) { + final MetricsAwareTracer cast = (MetricsAwareTracer) tracer; + return createRecyclableObjectPool(maxCapacity, new Allocator() { + @Override + public Transaction createInstance() { + return new MetricsAwareTransaction(cast); + } + }); + } else { + return createRecyclableObjectPool(maxCapacity, new Allocator() { + @Override + public Transaction createInstance() { + return new Transaction(tracer); + } + }); + } } - public ObjectPool createSpanPool(int maxCapacity, final ElasticApmTracer tracer) { + public ObjectPool createSpanPool(int maxCapacity, final SpanAwareTracer tracer) { return createRecyclableObjectPool(maxCapacity, new Allocator() { @Override public Span createInstance() { @@ -50,7 +64,7 @@ public Span createInstance() { }); } - public ObjectPool createErrorPool(int maxCapacity, final ElasticApmTracer tracer) { + public ObjectPool createErrorPool(int maxCapacity, final SpanAwareTracer tracer) { return createRecyclableObjectPool(maxCapacity, new Allocator() { @Override public ErrorCapture createInstance() { @@ -59,7 +73,7 @@ public ErrorCapture createInstance() { }); } - public ObjectPool createSpanLinkPool(int maxCapacity, final ElasticApmTracer tracer) { + public ObjectPool createSpanLinkPool(int maxCapacity, final SpanAwareTracer tracer) { return createRecyclableObjectPool(maxCapacity, new Allocator() { @Override public TraceContext createInstance() { diff --git a/apm-agent-core/src/test/java/co/elastic/apm/agent/objectpool/TestObjectPoolFactory.java b/apm-agent-core/src/test/java/co/elastic/apm/agent/objectpool/TestObjectPoolFactory.java index bd3363dc2ab..2c48e38ce76 100644 --- a/apm-agent-core/src/test/java/co/elastic/apm/agent/objectpool/TestObjectPoolFactory.java +++ b/apm-agent-core/src/test/java/co/elastic/apm/agent/objectpool/TestObjectPoolFactory.java @@ -18,7 +18,7 @@ */ package co.elastic.apm.agent.objectpool; -import co.elastic.apm.agent.impl.ElasticApmTracer; +import co.elastic.apm.agent.impl.SpanAwareTracer; import co.elastic.apm.agent.impl.error.ErrorCapture; import co.elastic.apm.agent.impl.transaction.Span; import co.elastic.apm.agent.impl.transaction.TraceContext; @@ -93,25 +93,25 @@ public void reset() { } @Override - public ObjectPool createTransactionPool(int maxCapacity, ElasticApmTracer tracer) { + public ObjectPool createTransactionPool(int maxCapacity, SpanAwareTracer tracer) { transactionPool = (BookkeeperObjectPool) super.createTransactionPool(maxCapacity, tracer); return transactionPool; } @Override - public ObjectPool createSpanPool(int maxCapacity, ElasticApmTracer tracer) { + public ObjectPool createSpanPool(int maxCapacity, SpanAwareTracer tracer) { spanPool = (BookkeeperObjectPool) super.createSpanPool(maxCapacity, tracer); return spanPool; } @Override - public ObjectPool createErrorPool(int maxCapacity, ElasticApmTracer tracer) { + public ObjectPool createErrorPool(int maxCapacity, SpanAwareTracer tracer) { errorPool = (BookkeeperObjectPool) super.createErrorPool(maxCapacity, tracer); return errorPool; } @Override - public ObjectPool createSpanLinkPool(int maxCapacity, ElasticApmTracer tracer) { + public ObjectPool createSpanLinkPool(int maxCapacity, SpanAwareTracer tracer) { spanLinksPool = (BookkeeperObjectPool) super.createSpanLinkPool(maxCapacity, tracer); return spanLinksPool; } 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 f6f051fe2dd..39dd0b4b5cd 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 @@ -38,7 +38,7 @@ public class ApacheHttpAsyncClientHelper { private final ObjectPool> futureCallbackWrapperObjectPool; public ApacheHttpAsyncClientHelper() { - ObjectPoolFactory factory = GlobalTracer.requireTracerImpl().getObjectPoolFactory(); + ObjectPoolFactory factory = GlobalTracer.get().getObjectPoolFactory(); requestProducerWrapperObjectPool = factory.createRecyclableObjectPool(MAX_POOLED_ELEMENTS, new RequestProducerWrapperAllocator()); futureCallbackWrapperObjectPool = factory.createRecyclableObjectPool(MAX_POOLED_ELEMENTS, new FutureCallbackWrapperAllocator()); } 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 b3bc82c4ce7..acd6ad0e2c2 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 @@ -105,11 +105,6 @@ public static void onMethodExit(@Advice.Enter @Nullable Object span, } } - @Override - public ElementMatcher.Junction getClassLoaderMatcher() { - return classLoaderCanLoadClass("co.elastic.apm.api.CaptureSpan"); - } - @Override public ElementMatcher getTypeMatcher() { return isInAnyPackage(stacktraceConfig.getApplicationPackages(), ElementMatchers.none()) 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 96b4a69fab1..03a822a18c4 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,7 +22,7 @@ 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.ElasticApmTracer; +import co.elastic.apm.agent.impl.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; @@ -40,25 +40,19 @@ 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; +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.agent.pluginapi.ElasticApmApiInstrumentation.PUBLIC_API_INSTRUMENTATION_GROUP; import static co.elastic.apm.agent.pluginapi.Utils.FRAMEWORK_NAME; -import static net.bytebuddy.matcher.ElementMatchers.declaresMethod; -import static net.bytebuddy.matcher.ElementMatchers.isAnnotatedWith; -import static net.bytebuddy.matcher.ElementMatchers.named; -import static net.bytebuddy.matcher.ElementMatchers.not; +import static net.bytebuddy.matcher.ElementMatchers.*; public class TracedInstrumentation extends TracerAwareInstrumentation { private final CoreConfiguration coreConfig; private final StacktraceConfiguration stacktraceConfig; - public TracedInstrumentation(ElasticApmTracer tracer) { + public TracedInstrumentation(Tracer tracer) { coreConfig = tracer.getConfig(CoreConfiguration.class); stacktraceConfig = tracer.getConfig(StacktraceConfiguration.class); } diff --git a/apm-agent-plugins/apm-api-plugin/src/test/java/co/elastic/apm/api/AnnotationInheritanceTest.java b/apm-agent-plugins/apm-api-plugin/src/test/java/co/elastic/apm/api/AnnotationInheritanceTest.java index 61cb5084c41..75049c35b19 100644 --- a/apm-agent-plugins/apm-api-plugin/src/test/java/co/elastic/apm/api/AnnotationInheritanceTest.java +++ b/apm-agent-plugins/apm-api-plugin/src/test/java/co/elastic/apm/api/AnnotationInheritanceTest.java @@ -23,6 +23,7 @@ import co.elastic.apm.agent.bci.ElasticApmAgent; import co.elastic.apm.agent.configuration.CoreConfiguration; import co.elastic.apm.agent.impl.ElasticApmTracer; +import co.elastic.apm.agent.impl.Tracer; import net.bytebuddy.agent.ByteBuddyAgent; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterEach; 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 170267d3dfc..bd7ca07b3d3 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,7 +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.ElasticApmTracer; +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; @@ -174,7 +174,7 @@ public ElementMatcher getMethodMatcher() { public static class AsyncHandlerOnCompletedInstrumentation extends AbstractAsyncHandlerInstrumentation { - public AsyncHandlerOnCompletedInstrumentation(ElasticApmTracer tracer) { + public AsyncHandlerOnCompletedInstrumentation(Tracer tracer) { super(named("onCompleted").and(takesArguments(0))); } @@ -198,7 +198,7 @@ public static void onMethodExit(@Nullable @Advice.Enter Object spanObj) { public static class AsyncHandlerOnThrowableInstrumentation extends AbstractAsyncHandlerInstrumentation { - public AsyncHandlerOnThrowableInstrumentation(ElasticApmTracer tracer) { + public AsyncHandlerOnThrowableInstrumentation(Tracer tracer) { super(named("onThrowable").and(takesArguments(Throwable.class))); } @@ -225,7 +225,7 @@ public static void onMethodExit(@Nullable @Advice.Enter Object spanObj, @Advice. public static class AsyncHandlerOnStatusReceivedInstrumentation extends AbstractAsyncHandlerInstrumentation { - public AsyncHandlerOnStatusReceivedInstrumentation(ElasticApmTracer tracer) { + public AsyncHandlerOnStatusReceivedInstrumentation(Tracer tracer) { super(named("onStatusReceived").and(takesArgument(0, named("org.asynchttpclient.HttpResponseStatus")))); } @@ -249,7 +249,7 @@ public static void onMethodExit(@Nullable @Advice.Enter Object spanObj, @Advice. public static class StreamedAsyncHandlerOnStreamInstrumentation extends AbstractAsyncHandlerInstrumentation { - public StreamedAsyncHandlerOnStreamInstrumentation(ElasticApmTracer tracer) { + public StreamedAsyncHandlerOnStreamInstrumentation(Tracer tracer) { super(named("onStream").and(takesArgument(0, named("org.reactivestreams.Publisher")))); } 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 ba6f86bfa8f..d7fa48bd2f8 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,8 +19,8 @@ package co.elastic.apm.agent.awssdk.v1.helper; import co.elastic.apm.agent.awssdk.common.AbstractDynamoDBInstrumentationHelper; -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.transaction.Span; import com.amazonaws.AmazonWebServiceRequest; import com.amazonaws.Request; @@ -31,13 +31,13 @@ public class DynamoDbHelper extends AbstractDynamoDBInstrumentationHelper, ExecutionContext> { - private static final DynamoDbHelper INSTANCE = new DynamoDbHelper(GlobalTracer.requireTracerImpl()); + private static final DynamoDbHelper INSTANCE = new DynamoDbHelper(GlobalTracer.get()); public static DynamoDbHelper getInstance() { return INSTANCE; } - public DynamoDbHelper(ElasticApmTracer tracer) { + public DynamoDbHelper(Tracer tracer) { super(tracer, SdkV1DataSource.getInstance()); } 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 178c09ab917..c44d5a8968d 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.ElasticApmTracer; import co.elastic.apm.agent.impl.GlobalTracer; +import co.elastic.apm.agent.impl.Tracer; import com.amazonaws.Request; import com.amazonaws.http.ExecutionContext; @@ -28,13 +28,13 @@ public class S3Helper extends AbstractS3InstrumentationHelper, ExecutionContext> { - private static final S3Helper INSTANCE = new S3Helper(GlobalTracer.requireTracerImpl()); + private static final S3Helper INSTANCE = new S3Helper(GlobalTracer.get()); public static S3Helper getInstance() { return INSTANCE; } - public S3Helper(ElasticApmTracer tracer) { + public S3Helper(Tracer tracer) { super(tracer, SdkV1DataSource.getInstance()); } } 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 4abd688d61f..53856d4817f 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,8 +21,8 @@ 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.ElasticApmTracer; 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; @@ -46,13 +46,13 @@ public class SQSHelper extends AbstractSQSInstrumentationHelper, ExecutionContext, Message> implements TextHeaderSetter> { - private static final SQSHelper INSTANCE = new SQSHelper(GlobalTracer.requireTracerImpl()); + private static final SQSHelper INSTANCE = new SQSHelper(GlobalTracer.get()); public static SQSHelper getInstance() { return INSTANCE; } - protected SQSHelper(ElasticApmTracer tracer) { + protected SQSHelper(Tracer tracer) { super(tracer, SdkV1DataSource.getInstance()); } 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 033b57aea01..3b260f6eb4f 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,13 +20,13 @@ import co.elastic.apm.agent.awssdk.common.AbstractMessageIteratorWrapper; import co.elastic.apm.agent.awssdk.v1.helper.SQSHelper; -import co.elastic.apm.agent.impl.ElasticApmTracer; +import co.elastic.apm.agent.impl.Tracer; import com.amazonaws.services.sqs.model.Message; import java.util.Iterator; class MessageIteratorWrapper extends AbstractMessageIteratorWrapper { - public MessageIteratorWrapper(Iterator delegate, ElasticApmTracer tracer, String queueName) { + public MessageIteratorWrapper(Iterator delegate, Tracer tracer, String queueName) { super(delegate, tracer, queueName, SQSHelper.getInstance(), SQSHelper.getInstance()); } } 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 9bf1b83dcb4..f50ac61c279 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.ElasticApmTracer; +import co.elastic.apm.agent.impl.Tracer; import com.amazonaws.services.sqs.model.Message; import java.util.Iterator; @@ -28,7 +28,7 @@ public class MessageListWrapper extends AbstractMessageListWrapper { - public MessageListWrapper(List delegate, ElasticApmTracer tracer, String queueName) { + public MessageListWrapper(List delegate, Tracer tracer, String queueName) { super(delegate, tracer, queueName, SQSHelper.getInstance(), SQSHelper.getInstance()); } 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 060da9eeb11..013a0cf43c3 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.ElasticApmTracer; +import co.elastic.apm.agent.impl.Tracer; import com.amazonaws.services.sqs.model.Message; import com.amazonaws.services.sqs.model.ReceiveMessageResult; @@ -27,12 +27,12 @@ public class ReceiveMessageResultWrapper extends ReceiveMessageResult { private final ReceiveMessageResult delegate; - private final ElasticApmTracer tracer; + private final Tracer tracer; private final String queueName; private final MessageListWrapper listWrapper; - public ReceiveMessageResultWrapper(ReceiveMessageResult delegate, ElasticApmTracer tracer, String queueName) { + public ReceiveMessageResultWrapper(ReceiveMessageResult delegate, Tracer tracer, String queueName) { this.delegate = delegate; this.tracer = tracer; this.queueName = queueName; diff --git a/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-1-plugin/src/test/java/co/elastic/apm/agent/awssdk/v1/SQSJmsClientIT.java b/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-1-plugin/src/test/java/co/elastic/apm/agent/awssdk/v1/SQSJmsClientIT.java index c78d443339d..c195e485d82 100644 --- a/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-1-plugin/src/test/java/co/elastic/apm/agent/awssdk/v1/SQSJmsClientIT.java +++ b/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-1-plugin/src/test/java/co/elastic/apm/agent/awssdk/v1/SQSJmsClientIT.java @@ -296,7 +296,7 @@ static class SQSListener implements MessageListener { @Override public void onMessage(Message message) { try { - Tracer tracer = GlobalTracer.getTracerImpl(); + Tracer tracer = GlobalTracer.get(); assertThat(tracer).isNotNull(); AbstractSpan parent = tracer.getActive(); assertThat(parent).isNotNull(); 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 a98e41cc182..214577487d0 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.ElasticApmTracer; import co.elastic.apm.agent.impl.GlobalTracer; +import co.elastic.apm.agent.impl.Tracer; import software.amazon.awssdk.core.SdkRequest; import software.amazon.awssdk.core.http.ExecutionContext; @@ -28,13 +28,13 @@ public class DynamoDbHelper extends AbstractDynamoDBInstrumentationHelper { - private static final DynamoDbHelper INSTANCE = new DynamoDbHelper(GlobalTracer.requireTracerImpl()); + private static final DynamoDbHelper INSTANCE = new DynamoDbHelper(GlobalTracer.get()); public static DynamoDbHelper getInstance() { return INSTANCE; } - public DynamoDbHelper(ElasticApmTracer tracer) { + public DynamoDbHelper(Tracer tracer) { super(tracer, SdkV2DataSource.getInstance()); } 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 72d21a328f8..f805761f048 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,22 +19,20 @@ package co.elastic.apm.agent.awssdk.v2.helper; import co.elastic.apm.agent.awssdk.common.AbstractS3InstrumentationHelper; -import co.elastic.apm.agent.impl.ElasticApmTracer; import co.elastic.apm.agent.impl.GlobalTracer; +import co.elastic.apm.agent.impl.Tracer; import software.amazon.awssdk.core.SdkRequest; import software.amazon.awssdk.core.http.ExecutionContext; -import javax.annotation.Nullable; - public class S3Helper extends AbstractS3InstrumentationHelper { - private static final S3Helper INSTANCE = new S3Helper(GlobalTracer.requireTracerImpl()); + private static final S3Helper INSTANCE = new S3Helper(GlobalTracer.get()); public static S3Helper getInstance() { return INSTANCE; } - public S3Helper(ElasticApmTracer tracer) { + public S3Helper(Tracer tracer) { super(tracer, SdkV2DataSource.getInstance()); } } 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 4ba86288bc2..917a3bb0e17 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,8 +19,8 @@ package co.elastic.apm.agent.awssdk.v2.helper; import co.elastic.apm.agent.awssdk.common.AbstractSQSInstrumentationHelper; -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.transaction.Span; import co.elastic.apm.agent.impl.transaction.TextHeaderSetter; import co.elastic.apm.agent.impl.transaction.TraceContext; @@ -46,14 +46,14 @@ @SuppressWarnings({"rawtypes", "unchecked"}) public class SQSHelper extends AbstractSQSInstrumentationHelper implements TextHeaderSetter> { - - private static final SQSHelper INSTANCE = new SQSHelper(GlobalTracer.requireTracerImpl()); + + private static final SQSHelper INSTANCE = new SQSHelper(GlobalTracer.get()); public static SQSHelper getInstance() { return INSTANCE; } - public SQSHelper(ElasticApmTracer tracer) { + public SQSHelper(Tracer tracer) { super(tracer, SdkV2DataSource.getInstance()); } 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 cddb27fd922..735535eff9c 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,13 +20,13 @@ import co.elastic.apm.agent.awssdk.common.AbstractMessageIteratorWrapper; import co.elastic.apm.agent.awssdk.v2.helper.SQSHelper; -import co.elastic.apm.agent.impl.ElasticApmTracer; +import co.elastic.apm.agent.impl.Tracer; import software.amazon.awssdk.services.sqs.model.Message; import java.util.Iterator; class MessageIteratorWrapper extends AbstractMessageIteratorWrapper { - public MessageIteratorWrapper(Iterator delegate, ElasticApmTracer tracer, String queueName) { + public MessageIteratorWrapper(Iterator delegate, Tracer tracer, String queueName) { super(delegate, tracer, queueName, SQSHelper.getInstance(), SQSHelper.getInstance()); } } 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 e0d2734c88a..84073604557 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 @@ -23,8 +23,8 @@ import co.elastic.apm.agent.awssdk.v2.helper.SQSHelper; import co.elastic.apm.agent.awssdk.v2.helper.SdkV2DataSource; import co.elastic.apm.agent.configuration.MessagingConfiguration; -import co.elastic.apm.agent.impl.ElasticApmTracer; import co.elastic.apm.agent.common.util.WildcardMatcher; +import co.elastic.apm.agent.impl.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; @@ -43,7 +43,7 @@ public class MessageListWrapper extends AbstractMessageListWrapper { public static final CallDepth jmsReceiveMessageCallDepth = CallDepth.get(MessageListWrapper.class); private static final WeakMap> sqsResponseToWrappedMessageListMap = WeakConcurrent.buildMap(); - public static void registerWrapperListForResponse(@Nullable SdkRequest sdkRequest, @Nullable SdkResponse sdkResponse, ElasticApmTracer tracer) { + public static void registerWrapperListForResponse(@Nullable SdkRequest sdkRequest, @Nullable SdkResponse sdkResponse, Tracer tracer) { if (sdkResponse instanceof ReceiveMessageResponse && sdkRequest instanceof ReceiveMessageRequest) { String queueName = SdkV2DataSource.getInstance().getFieldValue(IAwsSdkDataSource.QUEUE_NAME_FIELD, sdkRequest); ReceiveMessageResponse receiveMessageResponse = (ReceiveMessageResponse) sdkResponse; @@ -66,7 +66,7 @@ public static List getMessagesList(ReceiveMessageResponse response) { return sqsResponseToWrappedMessageListMap.get(response); } - public MessageListWrapper(List delegate, ElasticApmTracer tracer, String queueName) { + public MessageListWrapper(List delegate, Tracer tracer, String queueName) { super(delegate, tracer, queueName, SQSHelper.getInstance(), SQSHelper.getInstance()); } diff --git a/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-2-plugin/src/test/java/co/elastic/apm/agent/awssdk/v2/BaseSyncClientHandlerInstrumentationTest.java b/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-2-plugin/src/test/java/co/elastic/apm/agent/awssdk/v2/BaseSyncClientHandlerInstrumentationTest.java index 6b5e6dc6da0..5786febab41 100644 --- a/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-2-plugin/src/test/java/co/elastic/apm/agent/awssdk/v2/BaseSyncClientHandlerInstrumentationTest.java +++ b/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-2-plugin/src/test/java/co/elastic/apm/agent/awssdk/v2/BaseSyncClientHandlerInstrumentationTest.java @@ -20,7 +20,7 @@ import co.elastic.apm.agent.MockTracer; import co.elastic.apm.agent.common.JvmRuntimeInfo; -import co.elastic.apm.agent.impl.ElasticApmTracer; +import co.elastic.apm.agent.impl.Tracer; import co.elastic.apm.agent.impl.transaction.Outcome; import co.elastic.apm.agent.impl.transaction.Span; import co.elastic.apm.agent.impl.transaction.Transaction; @@ -71,7 +71,7 @@ public void checkRedactedExceptionWhenExceptionThrownOnCorretto17() { public Outcome exerciseRedactedException(Exception canBeNull) { MockTracer.MockInstrumentationSetup mockInstrumentationSetup = MockTracer.createMockInstrumentationSetup(); - ElasticApmTracer tracer = mockInstrumentationSetup.getTracer(); + Tracer tracer = mockInstrumentationSetup.getTracer(); Transaction transaction = tracer.startRootTransaction(null); assertThat(transaction).isNotNull(); diff --git a/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-2-plugin/src/test/java/co/elastic/apm/agent/awssdk/v2/SQSJmsClientIT.java b/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-2-plugin/src/test/java/co/elastic/apm/agent/awssdk/v2/SQSJmsClientIT.java index 9457bcefec0..c0431011e83 100644 --- a/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-2-plugin/src/test/java/co/elastic/apm/agent/awssdk/v2/SQSJmsClientIT.java +++ b/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-2-plugin/src/test/java/co/elastic/apm/agent/awssdk/v2/SQSJmsClientIT.java @@ -301,7 +301,7 @@ static class SQSListener implements MessageListener { @Override public void onMessage(Message message) { try { - Tracer tracer = GlobalTracer.getTracerImpl(); + Tracer tracer = GlobalTracer.get(); assertThat(tracer).isNotNull(); AbstractSpan parent = tracer.getActive(); assertThat(parent).isNotNull(); 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 c9f2e803e65..daafdbba2a9 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,7 +18,7 @@ */ package co.elastic.apm.agent.awssdk.common; -import co.elastic.apm.agent.impl.ElasticApmTracer; +import co.elastic.apm.agent.impl.Tracer; import co.elastic.apm.agent.impl.transaction.Span; import javax.annotation.Nullable; @@ -26,14 +26,14 @@ public abstract class AbstractAwsSdkInstrumentationHelper { protected final IAwsSdkDataSource awsSdkDataSource; - protected final ElasticApmTracer tracer; + protected final Tracer tracer; - protected AbstractAwsSdkInstrumentationHelper(ElasticApmTracer tracer, IAwsSdkDataSource awsSdkDataSource) { + protected AbstractAwsSdkInstrumentationHelper(Tracer tracer, IAwsSdkDataSource awsSdkDataSource) { this.tracer = tracer; this.awsSdkDataSource = awsSdkDataSource; } - public ElasticApmTracer getTracer() { + public Tracer getTracer() { return tracer; } 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 0f7cf48b3a5..45fc1768840 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,7 +18,7 @@ */ package co.elastic.apm.agent.awssdk.common; -import co.elastic.apm.agent.impl.ElasticApmTracer; +import co.elastic.apm.agent.impl.Tracer; import co.elastic.apm.agent.impl.transaction.AbstractSpan; import co.elastic.apm.agent.impl.transaction.Span; @@ -28,7 +28,7 @@ public abstract class AbstractDynamoDBInstrumentationHelper extends AbstractAwsSdkInstrumentationHelper { public static final String DYNAMO_DB_TYPE = "dynamodb"; - protected AbstractDynamoDBInstrumentationHelper(ElasticApmTracer tracer, IAwsSdkDataSource awsSdkDataSource) { + protected AbstractDynamoDBInstrumentationHelper(Tracer tracer, IAwsSdkDataSource awsSdkDataSource) { super(tracer, awsSdkDataSource); } 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 6745039144e..ef905721a66 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,7 +19,7 @@ package co.elastic.apm.agent.awssdk.common; -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.TextHeaderGetter; import co.elastic.apm.agent.impl.transaction.Transaction; @@ -38,12 +38,12 @@ public abstract class AbstractMessageIteratorWrapper implements Iterato public static final Logger logger = LoggerFactory.getLogger(AbstractMessageIteratorWrapper.class); private final Iterator delegate; - private final ElasticApmTracer tracer; + private final Tracer tracer; private final String queueName; private final AbstractSQSInstrumentationHelper sqsInstrumentationHelper; private final TextHeaderGetter textHeaderGetter; - public AbstractMessageIteratorWrapper(Iterator delegate, ElasticApmTracer tracer, + public AbstractMessageIteratorWrapper(Iterator delegate, Tracer tracer, String queueName, AbstractSQSInstrumentationHelper sqsInstrumentationHelper, TextHeaderGetter 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 a6cacbee6b5..4386cbd4cd4 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,7 +18,7 @@ */ package co.elastic.apm.agent.awssdk.common; -import co.elastic.apm.agent.impl.ElasticApmTracer; +import co.elastic.apm.agent.impl.Tracer; import co.elastic.apm.agent.impl.transaction.TextHeaderGetter; import java.util.Collection; @@ -28,13 +28,13 @@ public abstract class AbstractMessageListWrapper implements List { protected List delegate; - protected final ElasticApmTracer tracer; + protected final Tracer tracer; protected final String queueName; protected final AbstractSQSInstrumentationHelper sqsInstrumentationHelper; protected final TextHeaderGetter textHeaderGetter; - public AbstractMessageListWrapper(List delegate, ElasticApmTracer tracer, String queueName, + public AbstractMessageListWrapper(List delegate, Tracer tracer, String queueName, AbstractSQSInstrumentationHelper sqsInstrumentationHelper, TextHeaderGetter textHeaderGetter) { this.delegate = delegate; 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 32adc4450bd..ee79deb71a5 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,7 +18,7 @@ */ package co.elastic.apm.agent.awssdk.common; -import co.elastic.apm.agent.impl.ElasticApmTracer; +import co.elastic.apm.agent.impl.Tracer; import co.elastic.apm.agent.impl.transaction.AbstractSpan; import co.elastic.apm.agent.impl.transaction.Span; @@ -28,7 +28,7 @@ public abstract class AbstractS3InstrumentationHelper extends AbstractAwsSdkInstrumentationHelper { public static final String S3_TYPE = "s3"; - protected AbstractS3InstrumentationHelper(ElasticApmTracer tracer, IAwsSdkDataSource awsSdkDataSource) { + protected AbstractS3InstrumentationHelper(Tracer tracer, IAwsSdkDataSource awsSdkDataSource) { super(tracer, awsSdkDataSource); } 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 35a8cab07c1..2038764d58f 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 @@ -18,16 +18,12 @@ */ package co.elastic.apm.agent.awssdk.common; +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.ElasticApmTracer; +import co.elastic.apm.agent.impl.Tracer; import co.elastic.apm.agent.impl.context.Message; -import co.elastic.apm.agent.impl.transaction.AbstractSpan; -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.common.util.WildcardMatcher; +import co.elastic.apm.agent.impl.transaction.*; import co.elastic.apm.agent.sdk.logging.Logger; import co.elastic.apm.agent.sdk.logging.LoggerFactory; import co.elastic.apm.agent.util.PrivilegedActionUtils; @@ -77,7 +73,7 @@ public abstract class AbstractSQSInstrumentationHelper extends A protected abstract boolean isReceiveMessageRequest(R request); - protected AbstractSQSInstrumentationHelper(ElasticApmTracer tracer, IAwsSdkDataSource awsSdkDataSource) { + protected AbstractSQSInstrumentationHelper(Tracer tracer, IAwsSdkDataSource awsSdkDataSource) { super(tracer, awsSdkDataSource); this.messagingConfiguration = tracer.getConfig(MessagingConfiguration.class); this.coreConfiguration = tracer.getConfig(CoreConfiguration.class); diff --git a/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/AbstractAwsLambdaHandlerInstrumentation.java b/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/AbstractAwsLambdaHandlerInstrumentation.java index d07533c4c56..a334dceaf66 100644 --- a/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/AbstractAwsLambdaHandlerInstrumentation.java +++ b/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/AbstractAwsLambdaHandlerInstrumentation.java @@ -20,7 +20,7 @@ import co.elastic.apm.agent.bci.TracerAwareInstrumentation; import co.elastic.apm.agent.configuration.ServerlessConfiguration; -import co.elastic.apm.agent.impl.ElasticApmTracer; +import co.elastic.apm.agent.impl.Tracer; import net.bytebuddy.description.type.TypeDescription; import net.bytebuddy.matcher.ElementMatcher; @@ -41,7 +41,7 @@ public abstract class AbstractAwsLambdaHandlerInstrumentation extends TracerAwar @Nullable protected String handlerMethodName; - public AbstractAwsLambdaHandlerInstrumentation(ElasticApmTracer tracer) { + public AbstractAwsLambdaHandlerInstrumentation(Tracer tracer) { serverlessConfiguration = tracer.getConfig(ServerlessConfiguration.class); String awsLambdaHandler = serverlessConfiguration.getAwsLambdaHandler(); //noinspection ConstantConditions diff --git a/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/RequestHandlerInstrumentation.java b/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/RequestHandlerInstrumentation.java index 0d443b1316a..155927d355c 100644 --- a/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/RequestHandlerInstrumentation.java +++ b/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/RequestHandlerInstrumentation.java @@ -20,7 +20,7 @@ import co.elastic.apm.agent.awslambda.helper.AWSEventsHelper; import co.elastic.apm.agent.awslambda.helper.PlainTransactionHelper; -import co.elastic.apm.agent.impl.ElasticApmTracer; +import co.elastic.apm.agent.impl.Tracer; import co.elastic.apm.agent.impl.transaction.Transaction; import com.amazonaws.services.lambda.runtime.Context; import net.bytebuddy.asm.Advice; @@ -35,7 +35,7 @@ public class RequestHandlerInstrumentation extends AbstractAwsLambdaHandlerInstrumentation { - public RequestHandlerInstrumentation(ElasticApmTracer tracer) { + public RequestHandlerInstrumentation(Tracer tracer) { super(tracer); } diff --git a/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/RequestStreamHandlerInstrumentation.java b/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/RequestStreamHandlerInstrumentation.java index a32e9a52463..7ee9acb5ca1 100644 --- a/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/RequestStreamHandlerInstrumentation.java +++ b/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/RequestStreamHandlerInstrumentation.java @@ -19,7 +19,7 @@ package co.elastic.apm.agent.awslambda; import co.elastic.apm.agent.awslambda.helper.PlainTransactionHelper; -import co.elastic.apm.agent.impl.ElasticApmTracer; +import co.elastic.apm.agent.impl.Tracer; import co.elastic.apm.agent.impl.transaction.Transaction; import com.amazonaws.services.lambda.runtime.Context; import net.bytebuddy.asm.Advice; @@ -35,7 +35,7 @@ public class RequestStreamHandlerInstrumentation extends AbstractAwsLambdaHandlerInstrumentation { - public RequestStreamHandlerInstrumentation(ElasticApmTracer tracer) { + public RequestStreamHandlerInstrumentation(Tracer tracer) { super(tracer); } diff --git a/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/helper/PlainTransactionHelper.java b/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/helper/PlainTransactionHelper.java index 3adda2f58d6..503279f1ff9 100644 --- a/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/helper/PlainTransactionHelper.java +++ b/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/helper/PlainTransactionHelper.java @@ -20,6 +20,7 @@ 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.transaction.Transaction; import co.elastic.apm.agent.util.PrivilegedActionUtils; import com.amazonaws.services.lambda.runtime.Context; diff --git a/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/helper/SNSTransactionHelper.java b/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/helper/SNSTransactionHelper.java index 872c744d085..acbaf50382f 100644 --- a/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/helper/SNSTransactionHelper.java +++ b/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/helper/SNSTransactionHelper.java @@ -19,8 +19,8 @@ package co.elastic.apm.agent.awslambda.helper; import co.elastic.apm.agent.awslambda.SNSMessageAttributesGetter; -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.transaction.TraceContext; import co.elastic.apm.agent.impl.transaction.Transaction; import com.amazonaws.services.lambda.runtime.events.SNSEvent; @@ -34,13 +34,13 @@ public class SNSTransactionHelper extends AbstractMessageBasedTransactionHelper< private final SNSEvent.SNSRecord placeholderRecord = new SNSEvent.SNSRecord(); - private SNSTransactionHelper(ElasticApmTracer tracer) { + private SNSTransactionHelper(Tracer tracer) { super(tracer); } public static SNSTransactionHelper getInstance() { if (INSTANCE == null) { - INSTANCE = new SNSTransactionHelper(GlobalTracer.requireTracerImpl()); + INSTANCE = new SNSTransactionHelper(GlobalTracer.get()); } return INSTANCE; } diff --git a/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/helper/SQSTransactionHelper.java b/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/helper/SQSTransactionHelper.java index c398ee7c633..5cc8aaca1c7 100644 --- a/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/helper/SQSTransactionHelper.java +++ b/apm-agent-plugins/apm-awslambda-plugin/src/main/java/co/elastic/apm/agent/awslambda/helper/SQSTransactionHelper.java @@ -19,8 +19,8 @@ package co.elastic.apm.agent.awslambda.helper; import co.elastic.apm.agent.awslambda.SQSMessageAttributesGetter; -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.transaction.TraceContext; import co.elastic.apm.agent.impl.transaction.Transaction; import com.amazonaws.services.lambda.runtime.events.SQSEvent; @@ -35,13 +35,13 @@ public class SQSTransactionHelper extends AbstractMessageBasedTransactionHelper< private final SQSEvent.SQSMessage placeholderMessage = new SQSEvent.SQSMessage(); - private SQSTransactionHelper(ElasticApmTracer tracer) { + private SQSTransactionHelper(Tracer tracer) { super(tracer); } public static SQSTransactionHelper getInstance() { if (INSTANCE == null) { - INSTANCE = new SQSTransactionHelper(GlobalTracer.requireTracerImpl()); + INSTANCE = new SQSTransactionHelper(GlobalTracer.get()); } return INSTANCE; } diff --git a/apm-agent-plugins/apm-awslambda-plugin/src/test/java/co/elastic/apm/agent/awslambda/lambdas/AbstractFunction.java b/apm-agent-plugins/apm-awslambda-plugin/src/test/java/co/elastic/apm/agent/awslambda/lambdas/AbstractFunction.java index 6d5722fa972..593cb44733b 100644 --- a/apm-agent-plugins/apm-awslambda-plugin/src/test/java/co/elastic/apm/agent/awslambda/lambdas/AbstractFunction.java +++ b/apm-agent-plugins/apm-awslambda-plugin/src/test/java/co/elastic/apm/agent/awslambda/lambdas/AbstractFunction.java @@ -27,7 +27,7 @@ public abstract class AbstractFunction implements RequestHandler { protected void createChildSpan() { - Objects.requireNonNull(GlobalTracer.requireTracerImpl().getActive()) + Objects.requireNonNull(GlobalTracer.get().getActive()) .createSpan() .withName("child-span") .activate() diff --git a/apm-agent-plugins/apm-awslambda-plugin/src/test/java/co/elastic/apm/agent/awslambda/lambdas/CustomHandler.java b/apm-agent-plugins/apm-awslambda-plugin/src/test/java/co/elastic/apm/agent/awslambda/lambdas/CustomHandler.java index 337212645df..e342a65c349 100644 --- a/apm-agent-plugins/apm-awslambda-plugin/src/test/java/co/elastic/apm/agent/awslambda/lambdas/CustomHandler.java +++ b/apm-agent-plugins/apm-awslambda-plugin/src/test/java/co/elastic/apm/agent/awslambda/lambdas/CustomHandler.java @@ -26,7 +26,7 @@ public class CustomHandler { public Void customHandleRequest(Object object, Context context) { - Objects.requireNonNull(GlobalTracer.requireTracerImpl().getActive()) + Objects.requireNonNull(GlobalTracer.get().getActive()) .createSpan() .withName("child-span") .activate() diff --git a/apm-agent-plugins/apm-awslambda-plugin/src/test/java/co/elastic/apm/agent/awslambda/lambdas/CustomStreamHandler.java b/apm-agent-plugins/apm-awslambda-plugin/src/test/java/co/elastic/apm/agent/awslambda/lambdas/CustomStreamHandler.java index d122f826150..9e67f534fda 100644 --- a/apm-agent-plugins/apm-awslambda-plugin/src/test/java/co/elastic/apm/agent/awslambda/lambdas/CustomStreamHandler.java +++ b/apm-agent-plugins/apm-awslambda-plugin/src/test/java/co/elastic/apm/agent/awslambda/lambdas/CustomStreamHandler.java @@ -28,7 +28,7 @@ public class CustomStreamHandler { public void customHandleRequest(InputStream inputStream, OutputStream outputStream, Context context) { - Objects.requireNonNull(GlobalTracer.requireTracerImpl().getActive()) + Objects.requireNonNull(GlobalTracer.get().getActive()) .createSpan() .withName("child-span") .activate() diff --git a/apm-agent-plugins/apm-awslambda-plugin/src/test/java/co/elastic/apm/agent/awslambda/lambdas/StreamHandlerLambdaFunction.java b/apm-agent-plugins/apm-awslambda-plugin/src/test/java/co/elastic/apm/agent/awslambda/lambdas/StreamHandlerLambdaFunction.java index f6a46d5ce3c..79b80851b0d 100644 --- a/apm-agent-plugins/apm-awslambda-plugin/src/test/java/co/elastic/apm/agent/awslambda/lambdas/StreamHandlerLambdaFunction.java +++ b/apm-agent-plugins/apm-awslambda-plugin/src/test/java/co/elastic/apm/agent/awslambda/lambdas/StreamHandlerLambdaFunction.java @@ -30,7 +30,7 @@ public class StreamHandlerLambdaFunction implements RequestStreamHandler { @Override public void handleRequest(InputStream inputStream, OutputStream outputStream, Context context) { - Objects.requireNonNull(GlobalTracer.requireTracerImpl().getActive()) + Objects.requireNonNull(GlobalTracer.get().getActive()) .createSpan() .withName("child-span") .activate() 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 c715612d818..c451979ef16 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,8 +20,8 @@ import co.elastic.apm.agent.dubbo.helper.AlibabaDubboTextMapPropagator; import co.elastic.apm.agent.dubbo.helper.DubboTraceHelper; -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.transaction.AbstractSpan; import co.elastic.apm.agent.impl.transaction.Outcome; import co.elastic.apm.agent.impl.transaction.Span; @@ -37,7 +37,7 @@ public class AlibabaMonitorFilterAdvice { - private static final ElasticApmTracer tracer = GlobalTracer.requireTracerImpl(); + private static final Tracer tracer = GlobalTracer.get(); @Nullable @Advice.OnMethodEnter(suppress = Throwable.class, inline = false) 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 3990a03ecbd..14051bc2143 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,8 +20,8 @@ import co.elastic.apm.agent.dubbo.helper.ApacheDubboTextMapPropagator; import co.elastic.apm.agent.dubbo.helper.DubboTraceHelper; -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.transaction.AbstractSpan; import co.elastic.apm.agent.impl.transaction.Outcome; import co.elastic.apm.agent.impl.transaction.Span; @@ -38,7 +38,7 @@ public class ApacheMonitorFilterAdvice { - private static final ElasticApmTracer tracer = GlobalTracer.requireTracerImpl(); + private static final Tracer tracer = GlobalTracer.get(); @Nullable @Advice.OnMethodEnter(suppress = Throwable.class, inline = false) 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 26a49b93bd2..9787f9fe303 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,7 +18,7 @@ */ package co.elastic.apm.agent.dubbo.helper; -import co.elastic.apm.agent.impl.ElasticApmTracer; +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; @@ -34,7 +34,7 @@ public class DubboTraceHelper { public static final String SPAN_KEY = "_elastic_apm_span"; @Nullable - public static Span createConsumerSpan(ElasticApmTracer 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; 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 34cc651bf80..3c999803926 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 @@ -20,8 +20,8 @@ import co.elastic.apm.agent.configuration.CoreConfiguration; import co.elastic.apm.agent.configuration.ServiceInfo; -import co.elastic.apm.agent.impl.ElasticApmTracer; import co.elastic.apm.agent.impl.GlobalTracer; +import co.elastic.apm.agent.impl.Tracer; import co.elastic.logging.log4j2.EcsLayout; import net.bytebuddy.asm.Advice; @@ -29,7 +29,7 @@ public class Log4j2ServiceNameInstrumentation extends AbstractLog4j2ServiceInstr public static class AdviceClass { - private static final ElasticApmTracer tracer = GlobalTracer.requireTracerImpl(); + private static final Tracer tracer = GlobalTracer.get(); @Advice.OnMethodEnter(suppress = Throwable.class, inline = false) public static void onEnter(@Advice.This EcsLayout.Builder builder) { 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 ba323ffeeed..bb19d0fd9a0 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 @@ -20,8 +20,8 @@ import co.elastic.apm.agent.configuration.CoreConfiguration; import co.elastic.apm.agent.configuration.ServiceInfo; -import co.elastic.apm.agent.impl.ElasticApmTracer; import co.elastic.apm.agent.impl.GlobalTracer; +import co.elastic.apm.agent.impl.Tracer; import co.elastic.logging.log4j2.EcsLayout; import net.bytebuddy.asm.Advice; import net.bytebuddy.description.type.TypeDescription; @@ -39,7 +39,7 @@ public ElementMatcher.Junction getTypeMatcher() { public static class AdviceClass { - private static final ElasticApmTracer tracer = GlobalTracer.requireTracerImpl(); + private static final Tracer tracer = GlobalTracer.get(); @Advice.OnMethodEnter(suppress = Throwable.class, inline = false) public static void onEnter(@Advice.This EcsLayout.Builder builder) { 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 b071200946f..a6fe28df96a 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,8 +19,8 @@ package co.elastic.apm.agent.esrestclient; import co.elastic.apm.agent.common.util.WildcardMatcher; -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.transaction.AbstractSpan; import co.elastic.apm.agent.impl.transaction.Outcome; import co.elastic.apm.agent.impl.transaction.Span; @@ -46,7 +46,7 @@ public class ElasticsearchRestClientInstrumentationHelper { private static final Logger logger = LoggerFactory.getLogger(ElasticsearchRestClientInstrumentationHelper.class); private static final Logger unsupportedOperationOnceLogger = LoggerUtils.logOnce(logger); - private static final ElasticsearchRestClientInstrumentationHelper INSTANCE = new ElasticsearchRestClientInstrumentationHelper(GlobalTracer.requireTracerImpl()); + private static final ElasticsearchRestClientInstrumentationHelper INSTANCE = new ElasticsearchRestClientInstrumentationHelper(GlobalTracer.get()); public static final List QUERY_WILDCARD_MATCHERS = Arrays.asList( WildcardMatcher.valueOf("*_search"), @@ -58,7 +58,7 @@ public class ElasticsearchRestClientInstrumentationHelper { public static final String ELASTICSEARCH = "elasticsearch"; public static final String SPAN_ACTION = "request"; private static final int MAX_POOLED_ELEMENTS = 256; - private final ElasticApmTracer tracer; + private final Tracer tracer; private final ObjectPool responseListenerObjectPool; @@ -66,7 +66,7 @@ public static ElasticsearchRestClientInstrumentationHelper get() { return INSTANCE; } - private ElasticsearchRestClientInstrumentationHelper(ElasticApmTracer tracer) { + private ElasticsearchRestClientInstrumentationHelper(Tracer tracer) { this.tracer = tracer; this.responseListenerObjectPool = tracer.getObjectPoolFactory().createRecyclableObjectPool(MAX_POOLED_ELEMENTS, new ResponseListenerAllocator()); } 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 d1b9000fb8c..d85a408fdd4 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,7 +19,7 @@ package co.elastic.apm.agent.websocket; import co.elastic.apm.agent.bci.TracerAwareInstrumentation; -import co.elastic.apm.agent.impl.ElasticApmTracer; +import co.elastic.apm.agent.impl.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; @@ -48,7 +48,7 @@ public abstract class BaseServerEndpointInstrumentation extends TracerAwareInstr private final Collection applicationPackages; - public BaseServerEndpointInstrumentation(ElasticApmTracer tracer) { + public BaseServerEndpointInstrumentation(Tracer tracer) { applicationPackages = tracer.getConfig(StacktraceConfiguration.class).getApplicationPackages(); } 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 6219ca58099..5d51b59d42f 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.ElasticApmTracer; +import co.elastic.apm.agent.impl.Tracer; import co.elastic.apm.agent.util.VersionUtils; import jakarta.websocket.server.ServerEndpoint; import net.bytebuddy.asm.Advice; @@ -30,7 +30,7 @@ public class JakartaServerEndpointInstrumentation extends BaseServerEndpointInstrumentation { - public JakartaServerEndpointInstrumentation(ElasticApmTracer tracer) { + public JakartaServerEndpointInstrumentation(Tracer tracer) { super(tracer); } 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 4886047df3c..40ac2f9f026 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.ElasticApmTracer; +import co.elastic.apm.agent.impl.Tracer; import co.elastic.apm.agent.util.VersionUtils; import net.bytebuddy.asm.Advice; @@ -30,7 +30,7 @@ public class JavaxServerEndpointInstrumentation extends BaseServerEndpointInstrumentation { - public JavaxServerEndpointInstrumentation(ElasticApmTracer tracer) { + public JavaxServerEndpointInstrumentation(Tracer tracer) { super(tracer); } 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 7912d64ff07..0240061aa40 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,8 +18,8 @@ */ package co.elastic.apm.agent.java_ldap; -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.transaction.AbstractSpan; import co.elastic.apm.agent.impl.transaction.Outcome; import co.elastic.apm.agent.impl.transaction.Span; @@ -32,7 +32,7 @@ public class LdapClientAdvice { - private static final ElasticApmTracer tracer = GlobalTracer.requireTracerImpl(); + 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) { 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 7c5ca8b0fcb..073e4ee064b 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 @@ -85,7 +85,7 @@ public String getAdviceClassName() { public static class HandlerAdapterAdvice { - private static final WebConfiguration webConfig = GlobalTracer.requireTracerImpl().getConfig(WebConfiguration.class); + private static final WebConfiguration webConfig = GlobalTracer.get().getConfig(WebConfiguration.class); // never invoked, only used to cache the fact that the io.javalin.http.Context#handlerType() method is unavailable in this Javalin version private static final MethodHandle NOOP = MethodHandles.constant(String.class, "Non-supported Javalin version"); 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 38b143ac396..3cf822a10ec 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,14 +19,14 @@ package co.elastic.apm.agent.jaxrs; import co.elastic.apm.agent.bci.bytebuddy.SimpleMethodSignatureOffsetMappingFactory; -import co.elastic.apm.agent.impl.ElasticApmTracer; +import co.elastic.apm.agent.impl.Tracer; import co.elastic.apm.agent.util.VersionUtils; import net.bytebuddy.asm.Advice; import javax.annotation.Nullable; public class JakartaeeJaxRsTransactionNameInstrumentation extends JaxRsTransactionNameInstrumentation { - public JakartaeeJaxRsTransactionNameInstrumentation(ElasticApmTracer tracer) { + public JakartaeeJaxRsTransactionNameInstrumentation(Tracer tracer) { super(tracer); } 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 24f59922396..33248197520 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.ElasticApmTracer; +import co.elastic.apm.agent.impl.Tracer; import co.elastic.apm.agent.util.VersionUtils; import net.bytebuddy.asm.Advice; @@ -27,7 +27,7 @@ public class JavaxJaxRsTransactionNameInstrumentation extends JaxRsTransactionNameInstrumentation { - public JavaxJaxRsTransactionNameInstrumentation(ElasticApmTracer tracer) { + public JavaxJaxRsTransactionNameInstrumentation(Tracer tracer) { super(tracer); } 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 a9e2a360c08..14c7c8fb389 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.ElasticApmTracer; +import co.elastic.apm.agent.impl.Tracer; import net.bytebuddy.asm.Advice; import net.bytebuddy.description.annotation.AnnotationDescription; import net.bytebuddy.description.annotation.AnnotationSource; @@ -41,7 +41,7 @@ public class JaxRsOffsetMappingFactory implements Advice.OffsetMapping.Factory applicationPackages; private final JaxRsConfiguration configuration; - private final ElasticApmTracer tracer; + private final Tracer tracer; - public JaxRsTransactionNameInstrumentation(ElasticApmTracer tracer) { + public JaxRsTransactionNameInstrumentation(Tracer tracer) { this.tracer = tracer; applicationPackages = tracer.getConfig(StacktraceConfiguration.class).getApplicationPackages(); configuration = tracer.getConfig(JaxRsConfiguration.class); @@ -120,7 +120,7 @@ public Advice.OffsetMapping.Factory getOffsetMapping() { } static class BaseAdvice { - private static final boolean useAnnotationValueForTransactionName = GlobalTracer.getTracerImpl() + private static final boolean useAnnotationValueForTransactionName = GlobalTracer.get() .getConfig(JaxRsConfiguration.class) .isUseJaxRsPathForTransactionName(); 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 c3753655ecc..6986f7504a7 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,7 +20,7 @@ import co.elastic.apm.agent.bci.TracerAwareInstrumentation; import co.elastic.apm.agent.bci.bytebuddy.SimpleMethodSignatureOffsetMappingFactory.SimpleMethodSignature; -import co.elastic.apm.agent.impl.ElasticApmTracer; +import co.elastic.apm.agent.impl.Tracer; import co.elastic.apm.agent.impl.stacktrace.StacktraceConfiguration; import co.elastic.apm.agent.impl.transaction.Transaction; import net.bytebuddy.asm.Advice; @@ -52,7 +52,7 @@ public class JaxWsTransactionNameInstrumentation extends TracerAwareInstrumentat private final Collection applicationPackages; - public JaxWsTransactionNameInstrumentation(ElasticApmTracer tracer) { + public JaxWsTransactionNameInstrumentation(Tracer tracer) { applicationPackages = tracer.getConfig(StacktraceConfiguration.class).getApplicationPackages(); } 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 245e9c940c7..28d1fa242e0 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,7 +18,7 @@ */ package co.elastic.apm.agent.jdbc; -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.jdbc.helper.JdbcHelper; import net.bytebuddy.asm.Advice; @@ -82,7 +82,7 @@ public ElementMatcher getMethodMatcher() { @SuppressWarnings("DuplicatedCode") public static class ExecuteWithQueryInstrumentation extends StatementInstrumentation { - public ExecuteWithQueryInstrumentation(ElasticApmTracer tracer) { + public ExecuteWithQueryInstrumentation(Tracer tracer) { super( named("execute").or(named("executeQuery")) .and(takesArgument(0, String.class)) @@ -131,7 +131,7 @@ public static void onAfterExecute(@Advice.This Statement statement, */ public static class ExecuteUpdateWithQueryInstrumentation extends StatementInstrumentation { - public ExecuteUpdateWithQueryInstrumentation(ElasticApmTracer tracer) { + public ExecuteUpdateWithQueryInstrumentation(Tracer tracer) { super( named("executeUpdate").or(named("executeLargeUpdate")) .and(takesArgument(0, String.class)) @@ -174,7 +174,7 @@ public static void onAfterExecute(@Advice.Enter @Nullable Object span, */ public static class AddBatchInstrumentation extends StatementInstrumentation { - public AddBatchInstrumentation(ElasticApmTracer tracer) { + public AddBatchInstrumentation(Tracer tracer) { super( nameStartsWith("addBatch") .and(takesArgument(0, String.class)) @@ -200,7 +200,7 @@ public static void storeSql(@Advice.This Statement statement, @Advice.Argument(0 * */ public static class ExecuteBatchInstrumentation extends StatementInstrumentation { - public ExecuteBatchInstrumentation(ElasticApmTracer tracer) { + public ExecuteBatchInstrumentation(Tracer tracer) { super( named("executeBatch").or(named("executeLargeBatch")) .and(takesArguments(0)) @@ -265,7 +265,7 @@ public static void onAfterExecute(@Advice.Enter @Nullable Object spanObj, * */ public static class ExecuteUpdateNoQueryInstrumentation extends StatementInstrumentation { - public ExecuteUpdateNoQueryInstrumentation(ElasticApmTracer tracer) { + public ExecuteUpdateNoQueryInstrumentation(Tracer tracer) { super( named("executeUpdate").or(named("executeLargeUpdate")) .and(takesArguments(0)) @@ -313,7 +313,7 @@ public static void onAfterExecute(@Advice.Enter @Nullable Object span, * */ public static class ExecutePreparedStatementInstrumentation extends StatementInstrumentation { - public ExecutePreparedStatementInstrumentation(ElasticApmTracer tracer) { + public ExecutePreparedStatementInstrumentation(Tracer tracer) { super( named("execute").or(named("executeQuery")) .and(takesArguments(0)) @@ -355,7 +355,7 @@ public static void onAfterExecute(@Advice.This Statement statement, */ public static class CloseStatementInstrumentation extends StatementInstrumentation { - public CloseStatementInstrumentation(ElasticApmTracer tracer) { + public CloseStatementInstrumentation(Tracer tracer) { super( named("close") .and(takesArguments(0)) diff --git a/apm-agent-plugins/apm-jdbc-plugin/src/test/java/co/elastic/apm/agent/jdbc/helper/ConnectionMetaDataTest.java b/apm-agent-plugins/apm-jdbc-plugin/src/test/java/co/elastic/apm/agent/jdbc/helper/ConnectionMetaDataTest.java index 5c77ad732d4..f0cc0d9255f 100644 --- a/apm-agent-plugins/apm-jdbc-plugin/src/test/java/co/elastic/apm/agent/jdbc/helper/ConnectionMetaDataTest.java +++ b/apm-agent-plugins/apm-jdbc-plugin/src/test/java/co/elastic/apm/agent/jdbc/helper/ConnectionMetaDataTest.java @@ -20,7 +20,7 @@ import co.elastic.apm.agent.MockReporter; import co.elastic.apm.agent.MockTracer; -import co.elastic.apm.agent.impl.ElasticApmTracer; +import co.elastic.apm.agent.impl.Tracer; import co.elastic.apm.agent.impl.transaction.Transaction; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; @@ -348,7 +348,7 @@ void testInvalid() { private static final MockTracer.MockInstrumentationSetup mockSetup = MockTracer.createMockInstrumentationSetup(); private static final MockReporter reporter = mockSetup.getReporter(); - private static final ElasticApmTracer tracer = mockSetup.getTracer(); + private static final Tracer tracer = mockSetup.getTracer(); private void testUrl(String url, String expectedVendor, @Nullable String expectedHost, int expectedPort, @Nullable String expectedDatabase) { ConnectionMetaData metadata = ConnectionMetaData.parse(url).build(); 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 205db8ed610..1e26f7398be 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,16 +19,14 @@ package co.elastic.apm.agent.httpserver; 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.context.Request; import co.elastic.apm.agent.impl.context.Response; import co.elastic.apm.agent.impl.context.web.ResultUtil; 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.sdk.logging.Logger; -import co.elastic.apm.agent.sdk.logging.LoggerFactory; import co.elastic.apm.agent.util.TransactionNameUtils; import com.sun.net.httpserver.Headers; import com.sun.net.httpserver.HttpExchange; @@ -42,15 +40,13 @@ public class HttpHandlerAdvice { - private static final Logger logger = LoggerFactory.getLogger(HttpHandlerAdvice.class); - - private static final ElasticApmTracer tracer; + private static final Tracer tracer; private static final HttpServerHelper serverHelper; private static final WebConfiguration webConfiguration; private static final CoreConfiguration coreConfiguration; static { - tracer = GlobalTracer.requireTracerImpl(); + tracer = GlobalTracer.get(); serverHelper = new HttpServerHelper(tracer.getConfig(WebConfiguration.class)); webConfiguration = tracer.getConfig(WebConfiguration.class); coreConfiguration = tracer.getConfig(CoreConfiguration.class); @@ -146,7 +142,6 @@ public static void onExitHandle(@Advice.Argument(0) HttpExchange exchange, @Advi .withFinished(true) .withStatusCode(exchange.getResponseCode()); - ElasticApmTracer tracer = GlobalTracer.getTracerImpl(); if (transaction.isSampled() && tracer.getConfig(CoreConfiguration.class).isCaptureHeaders()) { Headers headers = exchange.getResponseHeaders(); if (headers != null) { 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 b775afdc814..de8bb910865 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.ElasticApmTracer; import co.elastic.apm.agent.impl.GlobalTracer; +import co.elastic.apm.agent.impl.Tracer; import net.bytebuddy.matcher.ElementMatcher; import java.util.Collection; @@ -51,15 +51,15 @@ protected static class BaseAdvice { protected static final CoreConfiguration coreConfiguration; static { - ElasticApmTracer elasticApmTracer = GlobalTracer.requireTracerImpl(); + Tracer tracer = GlobalTracer.get(); // loading helper class will load JMS-related classes if loaded from Instrumentation static init // that fails when trying to load instrumentation classes without JMS dependencies, for example when generating // documentation that relies on instrumentation group names - helper = new JmsInstrumentationHelper(elasticApmTracer); + helper = new JmsInstrumentationHelper(tracer); - messagingConfiguration = elasticApmTracer.getConfig(MessagingConfiguration.class); - coreConfiguration = elasticApmTracer.getConfig(CoreConfiguration.class); + messagingConfiguration = tracer.getConfig(MessagingConfiguration.class); + coreConfiguration = tracer.getConfig(CoreConfiguration.class); } } } 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 08ea63d0a3c..d0927d081a2 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,7 +20,7 @@ import co.elastic.apm.agent.configuration.CoreConfiguration; import co.elastic.apm.agent.configuration.MessagingConfiguration; -import co.elastic.apm.agent.impl.ElasticApmTracer; +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; @@ -84,11 +84,11 @@ public class JmsInstrumentationHelper { static final String FRAMEWORK_NAME = "JMS"; private static final Logger logger = LoggerFactory.getLogger(JmsInstrumentationHelper.class); - private final ElasticApmTracer tracer; + private final Tracer tracer; private final CoreConfiguration coreConfiguration; private final MessagingConfiguration messagingConfiguration; - public JmsInstrumentationHelper(ElasticApmTracer tracer) { + public JmsInstrumentationHelper(Tracer tracer) { this.tracer = tracer; coreConfiguration = tracer.getConfig(CoreConfiguration.class); messagingConfiguration = tracer.getConfig(MessagingConfiguration.class); 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 2424b87783d..2ba130b5d63 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,7 +19,7 @@ package co.elastic.apm.agent.jms; import co.elastic.apm.agent.configuration.MessagingConfiguration; -import co.elastic.apm.agent.impl.ElasticApmTracer; +import co.elastic.apm.agent.impl.Tracer; import co.elastic.apm.agent.impl.transaction.Transaction; import co.elastic.apm.agent.sdk.logging.Logger; import co.elastic.apm.agent.sdk.logging.LoggerFactory; @@ -55,7 +55,7 @@ public class JmsMessageListenerInstrumentation extends BaseJmsInstrumentation { private MessagingConfiguration configuration; - public JmsMessageListenerInstrumentation(ElasticApmTracer tracer) { + public JmsMessageListenerInstrumentation(Tracer tracer) { this.configuration = tracer.getConfig(MessagingConfiguration.class); } diff --git a/apm-agent-plugins/apm-jms-plugin/apm-jms-spring-plugin/src/test/java/co/elastic/apm/agent/jms/spring/SpringMapMessageListener.java b/apm-agent-plugins/apm-jms-plugin/apm-jms-spring-plugin/src/test/java/co/elastic/apm/agent/jms/spring/SpringMapMessageListener.java index d73e03cc765..bfe1419893f 100644 --- a/apm-agent-plugins/apm-jms-plugin/apm-jms-spring-plugin/src/test/java/co/elastic/apm/agent/jms/spring/SpringMapMessageListener.java +++ b/apm-agent-plugins/apm-jms-plugin/apm-jms-spring-plugin/src/test/java/co/elastic/apm/agent/jms/spring/SpringMapMessageListener.java @@ -45,7 +45,7 @@ public void onMessage(MapMessage mapMessage, Session session) throws JMSExceptio } System.out.println("Received map message: "); map.forEach((key, value) -> System.out.println(" " + key + " --> " + value)); - Transaction transaction = GlobalTracer.getTracerImpl().currentTransaction(); + Transaction transaction = GlobalTracer.get().currentTransaction(); assertThat(transaction.isFinished()).isFalse(); SpringJmsTest.resultQueue.offer(map); } diff --git a/apm-agent-plugins/apm-jmx-plugin/src/main/java/co/elastic/apm/agent/jmx/JmxMetricTracker.java b/apm-agent-plugins/apm-jmx-plugin/src/main/java/co/elastic/apm/agent/jmx/JmxMetricTracker.java index 87fb429c96a..57bfbee2437 100644 --- a/apm-agent-plugins/apm-jmx-plugin/src/main/java/co/elastic/apm/agent/jmx/JmxMetricTracker.java +++ b/apm-agent-plugins/apm-jmx-plugin/src/main/java/co/elastic/apm/agent/jmx/JmxMetricTracker.java @@ -23,7 +23,6 @@ import co.elastic.apm.agent.metrics.DoubleSupplier; import co.elastic.apm.agent.metrics.Labels; import co.elastic.apm.agent.metrics.MetricRegistry; -import co.elastic.apm.agent.util.ExecutorUtils; import co.elastic.apm.agent.util.GlobalLocks; import co.elastic.apm.agent.sdk.logging.Logger; import co.elastic.apm.agent.sdk.logging.LoggerFactory; diff --git a/apm-agent-plugins/apm-jmx-plugin/src/test/java/co/elastic/apm/agent/jmx/JmxMetricTrackerTest.java b/apm-agent-plugins/apm-jmx-plugin/src/test/java/co/elastic/apm/agent/jmx/JmxMetricTrackerTest.java index 17fa88bae5a..39304d8437e 100644 --- a/apm-agent-plugins/apm-jmx-plugin/src/test/java/co/elastic/apm/agent/jmx/JmxMetricTrackerTest.java +++ b/apm-agent-plugins/apm-jmx-plugin/src/test/java/co/elastic/apm/agent/jmx/JmxMetricTrackerTest.java @@ -21,6 +21,7 @@ import co.elastic.apm.agent.MockTracer; import co.elastic.apm.agent.configuration.SpyConfiguration; import co.elastic.apm.agent.impl.ElasticApmTracer; +import co.elastic.apm.agent.impl.Tracer; import co.elastic.apm.agent.metrics.Labels; import co.elastic.apm.agent.metrics.MetricRegistry; import co.elastic.apm.agent.report.serialize.MetricRegistrySerializer; 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 f0eb2fb23c7..9c20b36f071 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 @@ -57,7 +57,7 @@ public String getAdviceClassName() { public static class KafkaPollEntryAdvice { - private static final MessagingConfiguration messagingConfiguration = GlobalTracer.requireTracerImpl().getConfig(MessagingConfiguration.class); + private static final MessagingConfiguration messagingConfiguration = GlobalTracer.get().getConfig(MessagingConfiguration.class); @SuppressWarnings("unused") @Advice.OnMethodEnter(suppress = Throwable.class, inline = false) 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 8239e6bf67b..6fa00387620 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,8 +19,8 @@ package co.elastic.apm.agent.kafka.helper; import co.elastic.apm.agent.configuration.MessagingConfiguration; -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.transaction.Span; import co.elastic.apm.agent.common.util.WildcardMatcher; import co.elastic.apm.agent.objectpool.Allocator; @@ -39,17 +39,17 @@ public class KafkaInstrumentationHelper { public static final Logger logger = LoggerFactory.getLogger(KafkaInstrumentationHelper.class); - private static final KafkaInstrumentationHelper INSTANCE = new KafkaInstrumentationHelper(GlobalTracer.requireTracerImpl()); + private static final KafkaInstrumentationHelper INSTANCE = new KafkaInstrumentationHelper(GlobalTracer.get()); private final ObjectPool callbackWrapperObjectPool; - private final ElasticApmTracer tracer; + private final Tracer tracer; private final MessagingConfiguration messagingConfiguration; public static KafkaInstrumentationHelper get() { return INSTANCE; } - public KafkaInstrumentationHelper(ElasticApmTracer tracer) { + public KafkaInstrumentationHelper(Tracer tracer) { this.tracer = tracer; this.messagingConfiguration = tracer.getConfig(MessagingConfiguration.class); this.callbackWrapperObjectPool = tracer.getObjectPoolFactory().createRecyclableObjectPool(256, 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 c9fbeb963ed..2e2b359e5ed 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.ElasticApmTracer; +import co.elastic.apm.agent.impl.Tracer; import org.apache.kafka.clients.consumer.ConsumerRecord; import java.util.Iterator; @@ -26,9 +26,9 @@ class ConsumerRecordsIterableWrapper implements Iterable> { private final Iterable> delegate; - private final ElasticApmTracer tracer; + private final Tracer tracer; - public ConsumerRecordsIterableWrapper(Iterable> delegate, ElasticApmTracer tracer) { + public ConsumerRecordsIterableWrapper(Iterable> delegate, Tracer tracer) { this.delegate = delegate; this.tracer = tracer; } 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 2f3e4b4dde2..b59099ca96e 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,7 +20,7 @@ import co.elastic.apm.agent.configuration.CoreConfiguration; import co.elastic.apm.agent.configuration.MessagingConfiguration; -import co.elastic.apm.agent.impl.ElasticApmTracer; +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; @@ -40,11 +40,11 @@ class ConsumerRecordsIteratorWrapper implements Iterator> { public static final String FRAMEWORK_NAME = "Kafka"; private final Iterator> delegate; - private final ElasticApmTracer tracer; + private final Tracer tracer; private final CoreConfiguration coreConfiguration; private final MessagingConfiguration messagingConfiguration; - public ConsumerRecordsIteratorWrapper(Iterator> delegate, ElasticApmTracer tracer) { + public ConsumerRecordsIteratorWrapper(Iterator> delegate, Tracer tracer) { this.delegate = delegate; this.tracer = tracer; coreConfiguration = tracer.getConfig(CoreConfiguration.class); 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 becd215df19..5289049a432 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.ElasticApmTracer; +import co.elastic.apm.agent.impl.Tracer; import org.apache.kafka.clients.consumer.ConsumerRecord; import java.util.Collection; @@ -29,9 +29,9 @@ class ConsumerRecordsListWrapper implements List> { private final List> delegate; - private final ElasticApmTracer tracer; + private final Tracer tracer; - public ConsumerRecordsListWrapper(List> delegate, ElasticApmTracer tracer) { + public ConsumerRecordsListWrapper(List> delegate, Tracer tracer) { this.delegate = delegate; this.tracer = tracer; } 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 50564b37731..adb50d02a4c 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,8 +18,8 @@ */ package co.elastic.apm.agent.kafka.helper; -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.transaction.AbstractSpan; import co.elastic.apm.agent.impl.transaction.Span; import co.elastic.apm.agent.impl.transaction.TraceContext; @@ -36,7 +36,7 @@ public class KafkaInstrumentationHeadersHelper { private static final Logger logger = LoggerFactory.getLogger(KafkaInstrumentationHeadersHelper.class); - private static final KafkaInstrumentationHeadersHelper INSTANCE = new KafkaInstrumentationHeadersHelper(GlobalTracer.requireTracerImpl()); + private static final KafkaInstrumentationHeadersHelper INSTANCE = new KafkaInstrumentationHeadersHelper(GlobalTracer.get()); private static final ThreadLocal wrappingDisabled = new ThreadLocal() { @Override @@ -45,13 +45,13 @@ protected Boolean initialValue() { } }; - private final ElasticApmTracer tracer; + private final Tracer tracer; public static KafkaInstrumentationHeadersHelper get() { return INSTANCE; } - public KafkaInstrumentationHeadersHelper(ElasticApmTracer tracer) { + public KafkaInstrumentationHeadersHelper(Tracer tracer) { this.tracer = tracer; } diff --git a/apm-agent-plugins/apm-logging-plugin/apm-logging-plugin-common/src/test/java/co/elastic/apm/agent/loginstr/correlation/CorrelationIdMapAdapterTest.java b/apm-agent-plugins/apm-logging-plugin/apm-logging-plugin-common/src/test/java/co/elastic/apm/agent/loginstr/correlation/CorrelationIdMapAdapterTest.java index 638315755ca..85a2f401806 100644 --- a/apm-agent-plugins/apm-logging-plugin/apm-logging-plugin-common/src/test/java/co/elastic/apm/agent/loginstr/correlation/CorrelationIdMapAdapterTest.java +++ b/apm-agent-plugins/apm-logging-plugin/apm-logging-plugin-common/src/test/java/co/elastic/apm/agent/loginstr/correlation/CorrelationIdMapAdapterTest.java @@ -19,9 +19,9 @@ package co.elastic.apm.agent.loginstr.correlation; import co.elastic.apm.agent.MockTracer; -import co.elastic.apm.agent.impl.ElasticApmTracer; 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.transaction.Span; import co.elastic.apm.agent.impl.transaction.Transaction; import org.junit.jupiter.api.AfterEach; @@ -33,7 +33,7 @@ public class CorrelationIdMapAdapterTest { - private final ElasticApmTracer tracer = MockTracer.createRealTracer(); + private final Tracer tracer = MockTracer.createRealTracer(); @BeforeEach void setUp() { diff --git a/apm-agent-plugins/apm-micrometer-plugin/src/test/java/co/elastic/apm/agent/micrometer/MicrometerMetricsReporterTest.java b/apm-agent-plugins/apm-micrometer-plugin/src/test/java/co/elastic/apm/agent/micrometer/MicrometerMetricsReporterTest.java index 18b64638e1a..b4016005f0a 100644 --- a/apm-agent-plugins/apm-micrometer-plugin/src/test/java/co/elastic/apm/agent/micrometer/MicrometerMetricsReporterTest.java +++ b/apm-agent-plugins/apm-micrometer-plugin/src/test/java/co/elastic/apm/agent/micrometer/MicrometerMetricsReporterTest.java @@ -23,6 +23,7 @@ import co.elastic.apm.agent.configuration.MetricsConfiguration; import co.elastic.apm.agent.impl.ElasticApmTracer; import co.elastic.apm.agent.common.util.WildcardMatcher; +import co.elastic.apm.agent.impl.Tracer; import co.elastic.apm.agent.report.ReporterConfiguration; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; 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 5e2fc3dfd78..17cd6818cee 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,8 +18,8 @@ */ package co.elastic.apm.agent.mongodb; -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.transaction.AbstractSpan; import co.elastic.apm.agent.impl.transaction.Span; import co.elastic.apm.agent.common.util.WildcardMatcher; @@ -34,11 +34,11 @@ public class MongoHelper { private static final Logger logger = LoggerFactory.getLogger(MongoHelper.class); - private final ElasticApmTracer tracer; + private final Tracer tracer; private final MongoConfiguration config; public MongoHelper() { - this.tracer = GlobalTracer.getTracerImpl(); + this.tracer = GlobalTracer.get(); this.config = tracer.getConfig(MongoConfiguration.class); } diff --git a/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-metricsdk-plugin/src/main/java/co/elastic/apm/agent/otelmetricsdk/SdkMeterProviderBuilderInstrumentation.java b/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-metricsdk-plugin/src/main/java/co/elastic/apm/agent/otelmetricsdk/SdkMeterProviderBuilderInstrumentation.java index 8bf744349aa..9c096063b6a 100644 --- a/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-metricsdk-plugin/src/main/java/co/elastic/apm/agent/otelmetricsdk/SdkMeterProviderBuilderInstrumentation.java +++ b/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-metricsdk-plugin/src/main/java/co/elastic/apm/agent/otelmetricsdk/SdkMeterProviderBuilderInstrumentation.java @@ -20,6 +20,7 @@ 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.otelmetricexport.ElasticOtelMetricsExporter; import co.elastic.apm.agent.sdk.ElasticApmInstrumentation; import co.elastic.apm.agent.sdk.logging.Logger; diff --git a/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-plugin/src/main/java/co/elastic/apm/agent/opentelemetry/sdk/OTelSpanBuilder.java b/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-plugin/src/main/java/co/elastic/apm/agent/opentelemetry/sdk/OTelSpanBuilder.java index 5ddc7d75381..a68a7cd6dfb 100644 --- a/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-plugin/src/main/java/co/elastic/apm/agent/opentelemetry/sdk/OTelSpanBuilder.java +++ b/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-plugin/src/main/java/co/elastic/apm/agent/opentelemetry/sdk/OTelSpanBuilder.java @@ -34,10 +34,7 @@ import io.opentelemetry.api.OpenTelemetry; import io.opentelemetry.api.common.AttributeKey; import io.opentelemetry.api.common.Attributes; -import io.opentelemetry.api.trace.Span; -import io.opentelemetry.api.trace.SpanBuilder; -import io.opentelemetry.api.trace.SpanContext; -import io.opentelemetry.api.trace.SpanKind; +import io.opentelemetry.api.trace.*; import io.opentelemetry.api.trace.propagation.W3CTraceContextPropagator; import io.opentelemetry.context.Context; @@ -54,7 +51,7 @@ class OTelSpanBuilder implements SpanBuilder { private static final Logger addLinkLogger = LoggerUtils.logOnce(LoggerFactory.getLogger(OTelSpanBuilder.class)); private final String spanName; - private final ElasticApmTracer elasticApmTracer; + private final ElasticApmTracer tracer; private final Map, Object> attributes = new HashMap<>(); private long epochMicros = -1; @Nullable @@ -67,9 +64,9 @@ class OTelSpanBuilder implements SpanBuilder { @Nullable private SpanKind kind; - public OTelSpanBuilder(String spanName, ElasticApmTracer elasticApmTracer) { + public OTelSpanBuilder(String spanName, ElasticApmTracer tracer) { this.spanName = spanName; - this.elasticApmTracer = elasticApmTracer; + this.tracer = tracer; } @Override @@ -153,17 +150,17 @@ public Span startSpan() { if (parent == null) { // when parent is not explicitly set, the currently active parent is used as fallback - parent = elasticApmTracer.getActive(); + parent = tracer.getActive(); } if (remoteContext != null) { PotentiallyMultiValuedMap headers = new PotentiallyMultiValuedMap(2); W3CTraceContextPropagator.getInstance().inject(remoteContext, headers, PotentiallyMultiValuedMap::add); - span = elasticApmTracer.startChildTransaction(headers, MultiValueMapAccessor.INSTANCE, PrivilegedActionUtils.getClassLoader(getClass()), epochMicros); + span = tracer.startChildTransaction(headers, MultiValueMapAccessor.INSTANCE, PrivilegedActionUtils.getClassLoader(getClass()), epochMicros); } else if (parent == null) { - span = elasticApmTracer.startRootTransaction(PrivilegedActionUtils.getClassLoader(getClass()), epochMicros); + span = tracer.startRootTransaction(PrivilegedActionUtils.getClassLoader(getClass()), epochMicros); } else { - span = elasticApmTracer.startSpan(parent, epochMicros); + span = tracer.startSpan(parent, epochMicros); } if (span == null) { return Span.getInvalid(); diff --git a/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-plugin/src/main/java/co/elastic/apm/agent/opentelemetry/sdk/OTelTracer.java b/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-plugin/src/main/java/co/elastic/apm/agent/opentelemetry/sdk/OTelTracer.java index db800afc1b7..071fefaec30 100644 --- a/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-plugin/src/main/java/co/elastic/apm/agent/opentelemetry/sdk/OTelTracer.java +++ b/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-plugin/src/main/java/co/elastic/apm/agent/opentelemetry/sdk/OTelTracer.java @@ -23,14 +23,14 @@ import io.opentelemetry.api.trace.Tracer; public class OTelTracer implements Tracer { - private final ElasticApmTracer elasticApmTracer; + private final ElasticApmTracer tracer; - public OTelTracer(ElasticApmTracer elasticApmTracer) { - this.elasticApmTracer = elasticApmTracer; + public OTelTracer(ElasticApmTracer tracer) { + this.tracer = tracer; } @Override public SpanBuilder spanBuilder(String spanName) { - return new OTelSpanBuilder(spanName, elasticApmTracer); + return new OTelSpanBuilder(spanName, tracer); } } diff --git a/apm-agent-plugins/apm-opentracing-plugin/src/main/java/co/elastic/apm/agent/opentracingimpl/ExternalSpanContextInstrumentation.java b/apm-agent-plugins/apm-opentracing-plugin/src/main/java/co/elastic/apm/agent/opentracingimpl/ExternalSpanContextInstrumentation.java index 26f245971f1..3709bfd8712 100644 --- a/apm-agent-plugins/apm-opentracing-plugin/src/main/java/co/elastic/apm/agent/opentracingimpl/ExternalSpanContextInstrumentation.java +++ b/apm-agent-plugins/apm-opentracing-plugin/src/main/java/co/elastic/apm/agent/opentracingimpl/ExternalSpanContextInstrumentation.java @@ -18,8 +18,8 @@ */ package co.elastic.apm.agent.opentracingimpl; -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.transaction.TraceContext; import net.bytebuddy.asm.Advice; import net.bytebuddy.asm.Advice.AssignReturned.ToFields.ToField; @@ -117,12 +117,10 @@ public static String onExit(@Advice.FieldValue(value = "childTraceContext", typi @Nullable public static TraceContext parseTextMap(Iterable> textMap) { - ElasticApmTracer tracer = GlobalTracer.getTracerImpl(); - if (tracer != null) { - TraceContext childTraceContext = TraceContext.with64BitId(tracer); - if (TraceContext.>>getFromTraceContextTextHeaders().asChildOf(childTraceContext, textMap, OpenTracingTextMapBridge.instance())) { - return childTraceContext; - } + Tracer tracer = GlobalTracer.get(); + TraceContext childTraceContext = TraceContext.with64BitId(tracer); + if (TraceContext.>>getFromTraceContextTextHeaders().asChildOf(childTraceContext, textMap, OpenTracingTextMapBridge.instance())) { + return childTraceContext; } return null; } 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 d532f0da64f..381d2be8da9 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 @@ -20,6 +20,7 @@ import co.elastic.apm.agent.collections.LongList; import co.elastic.apm.agent.impl.ElasticApmTracer; +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.StackFrame; @@ -598,7 +599,7 @@ public static class Root extends CallTree implements Recyclable { private final LongHashSet activeSet = new LongHashSet(); - public Root(ElasticApmTracer tracer) { + public Root(Tracer tracer) { this.rootContext = TraceContext.with64BitId(tracer); } @@ -659,7 +660,7 @@ public void onDeactivation(byte[] deactivated, byte[] active, long timestamp) { } } - public void addStackTrace(ElasticApmTracer tracer, List stackTrace, long nanoTime, ObjectPool callTreePool, long minDurationNs) { + public void addStackTrace(Tracer tracer, List stackTrace, long nanoTime, ObjectPool callTreePool, long minDurationNs) { // only "materialize" trace context if there's actually an associated stack trace to the activation // avoids allocating a TraceContext for very short activations which have no effect on the CallTree anyway boolean firstFrameAfterActivation = false; 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 277759536fe..a38311b359a 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,6 +20,7 @@ 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/ProfilingFactory.java b/apm-agent-plugins/apm-profiling-plugin/src/main/java/co/elastic/apm/agent/profiler/ProfilingFactory.java index 400e28623cf..bce07721ae3 100644 --- a/apm-agent-plugins/apm-profiling-plugin/src/main/java/co/elastic/apm/agent/profiler/ProfilingFactory.java +++ b/apm-agent-plugins/apm-profiling-plugin/src/main/java/co/elastic/apm/agent/profiler/ProfilingFactory.java @@ -35,7 +35,7 @@ public ProfilingFactory(ElasticApmTracer tracer) { } @Override - public void start(ElasticApmTracer tracer) { + public void start(ElasticApmTracer tracer) throws Exception { profiler.start(tracer); tracer.registerSpanListener(new ProfilingActivationListener(tracer, profiler)); } 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 f58a90aa592..8739353e4ea 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 @@ -21,7 +21,7 @@ import co.elastic.apm.agent.configuration.CoreConfiguration; import co.elastic.apm.agent.configuration.converter.TimeDuration; 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; @@ -149,7 +149,7 @@ public void translateTo(ActivationEvent event, long sequence, TraceContext activ private final RingBuffer eventBuffer; private volatile boolean profilingSessionOngoing = false; private final Sequence sequence; - private final ElasticApmTracer tracer; + private final Tracer tracer; private final NanoClock nanoClock; private final ObjectPool rootPool; private final ThreadMatcher threadMatcher = new ThreadMatcher(); @@ -183,7 +183,7 @@ public void translateTo(ActivationEvent event, long sequence, TraceContext activ * @param tracer tracer * @param nanoClock clock */ - public SamplingProfiler(ElasticApmTracer tracer, NanoClock nanoClock) { + public SamplingProfiler(Tracer tracer, NanoClock nanoClock) { this(tracer, nanoClock, null, null); } @@ -197,7 +197,7 @@ public SamplingProfiler(ElasticApmTracer tracer, NanoClock nanoClock) { * @param activationEventsFile activation events file, if {@literal null} a temp file will be used * @param jfrFile java flight recorder file, if {@literal null} a temp file will be used instead */ - public SamplingProfiler(final ElasticApmTracer tracer, NanoClock nanoClock, @Nullable File activationEventsFile, @Nullable File jfrFile) { + public SamplingProfiler(final Tracer tracer, NanoClock nanoClock, @Nullable File activationEventsFile, @Nullable File jfrFile) { this.tracer = tracer; this.config = tracer.getConfig(ProfilingConfiguration.class); this.coreConfig = tracer.getConfig(CoreConfiguration.class); @@ -516,7 +516,7 @@ public void processTraces() throws IOException { logger.debug("Processing {} stack traces", stackTraceEvents.size()); } List stackFrames = new ArrayList<>(); - ElasticApmTracer tracer = this.tracer; + Tracer tracer = this.tracer; ActivationEvent event = new ActivationEvent(); long inferredSpansMinDuration = getInferredSpansMinDurationNs(); for (StackTraceEvent stackTrace : stackTraceEvents) { @@ -687,7 +687,7 @@ void copyFromFiles(Path activationEvents, Path traces) throws IOException { } @Override - public void start(ElasticApmTracer tracer) { + public void start(Tracer tracer) { scheduler.submit(this); } diff --git a/apm-agent-plugins/apm-profiling-plugin/src/test/java/co/elastic/apm/agent/profiler/CallTreeSpanifyTest.java b/apm-agent-plugins/apm-profiling-plugin/src/test/java/co/elastic/apm/agent/profiler/CallTreeSpanifyTest.java index 5481703f2a8..be0407e7199 100644 --- a/apm-agent-plugins/apm-profiling-plugin/src/test/java/co/elastic/apm/agent/profiler/CallTreeSpanifyTest.java +++ b/apm-agent-plugins/apm-profiling-plugin/src/test/java/co/elastic/apm/agent/profiler/CallTreeSpanifyTest.java @@ -22,6 +22,7 @@ import co.elastic.apm.agent.MockTracer; import co.elastic.apm.agent.configuration.SpyConfiguration; 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; diff --git a/apm-agent-plugins/apm-profiling-plugin/src/test/java/co/elastic/apm/agent/profiler/CallTreeTest.java b/apm-agent-plugins/apm-profiling-plugin/src/test/java/co/elastic/apm/agent/profiler/CallTreeTest.java index 1df9b469dc4..6e34419bc2b 100644 --- a/apm-agent-plugins/apm-profiling-plugin/src/test/java/co/elastic/apm/agent/profiler/CallTreeTest.java +++ b/apm-agent-plugins/apm-profiling-plugin/src/test/java/co/elastic/apm/agent/profiler/CallTreeTest.java @@ -23,6 +23,7 @@ import co.elastic.apm.agent.configuration.SpyConfiguration; import co.elastic.apm.agent.configuration.converter.TimeDuration; import co.elastic.apm.agent.impl.ElasticApmTracer; +import co.elastic.apm.agent.impl.Tracer; import co.elastic.apm.agent.impl.sampling.ConstantSampler; import co.elastic.apm.agent.impl.transaction.AbstractSpan; import co.elastic.apm.agent.impl.transaction.Span; @@ -1014,7 +1015,7 @@ public StackTraceEvent(List trace, long nanoTime) { } } - private static void handleSpanEvent(ElasticApmTracer tracer, Map> spanMap, String name, long nanoTime) { + private static void handleSpanEvent(Tracer tracer, Map> spanMap, String name, long nanoTime) { if (!spanMap.containsKey(name)) { Span span = tracer.getActive().createSpan(nanoTime / 1000).appendToName(name).activate(); spanMap.put(name, span); diff --git a/apm-agent-plugins/apm-profiling-plugin/src/test/java/co/elastic/apm/agent/profiler/SamplingProfilerQueueTest.java b/apm-agent-plugins/apm-profiling-plugin/src/test/java/co/elastic/apm/agent/profiler/SamplingProfilerQueueTest.java index ecf96619cd0..58884f2a5de 100644 --- a/apm-agent-plugins/apm-profiling-plugin/src/test/java/co/elastic/apm/agent/profiler/SamplingProfilerQueueTest.java +++ b/apm-agent-plugins/apm-profiling-plugin/src/test/java/co/elastic/apm/agent/profiler/SamplingProfilerQueueTest.java @@ -19,7 +19,7 @@ package co.elastic.apm.agent.profiler; import co.elastic.apm.agent.MockTracer; -import co.elastic.apm.agent.impl.ElasticApmTracer; +import co.elastic.apm.agent.impl.Tracer; import co.elastic.apm.agent.impl.transaction.TraceContext; import co.elastic.apm.agent.testutils.DisabledOnAppleSilicon; import org.junit.jupiter.api.Test; @@ -36,7 +36,7 @@ public class SamplingProfilerQueueTest { void testFillQueue() throws Exception { System.out.println(System.getProperty("os.name")); - ElasticApmTracer tracer = MockTracer.create(); + Tracer tracer = MockTracer.create(); SamplingProfiler profiler = new SamplingProfiler(tracer, new SystemNanoClock()); 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 24f212a52f1..a4e31f72fb1 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.ElasticApmTracer; +import co.elastic.apm.agent.impl.Tracer; import net.bytebuddy.asm.Advice; import net.bytebuddy.description.method.MethodDescription; import net.bytebuddy.matcher.ElementMatcher; @@ -33,7 +33,7 @@ import static net.bytebuddy.matcher.ElementMatchers.takesArgument; public class Quartz1JobTransactionNameInstrumentation extends AbstractJobTransactionNameInstrumentation { - public Quartz1JobTransactionNameInstrumentation(ElasticApmTracer tracer) { + public Quartz1JobTransactionNameInstrumentation(Tracer tracer) { super(tracer); } diff --git a/apm-agent-plugins/apm-quartz-job-plugin/apm-quartz-1-plugin/src/test/java/co/elastic/apm/agent/quartzjob/Quartz1JobTransactionNameInstrumentationTest.java b/apm-agent-plugins/apm-quartz-job-plugin/apm-quartz-1-plugin/src/test/java/co/elastic/apm/agent/quartzjob/Quartz1JobTransactionNameInstrumentationTest.java index 9070b85e0ff..d4857ce82c0 100644 --- a/apm-agent-plugins/apm-quartz-job-plugin/apm-quartz-1-plugin/src/test/java/co/elastic/apm/agent/quartzjob/Quartz1JobTransactionNameInstrumentationTest.java +++ b/apm-agent-plugins/apm-quartz-job-plugin/apm-quartz-1-plugin/src/test/java/co/elastic/apm/agent/quartzjob/Quartz1JobTransactionNameInstrumentationTest.java @@ -18,7 +18,7 @@ */ package co.elastic.apm.agent.quartzjob; -import co.elastic.apm.agent.impl.ElasticApmTracer; +import co.elastic.apm.agent.impl.Tracer; import co.elastic.apm.agent.impl.transaction.Outcome; import co.elastic.apm.agent.impl.transaction.Transaction; import org.quartz.Job; @@ -65,7 +65,7 @@ JobDetail buildJobDetailTestJob(String name, @Nullable String groupName) { } @Override - void executeTestJobCreatingSpan(ElasticApmTracer tracer, boolean traced) throws JobExecutionException { + void executeTestJobCreatingSpan(Tracer tracer, boolean traced) throws JobExecutionException { new TestJobCreatingSpan(tracer, traced).execute(null); } @@ -118,10 +118,10 @@ public void execute(JobExecutionContext context) throws JobExecutionException { } public static class TestJobCreatingSpan implements Job { - private final ElasticApmTracer tracer; + private final Tracer tracer; private final boolean traced; - public TestJobCreatingSpan(ElasticApmTracer tracer, boolean traced) { + public TestJobCreatingSpan(Tracer tracer, boolean traced) { this.tracer = tracer; this.traced = traced; } 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 703f2c5a955..f2ce10e5c47 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.ElasticApmTracer; +import co.elastic.apm.agent.impl.Tracer; import net.bytebuddy.asm.Advice; import net.bytebuddy.description.method.MethodDescription; import net.bytebuddy.matcher.ElementMatcher; @@ -32,7 +32,7 @@ import static net.bytebuddy.matcher.ElementMatchers.takesArgument; public class Quartz2JobTransactionNameInstrumentation extends AbstractJobTransactionNameInstrumentation { - public Quartz2JobTransactionNameInstrumentation(ElasticApmTracer tracer) { + public Quartz2JobTransactionNameInstrumentation(Tracer tracer) { super(tracer); } diff --git a/apm-agent-plugins/apm-quartz-job-plugin/apm-quartz-2-plugin/src/test/java/co/elastic/apm/agent/quartzjob/Quartz2JobTransactionNameInstrumentationTest.java b/apm-agent-plugins/apm-quartz-job-plugin/apm-quartz-2-plugin/src/test/java/co/elastic/apm/agent/quartzjob/Quartz2JobTransactionNameInstrumentationTest.java index a2de6a889a7..ac69a8e62fc 100644 --- a/apm-agent-plugins/apm-quartz-job-plugin/apm-quartz-2-plugin/src/test/java/co/elastic/apm/agent/quartzjob/Quartz2JobTransactionNameInstrumentationTest.java +++ b/apm-agent-plugins/apm-quartz-job-plugin/apm-quartz-2-plugin/src/test/java/co/elastic/apm/agent/quartzjob/Quartz2JobTransactionNameInstrumentationTest.java @@ -18,7 +18,7 @@ */ package co.elastic.apm.agent.quartzjob; -import co.elastic.apm.agent.impl.ElasticApmTracer; +import co.elastic.apm.agent.impl.Tracer; import co.elastic.apm.agent.impl.transaction.Outcome; import co.elastic.apm.agent.impl.transaction.Transaction; import org.quartz.Job; @@ -74,7 +74,7 @@ JobDetail buildJobDetailTestJob(String name, @Nullable String groupName) { } @Override - void executeTestJobCreatingSpan(ElasticApmTracer tracer, boolean traced) throws JobExecutionException { + void executeTestJobCreatingSpan(Tracer tracer, boolean traced) throws JobExecutionException { new TestJobCreatingSpan(tracer, traced).execute(null); } @@ -125,10 +125,10 @@ public void execute(JobExecutionContext context) throws JobExecutionException { } public static class TestJobCreatingSpan implements Job { - private final ElasticApmTracer tracer; + private final Tracer tracer; private final boolean traced; - public TestJobCreatingSpan(ElasticApmTracer tracer, boolean traced) { + public TestJobCreatingSpan(Tracer tracer, boolean traced) { this.tracer = tracer; this.traced = traced; } 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 a2bbf4bcd4f..a58ef6fec1e 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,8 +19,8 @@ package co.elastic.apm.agent.quartzjob; import co.elastic.apm.agent.bci.TracerAwareInstrumentation; -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.stacktrace.StacktraceConfiguration; import co.elastic.apm.agent.impl.transaction.AbstractSpan; import co.elastic.apm.agent.impl.transaction.Outcome; @@ -51,7 +51,7 @@ public abstract class AbstractJobTransactionNameInstrumentation extends TracerAw private final Collection applicationPackages; - protected AbstractJobTransactionNameInstrumentation(ElasticApmTracer tracer) { + protected AbstractJobTransactionNameInstrumentation(Tracer tracer) { applicationPackages = tracer.getConfig(StacktraceConfiguration.class).getApplicationPackages(); } diff --git a/apm-agent-plugins/apm-quartz-job-plugin/quartz-common/src/test/java/co/elastic/apm/agent/quartzjob/AbstractJobTransactionNameInstrumentationTest.java b/apm-agent-plugins/apm-quartz-job-plugin/quartz-common/src/test/java/co/elastic/apm/agent/quartzjob/AbstractJobTransactionNameInstrumentationTest.java index 4e5fa2803cd..07fbff96434 100644 --- a/apm-agent-plugins/apm-quartz-job-plugin/quartz-common/src/test/java/co/elastic/apm/agent/quartzjob/AbstractJobTransactionNameInstrumentationTest.java +++ b/apm-agent-plugins/apm-quartz-job-plugin/quartz-common/src/test/java/co/elastic/apm/agent/quartzjob/AbstractJobTransactionNameInstrumentationTest.java @@ -19,7 +19,7 @@ package co.elastic.apm.agent.quartzjob; import co.elastic.apm.agent.AbstractInstrumentationTest; -import co.elastic.apm.agent.impl.ElasticApmTracer; +import co.elastic.apm.agent.impl.Tracer; import co.elastic.apm.agent.impl.TracerInternalApiUtils; import co.elastic.apm.agent.impl.transaction.Outcome; import co.elastic.apm.agent.impl.transaction.Span; @@ -168,7 +168,7 @@ public Transaction verifyTransaction(Transaction transaction, String expectedNam abstract JobDetail buildJobDetailTestJob(String name, String groupName); - abstract void executeTestJobCreatingSpan(ElasticApmTracer tracer, boolean traced) throws JobExecutionException; + abstract void executeTestJobCreatingSpan(Tracer tracer, boolean traced) throws JobExecutionException; abstract JobDetail buildJobDetailTestJobWithResult(String name); 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 bc95d431956..5db3d494459 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 @@ -32,8 +32,8 @@ public abstract class AbstractBaseInstrumentation extends TracerAwareInstrumentation { - private static final CoreConfiguration coreConfiguration = GlobalTracer.requireTracerImpl().getConfig(CoreConfiguration.class); - private static final MessagingConfiguration messagingConfiguration = GlobalTracer.requireTracerImpl().getConfig(MessagingConfiguration.class); + private static final CoreConfiguration coreConfiguration = GlobalTracer.get().getConfig(CoreConfiguration.class); + private static final MessagingConfiguration messagingConfiguration = GlobalTracer.get().getConfig(MessagingConfiguration.class); /** * @param name name of the exchange or queue 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 80054e29f72..475ca37e3fe 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.ElasticApmTracer; +import co.elastic.apm.agent.impl.Tracer; import co.elastic.apm.agent.sdk.logging.Logger; import co.elastic.apm.agent.sdk.logging.LoggerFactory; import org.springframework.amqp.core.Message; @@ -29,10 +29,10 @@ public class MessageBatchHelper { public static final Logger logger = LoggerFactory.getLogger(MessageBatchHelper.class); - private final ElasticApmTracer tracer; + private final Tracer tracer; private final SpringAmqpTransactionHelper transactionHelper; - public MessageBatchHelper(ElasticApmTracer tracer, SpringAmqpTransactionHelper transactionHelper) { + public MessageBatchHelper(Tracer tracer, SpringAmqpTransactionHelper transactionHelper) { this.tracer = tracer; this.transactionHelper = transactionHelper; } 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 7a5c47e311d..03630860f76 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,12 +19,11 @@ package co.elastic.apm.agent.rabbitmq; -import co.elastic.apm.agent.impl.ElasticApmTracer; +import co.elastic.apm.agent.impl.Tracer; import co.elastic.apm.agent.impl.transaction.Transaction; import co.elastic.apm.agent.sdk.logging.Logger; import co.elastic.apm.agent.sdk.logging.LoggerFactory; import org.springframework.amqp.core.Message; -import org.springframework.amqp.core.MessageProperties; import java.util.Iterator; @@ -33,10 +32,10 @@ public class MessageBatchIteratorWrapper implements Iterator { public static final Logger logger = LoggerFactory.getLogger(MessageBatchIteratorWrapper.class); private final Iterator delegate; - private final ElasticApmTracer tracer; + private final Tracer tracer; private final SpringAmqpTransactionHelper transactionHelper; - public MessageBatchIteratorWrapper(Iterator delegate, ElasticApmTracer tracer, SpringAmqpTransactionHelper transactionHelper) { + public MessageBatchIteratorWrapper(Iterator delegate, Tracer tracer, SpringAmqpTransactionHelper transactionHelper) { this.delegate = delegate; this.tracer = tracer; this.transactionHelper = transactionHelper; 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 836e7d88fe2..37f3608a1d8 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.ElasticApmTracer; +import co.elastic.apm.agent.impl.Tracer; import org.springframework.amqp.core.Message; import java.util.Collection; @@ -30,10 +30,10 @@ public class MessageBatchListWrapper implements List { private final List delegate; - private final ElasticApmTracer tracer; + private final Tracer tracer; private final SpringAmqpTransactionHelper transactionHelper; - public MessageBatchListWrapper(List delegate, ElasticApmTracer tracer, SpringAmqpTransactionHelper transactionHelper) { + public MessageBatchListWrapper(List delegate, Tracer tracer, SpringAmqpTransactionHelper transactionHelper) { this.delegate = delegate; this.tracer = tracer; this.transactionHelper = transactionHelper; 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 f1c70e981d9..3f78e6b7170 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,8 +20,8 @@ import co.elastic.apm.agent.configuration.MessagingConfiguration; -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.transaction.AbstractSpan; import co.elastic.apm.agent.impl.transaction.TraceContext; import co.elastic.apm.agent.impl.transaction.Transaction; @@ -63,9 +63,9 @@ public static class MessageListenerContainerWrappingAdvice extends BaseAdvice { private static final MessagingConfiguration messagingConfiguration; static { - ElasticApmTracer elasticApmTracer = GlobalTracer.requireTracerImpl(); - messageBatchHelper = new MessageBatchHelper(elasticApmTracer, transactionHelper); - messagingConfiguration = elasticApmTracer.getConfig(MessagingConfiguration.class); + Tracer tracer = GlobalTracer.get(); + messageBatchHelper = new MessageBatchHelper(tracer, transactionHelper); + messagingConfiguration = tracer.getConfig(MessagingConfiguration.class); oneTimeTransactionCreationWarningLogger = LoggerUtils.logOnce(LoggerFactory.getLogger("Spring-AMQP-Batch-Logger")); } 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 078c77cfd92..6cb63aac0df 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,7 +18,7 @@ */ package co.elastic.apm.agent.rabbitmq; -import co.elastic.apm.agent.impl.ElasticApmTracer; +import co.elastic.apm.agent.impl.Tracer; import co.elastic.apm.agent.impl.transaction.Transaction; import co.elastic.apm.agent.rabbitmq.header.SpringRabbitMQTextHeaderGetter; import co.elastic.apm.agent.util.PrivilegedActionUtils; @@ -29,9 +29,9 @@ public class SpringAmqpTransactionHelper { - private final ElasticApmTracer tracer; + private final Tracer tracer; - public SpringAmqpTransactionHelper(ElasticApmTracer tracer) { + public SpringAmqpTransactionHelper(Tracer tracer) { this.tracer = tracer; } 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 3c41e033aae..218b02b7fe1 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.ElasticApmTracer; import co.elastic.apm.agent.impl.GlobalTracer; +import co.elastic.apm.agent.impl.Tracer; import net.bytebuddy.description.type.TypeDescription; import net.bytebuddy.matcher.ElementMatcher; @@ -55,8 +55,8 @@ static class BaseAdvice { protected static final SpringAmqpTransactionHelper transactionHelper; static { - ElasticApmTracer elasticApmTracer = GlobalTracer.requireTracerImpl(); - transactionHelper = new SpringAmqpTransactionHelper(elasticApmTracer); + Tracer tracer = GlobalTracer.get(); + transactionHelper = new SpringAmqpTransactionHelper(tracer); } } } 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 fbfe6c2bd83..9e56f0a43d7 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,7 +20,7 @@ import co.elastic.apm.agent.bci.TracerAwareInstrumentation; import co.elastic.apm.agent.bci.bytebuddy.SimpleMethodSignatureOffsetMappingFactory.SimpleMethodSignature; -import co.elastic.apm.agent.impl.ElasticApmTracer; +import co.elastic.apm.agent.impl.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; @@ -52,7 +52,7 @@ public class ScheduledTransactionNameInstrumentation extends TracerAwareInstrume private final Collection applicationPackages; - public ScheduledTransactionNameInstrumentation(ElasticApmTracer tracer) { + public ScheduledTransactionNameInstrumentation(Tracer tracer) { applicationPackages = tracer.getConfig(StacktraceConfiguration.class).getApplicationPackages(); } 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 5435b521fae..440a10f25ea 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,7 +20,7 @@ import co.elastic.apm.agent.bci.TracerAwareInstrumentation; import co.elastic.apm.agent.bci.bytebuddy.SimpleMethodSignatureOffsetMappingFactory; -import co.elastic.apm.agent.impl.ElasticApmTracer; +import co.elastic.apm.agent.impl.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; @@ -51,7 +51,7 @@ public class TimerTaskInstrumentation extends TracerAwareInstrumentation { private final Collection applicationPackages; - public TimerTaskInstrumentation(ElasticApmTracer tracer) { + public TimerTaskInstrumentation(Tracer tracer) { applicationPackages = tracer.getConfig(StacktraceConfiguration.class).getApplicationPackages(); } 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 f7d3aba243b..4fead910dcd 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 @@ -50,7 +50,7 @@ public String getAdviceClassName() { } public static class JakartaStartAsyncAdvice { - private static final AsyncContextAdviceHelper asyncHelper = new JakartaAsyncContextAdviceHelper(GlobalTracer.requireTracerImpl()); + private static final AsyncContextAdviceHelper asyncHelper = new JakartaAsyncContextAdviceHelper(GlobalTracer.get()); @Advice.OnMethodExit(suppress = Throwable.class, inline = false) public static void onExitStartAsync(@Advice.Return @Nullable AsyncContext asyncContext) { 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 dfe2c4cf9da..3473ae22dc7 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 @@ -51,7 +51,7 @@ public String getAdviceClassName() { } public static class StartAsyncAdvice { - private static final AsyncContextAdviceHelper asyncHelper = new JavaxAsyncContextAdviceHelper(GlobalTracer.requireTracerImpl());; + private static final AsyncContextAdviceHelper asyncHelper = new JavaxAsyncContextAdviceHelper(GlobalTracer.get());; @Advice.OnMethodExit(suppress = Throwable.class, inline = false) public static void onExitStartAsync(@Advice.Return @Nullable AsyncContext asyncContext) { 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 c18555e94fc..7233bbaec9c 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,9 +19,9 @@ package co.elastic.apm.agent.servlet; 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.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; @@ -35,7 +35,6 @@ import co.elastic.apm.agent.util.TransactionNameUtils; import javax.annotation.Nullable; -import java.security.Principal; import java.util.Arrays; import java.util.Enumeration; import java.util.List; @@ -62,10 +61,7 @@ public static adapter, Object servletRequest) { - ElasticApmTracer tracer = GlobalTracer.getTracerImpl(); - if (tracer == null) { - return null; - } + Tracer tracer = GlobalTracer.get(); final HttpServletRequest httpServletRequest = adapter.asHttpServletRequest(servletRequest); if (httpServletRequest == null) { @@ -167,10 +163,7 @@ public static METHODS_WITH_BODY = new HashSet<>(Arrays.asList("POST", "PUT", "PATCH", "DELETE")); private final CoreConfiguration coreConfiguration; private final WebConfiguration webConfiguration; - private final ElasticApmTracer tracer; + private final Tracer tracer; private final HttpServerHelper serverHelper; - public ServletTransactionHelper(ElasticApmTracer tracer) { + public ServletTransactionHelper(Tracer tracer) { this.coreConfiguration = tracer.getConfig(CoreConfiguration.class); this.webConfiguration = tracer.getConfig(WebConfiguration.class); this.tracer = tracer; 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 d14348df586..adca4c22714 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,7 +18,6 @@ */ package co.elastic.apm.agent.servlet.helper; -import co.elastic.apm.agent.impl.ElasticApmTracer; import co.elastic.apm.agent.impl.Tracer; import co.elastic.apm.agent.impl.transaction.Transaction; import co.elastic.apm.agent.objectpool.Allocator; @@ -38,7 +37,7 @@ public class JakartaAsyncContextAdviceHelper implements AsyncContextAdviceHelper private final ServletTransactionHelper servletTransactionHelper; private final Tracer tracer; - public JakartaAsyncContextAdviceHelper(ElasticApmTracer tracer) { + public JakartaAsyncContextAdviceHelper(Tracer tracer) { this.tracer = tracer; this.servletTransactionHelper = new ServletTransactionHelper(tracer); this.asyncListenerObjectPool = tracer.getObjectPoolFactory().createRecyclableObjectPool(MAX_POOLED_ELEMENTS, 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 4d23ecdbf63..ee5add938e3 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,7 +18,6 @@ */ package co.elastic.apm.agent.servlet.helper; -import co.elastic.apm.agent.impl.ElasticApmTracer; import co.elastic.apm.agent.impl.Tracer; import co.elastic.apm.agent.impl.transaction.Transaction; import co.elastic.apm.agent.objectpool.Allocator; @@ -39,7 +38,7 @@ public class JavaxAsyncContextAdviceHelper implements AsyncContextAdviceHelper customTransactionName() { // Transaction should be active, even if we are outside of Mono/Flux execution // In practice, it's called after onSubscribe and before onNext, thus the active context is not provided // by reactor plugin, but only by the webflux plugin that keeps the transaction active. - ElasticApmTracer tracer = GlobalTracer.requireTracerImpl(); + Tracer tracer = GlobalTracer.get(); Transaction transaction = Objects.requireNonNull(tracer.currentTransaction(), "active transaction is required"); // This mimics setting the name through the public API. We cannot use the public API if we want to test span recycling transaction.withName("user-provided-name", AbstractSpan.PRIO_USER_SUPPLIED); diff --git a/apm-agent-plugins/apm-spring-webflux/apm-spring-webflux-testapp/src/main/java/co/elastic/apm/agent/springwebflux/testapp/GreetingFunctional.java b/apm-agent-plugins/apm-spring-webflux/apm-spring-webflux-testapp/src/main/java/co/elastic/apm/agent/springwebflux/testapp/GreetingFunctional.java index 8c3a70aadbb..15517938eed 100644 --- a/apm-agent-plugins/apm-spring-webflux/apm-spring-webflux-testapp/src/main/java/co/elastic/apm/agent/springwebflux/testapp/GreetingFunctional.java +++ b/apm-agent-plugins/apm-spring-webflux/apm-spring-webflux-testapp/src/main/java/co/elastic/apm/agent/springwebflux/testapp/GreetingFunctional.java @@ -18,8 +18,8 @@ */ package co.elastic.apm.agent.springwebflux.testapp; -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.transaction.AbstractSpan; import co.elastic.apm.agent.impl.transaction.Transaction; import org.springframework.context.annotation.Bean; @@ -81,7 +81,7 @@ public RouterFunction route(GreetingHandler greetingHandler) { .GET("/functional/duration", accept(MediaType.TEXT_PLAIN), request -> response(greetingHandler.duration(getDuration(request)))) // custom transaction name set through API .GET("/functional/custom-transaction-name", accept(MediaType.TEXT_PLAIN), request -> { - ElasticApmTracer tracer = GlobalTracer.requireTracerImpl(); + Tracer tracer = GlobalTracer.get(); Transaction transaction = Objects.requireNonNull(tracer.currentTransaction(), "active transaction is required"); // This mimics setting the name through the public API. We cannot use the public API if we want to test span recycling transaction.withName("user-provided-name", AbstractSpan.PRIO_USER_SUPPLIED); diff --git a/apm-agent-plugins/apm-spring-webflux/apm-spring-webflux-testapp/src/main/java/co/elastic/apm/agent/springwebflux/testapp/GreetingHandler.java b/apm-agent-plugins/apm-spring-webflux/apm-spring-webflux-testapp/src/main/java/co/elastic/apm/agent/springwebflux/testapp/GreetingHandler.java index e27fdf38744..33c2c258f62 100644 --- a/apm-agent-plugins/apm-spring-webflux/apm-spring-webflux-testapp/src/main/java/co/elastic/apm/agent/springwebflux/testapp/GreetingHandler.java +++ b/apm-agent-plugins/apm-spring-webflux/apm-spring-webflux-testapp/src/main/java/co/elastic/apm/agent/springwebflux/testapp/GreetingHandler.java @@ -73,7 +73,7 @@ public Flux childSpans(int count, long delayMillis, long durationMillis) .delayElements(Duration.ofMillis(delayMillis)) .map(i -> String.format("child %d", i)) .doOnNext(name -> { - Span span = Objects.requireNonNull(GlobalTracer.requireTracerImpl().currentTransaction()).createSpan(); + Span span = Objects.requireNonNull(GlobalTracer.get().currentTransaction()).createSpan(); span.withName(String.format("%s id=%s", name, span.getTraceContext().getId())); try { fakeWork(durationMillis); diff --git a/apm-agent-plugins/apm-spring-webmvc-plugin/src/main/java/co/elastic/apm/agent/springwebmvc/SpringTransactionNameInstrumentation.java b/apm-agent-plugins/apm-spring-webmvc-plugin/src/main/java/co/elastic/apm/agent/springwebmvc/SpringTransactionNameInstrumentation.java index 4765effbd99..f249f184a8b 100644 --- a/apm-agent-plugins/apm-spring-webmvc-plugin/src/main/java/co/elastic/apm/agent/springwebmvc/SpringTransactionNameInstrumentation.java +++ b/apm-agent-plugins/apm-spring-webmvc-plugin/src/main/java/co/elastic/apm/agent/springwebmvc/SpringTransactionNameInstrumentation.java @@ -102,7 +102,7 @@ public Collection getInstrumentationGroupNames() { public static class HandlerAdapterAdvice { - private static final WebConfiguration webConfig = GlobalTracer.requireTracerImpl().getConfig(WebConfiguration.class);; + private static final WebConfiguration webConfig = GlobalTracer.get().getConfig(WebConfiguration.class);; @Advice.OnMethodEnter(suppress = Throwable.class, inline = false) public static void setTransactionName(@Advice.Argument(0) HttpServletRequest request, diff --git a/apm-agent-plugins/apm-struts-plugin/src/main/java/co/elastic/apm/agent/struts/ExecuteOperationsAdvice.java b/apm-agent-plugins/apm-struts-plugin/src/main/java/co/elastic/apm/agent/struts/ExecuteOperationsAdvice.java index 304b39237e1..f06fbf7c935 100644 --- a/apm-agent-plugins/apm-struts-plugin/src/main/java/co/elastic/apm/agent/struts/ExecuteOperationsAdvice.java +++ b/apm-agent-plugins/apm-struts-plugin/src/main/java/co/elastic/apm/agent/struts/ExecuteOperationsAdvice.java @@ -30,7 +30,7 @@ public class ExecuteOperationsAdvice { - private static final WebConfiguration webConfig = GlobalTracer.requireTracerImpl().getConfig(WebConfiguration.class); + private static final WebConfiguration webConfig = GlobalTracer.get().getConfig(WebConfiguration.class); @Advice.OnMethodExit(suppress = Throwable.class, inline = false) public static void setTransactionName(@Advice.Argument(0) HttpServletRequest request, @Advice.Return boolean handled) { diff --git a/apm-agent-plugins/apm-vertx/apm-vertx-common/src/main/java/co/elastic/apm/agent/vertx/AbstractHttpTransactionHelper.java b/apm-agent-plugins/apm-vertx/apm-vertx-common/src/main/java/co/elastic/apm/agent/vertx/AbstractHttpTransactionHelper.java index e11ed41424f..ad92d70829b 100644 --- a/apm-agent-plugins/apm-vertx/apm-vertx-common/src/main/java/co/elastic/apm/agent/vertx/AbstractHttpTransactionHelper.java +++ b/apm-agent-plugins/apm-vertx/apm-vertx-common/src/main/java/co/elastic/apm/agent/vertx/AbstractHttpTransactionHelper.java @@ -20,7 +20,6 @@ import co.elastic.apm.agent.configuration.CoreConfiguration; import co.elastic.apm.agent.httpserver.HttpServerHelper; -import co.elastic.apm.agent.impl.ElasticApmTracer; import co.elastic.apm.agent.impl.Tracer; import co.elastic.apm.agent.impl.context.Request; import co.elastic.apm.agent.impl.context.Response; @@ -58,7 +57,7 @@ public abstract class AbstractHttpTransactionHelper { protected final HttpServerHelper serverHelper; - protected AbstractHttpTransactionHelper(ElasticApmTracer tracer) { + protected AbstractHttpTransactionHelper(Tracer tracer) { this.tracer = tracer; this.webConfiguration = tracer.getConfig(WebConfiguration.class); this.coreConfiguration = tracer.getConfig(CoreConfiguration.class); diff --git a/apm-agent-plugins/apm-vertx/apm-vertx-common/src/main/java/co/elastic/apm/agent/vertx/AbstractVertxWebHelper.java b/apm-agent-plugins/apm-vertx/apm-vertx-common/src/main/java/co/elastic/apm/agent/vertx/AbstractVertxWebHelper.java index 0fcebf7e06d..525561830fb 100644 --- a/apm-agent-plugins/apm-vertx/apm-vertx-common/src/main/java/co/elastic/apm/agent/vertx/AbstractVertxWebHelper.java +++ b/apm-agent-plugins/apm-vertx/apm-vertx-common/src/main/java/co/elastic/apm/agent/vertx/AbstractVertxWebHelper.java @@ -18,7 +18,7 @@ */ package co.elastic.apm.agent.vertx; -import co.elastic.apm.agent.impl.ElasticApmTracer; +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; @@ -56,7 +56,7 @@ public abstract class AbstractVertxWebHelper extends AbstractHttpTransactionHelp private final MultiMapHeadersGetterSetter headerGetter = new MultiMapHeadersGetterSetter(); - protected AbstractVertxWebHelper(ElasticApmTracer tracer) { + protected AbstractVertxWebHelper(Tracer tracer) { super(tracer); } diff --git a/apm-agent-plugins/apm-vertx/apm-vertx-common/src/test/java/co/elastic/apm/agent/vertx/helper/HandlerWithCustomNamedSpan.java b/apm-agent-plugins/apm-vertx/apm-vertx-common/src/test/java/co/elastic/apm/agent/vertx/helper/HandlerWithCustomNamedSpan.java index 39433d905c6..8bd2a176661 100644 --- a/apm-agent-plugins/apm-vertx/apm-vertx-common/src/test/java/co/elastic/apm/agent/vertx/helper/HandlerWithCustomNamedSpan.java +++ b/apm-agent-plugins/apm-vertx/apm-vertx-common/src/test/java/co/elastic/apm/agent/vertx/helper/HandlerWithCustomNamedSpan.java @@ -38,7 +38,7 @@ public HandlerWithCustomNamedSpan(Handler handler, RoutingContex @Override public void handle(Void v) { - AbstractSpan active = GlobalTracer.requireTracerImpl().getActive(); + AbstractSpan active = GlobalTracer.get().getActive(); if (active == null) { return; } diff --git a/apm-agent-plugins/apm-vertx/apm-vertx3-plugin/src/main/java/co/elastic/apm/agent/vertx/v3/web/WebHelper.java b/apm-agent-plugins/apm-vertx/apm-vertx3-plugin/src/main/java/co/elastic/apm/agent/vertx/v3/web/WebHelper.java index b1ae5d22e28..f4c15b4ea3e 100644 --- a/apm-agent-plugins/apm-vertx/apm-vertx3-plugin/src/main/java/co/elastic/apm/agent/vertx/v3/web/WebHelper.java +++ b/apm-agent-plugins/apm-vertx/apm-vertx3-plugin/src/main/java/co/elastic/apm/agent/vertx/v3/web/WebHelper.java @@ -19,8 +19,8 @@ package co.elastic.apm.agent.vertx.v3.web; import co.elastic.apm.agent.collections.WeakConcurrentProviderImpl; -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.transaction.Transaction; import co.elastic.apm.agent.sdk.logging.Logger; import co.elastic.apm.agent.sdk.logging.LoggerFactory; @@ -36,7 +36,7 @@ public class WebHelper extends AbstractVertxWebHelper { private static final Logger log = LoggerFactory.getLogger(WebHelper.class); - private static final WebHelper INSTANCE = new WebHelper(GlobalTracer.requireTracerImpl()); + private static final WebHelper INSTANCE = new WebHelper(GlobalTracer.get()); static final WeakMap transactionMap = WeakConcurrentProviderImpl.createWeakSpanMap(); @@ -48,7 +48,7 @@ public static WebHelper getInstance() { // that should do nothing other than returning the wrapped delegate instance of type HttpServerRequestImpl. private final NoopHandler noopHandler = new NoopHandler(); - WebHelper(ElasticApmTracer tracer) { + WebHelper(Tracer tracer) { super(tracer); } diff --git a/apm-agent-plugins/apm-vertx/apm-vertx4-plugin/src/main/java/co/elastic/apm/agent/vertx/v4/web/WebHelper.java b/apm-agent-plugins/apm-vertx/apm-vertx4-plugin/src/main/java/co/elastic/apm/agent/vertx/v4/web/WebHelper.java index fc62c2c522f..acb76bc4dfb 100644 --- a/apm-agent-plugins/apm-vertx/apm-vertx4-plugin/src/main/java/co/elastic/apm/agent/vertx/v4/web/WebHelper.java +++ b/apm-agent-plugins/apm-vertx/apm-vertx4-plugin/src/main/java/co/elastic/apm/agent/vertx/v4/web/WebHelper.java @@ -18,8 +18,8 @@ */ package co.elastic.apm.agent.vertx.v4.web; -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.transaction.Transaction; import co.elastic.apm.agent.vertx.AbstractVertxWebHelper; import io.vertx.core.Context; @@ -30,13 +30,13 @@ public class WebHelper extends AbstractVertxWebHelper { - private static final WebHelper INSTANCE = new WebHelper(GlobalTracer.requireTracerImpl()); + private static final WebHelper INSTANCE = new WebHelper(GlobalTracer.get()); public static WebHelper getInstance() { return INSTANCE; } - private WebHelper(ElasticApmTracer tracer) { + private WebHelper(Tracer tracer) { super(tracer); }