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

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ user to configure an arbitrary agent version that will be downloaded from maven

[float]
===== Refactorings
* Migrate Several plugins to indy dispatcher {pull}2087[#2087], {pull}2090[#2090]
* Migrate several plugins to indy dispatcher {pull}2087[#2087], {pull}2088[#2088], {pull}2090[#2090]

[[release-notes-1.x]]
=== Java Agent version 1.x
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,17 @@
* specific language governing permissions and limitations
* under the License.
*/
package co.elastic.apm.agent.es.restclient.v5_6;
package co.elastic.apm.agent.esrestclient.v5_6;

import co.elastic.apm.agent.es.restclient.ElasticsearchRestClientInstrumentation;
import co.elastic.apm.agent.es.restclient.ElasticsearchRestClientInstrumentationHelper;
import co.elastic.apm.agent.impl.ElasticApmTracer;
import co.elastic.apm.agent.esrestclient.ElasticsearchRestClientInstrumentation;
import co.elastic.apm.agent.esrestclient.ElasticsearchRestClientInstrumentationHelper;
import co.elastic.apm.agent.impl.transaction.Span;
import co.elastic.apm.agent.sdk.advice.AssignTo;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;
import org.apache.http.HttpEntity;
import org.elasticsearch.client.Response;
import org.elasticsearch.client.ResponseListener;

import javax.annotation.Nullable;
Expand All @@ -41,13 +39,9 @@

public class ElasticsearchClientAsyncInstrumentation extends ElasticsearchRestClientInstrumentation {

public ElasticsearchClientAsyncInstrumentation(ElasticApmTracer tracer) {
super(tracer);
}

@Override
public String getAdviceClassName() {
return "co.elastic.apm.agent.es.restclient.v5_6.ElasticsearchClientAsyncInstrumentation$ElasticsearchRestClientAsyncAdvice";
return getClass().getName() + "$ElasticsearchRestClientAsyncAdvice";
}

@Override
Expand All @@ -70,28 +64,27 @@ public ElementMatcher<? super MethodDescription> getMethodMatcher() {

public static class ElasticsearchRestClientAsyncAdvice {

private static final ElasticsearchRestClientInstrumentationHelper helper = ElasticsearchRestClientInstrumentationHelper.get();

@Nullable
@AssignTo.Argument(index = 1, value = 5)
@Advice.OnMethodEnter(suppress = Throwable.class)
@Advice.OnMethodEnter(suppress = Throwable.class, inline = false)
public static Object[] onBeforeExecute(@Advice.Argument(0) String method,
@Advice.Argument(1) String endpoint,
@Advice.Argument(3) @Nullable HttpEntity entity,
@Advice.Argument(5) ResponseListener responseListener) {

ElasticsearchRestClientInstrumentationHelper<HttpEntity, Response, ResponseListener> helper = esClientInstrHelperManager.getForClassLoaderOfClass(Response.class);
if (helper != null) {
Span span = helper.createClientSpan(method, endpoint, entity);
if (span != null) {
Object[] ret = new Object[2];
ret[0] = span;
ret[1] = helper.<ResponseListener>wrapResponseListener(responseListener, span);
return ret;
}
Span span = helper.createClientSpan(method, endpoint, entity);
if (span != null) {
Object[] ret = new Object[2];
ret[0] = span;
ret[1] = helper.wrapResponseListener(responseListener, span);
return ret;
}
return null;
}

@Advice.OnMethodExit(suppress = Throwable.class, onThrowable = Throwable.class)
@Advice.OnMethodExit(suppress = Throwable.class, onThrowable = Throwable.class, inline = false)
public static void onAfterExecute(@Advice.Thrown @Nullable Throwable t,
@Advice.Enter @Nullable Object[] entryArgs) {
if (entryArgs != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,17 @@
* specific language governing permissions and limitations
* under the License.
*/
package co.elastic.apm.agent.es.restclient.v5_6;
package co.elastic.apm.agent.esrestclient.v5_6;

import co.elastic.apm.agent.es.restclient.ElasticsearchRestClientInstrumentation;
import co.elastic.apm.agent.es.restclient.ElasticsearchRestClientInstrumentationHelper;
import co.elastic.apm.agent.impl.ElasticApmTracer;
import co.elastic.apm.agent.esrestclient.ElasticsearchRestClientInstrumentation;
import co.elastic.apm.agent.esrestclient.ElasticsearchRestClientInstrumentationHelper;
import co.elastic.apm.agent.impl.transaction.Span;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;
import org.apache.http.HttpEntity;
import org.elasticsearch.client.Response;
import org.elasticsearch.client.ResponseListener;

import javax.annotation.Nullable;

Expand All @@ -40,31 +38,24 @@

public class ElasticsearchClientSyncInstrumentation extends ElasticsearchRestClientInstrumentation {

public ElasticsearchClientSyncInstrumentation(ElasticApmTracer tracer) {
super(tracer);
}

public static class ElasticsearchRestClientAdvice {

private static final ElasticsearchRestClientInstrumentationHelper helper = ElasticsearchRestClientInstrumentationHelper.get();

@Nullable
@Advice.OnMethodEnter(suppress = Throwable.class)
public static Span onBeforeExecute(@Advice.Argument(0) String method,
@Advice.OnMethodEnter(suppress = Throwable.class, inline = false)
public static Object onBeforeExecute(@Advice.Argument(0) String method,
@Advice.Argument(1) String endpoint,
@Advice.Argument(3) @Nullable HttpEntity entity) {
ElasticsearchRestClientInstrumentationHelper<HttpEntity, Response, ResponseListener> helper =
esClientInstrHelperManager.getForClassLoaderOfClass(Response.class);
if (helper == null) {
return null;
}
return helper.createClientSpan(method, endpoint, entity);
}

@Advice.OnMethodExit(suppress = Throwable.class, onThrowable = Throwable.class)
@Advice.OnMethodExit(suppress = Throwable.class, onThrowable = Throwable.class, inline = false)
public static void onAfterExecute(@Advice.Return @Nullable Response response,
@Advice.Enter @Nullable Span span,
@Advice.Enter @Nullable Object spanObj,
@Advice.Thrown @Nullable Throwable t) {
ElasticsearchRestClientInstrumentationHelper<HttpEntity, Response, ResponseListener> helper =
esClientInstrHelperManager.getForClassLoaderOfClass(Response.class);
if (helper != null && span != null) {
Span span = (Span) spanObj;
if (span != null) {
try {
helper.finishClientSpan(response, span, t);
} finally {
Expand All @@ -76,7 +67,7 @@ public static void onAfterExecute(@Advice.Return @Nullable Response response,

@Override
public String getAdviceClassName() {
return "co.elastic.apm.agent.es.restclient.v5_6.ElasticsearchClientSyncInstrumentation$ElasticsearchRestClientAdvice";
return getClass().getName() + "$ElasticsearchRestClientAdvice";
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
* under the License.
*/
@NonnullApi
package co.elastic.apm.agent.es.restclient.v6_4;
package co.elastic.apm.agent.esrestclient.v5_6;

import co.elastic.apm.agent.sdk.NonnullApi;
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
co.elastic.apm.agent.es.restclient.v5_6.ElasticsearchClientSyncInstrumentation
co.elastic.apm.agent.es.restclient.v5_6.ElasticsearchClientAsyncInstrumentation
co.elastic.apm.agent.esrestclient.v5_6.ElasticsearchClientSyncInstrumentation
co.elastic.apm.agent.esrestclient.v5_6.ElasticsearchClientAsyncInstrumentation
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
* specific language governing permissions and limitations
* under the License.
*/
package co.elastic.apm.agent.es.restclient.v5_6;
package co.elastic.apm.agent.esrestclient.v5_6;

import co.elastic.apm.agent.es.restclient.AbstractEsClientInstrumentationTest;
import co.elastic.apm.agent.esrestclient.AbstractEsClientInstrumentationTest;
import co.elastic.apm.agent.impl.transaction.Outcome;
import co.elastic.apm.agent.impl.transaction.Span;
import org.apache.http.HttpHost;
Expand Down Expand Up @@ -51,7 +51,6 @@
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.testcontainers.elasticsearch.ElasticsearchContainer;

import java.io.IOException;
import java.util.HashMap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,17 @@
* specific language governing permissions and limitations
* under the License.
*/
package co.elastic.apm.agent.es.restclient.v6_4;
package co.elastic.apm.agent.esrestclient.v6_4;

import co.elastic.apm.agent.es.restclient.ElasticsearchRestClientInstrumentation;
import co.elastic.apm.agent.es.restclient.ElasticsearchRestClientInstrumentationHelper;
import co.elastic.apm.agent.impl.ElasticApmTracer;
import co.elastic.apm.agent.esrestclient.ElasticsearchRestClientInstrumentation;
import co.elastic.apm.agent.esrestclient.ElasticsearchRestClientInstrumentationHelper;
import co.elastic.apm.agent.impl.transaction.Span;
import co.elastic.apm.agent.sdk.advice.AssignTo;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;
import org.apache.http.HttpEntity;
import org.elasticsearch.client.Request;
import org.elasticsearch.client.Response;
import org.elasticsearch.client.ResponseListener;

import javax.annotation.Nullable;
Expand All @@ -40,13 +37,9 @@

public class ElasticsearchClientAsyncInstrumentation extends ElasticsearchRestClientInstrumentation {

public ElasticsearchClientAsyncInstrumentation(ElasticApmTracer tracer) {
super(tracer);
}

@Override
public String getAdviceClassName() {
return "co.elastic.apm.agent.es.restclient.v6_4.ElasticsearchClientAsyncInstrumentation$ElasticsearchRestClientAsyncAdvice";
return getClass().getName() + "$ElasticsearchRestClientAsyncAdvice";
}

@Override
Expand All @@ -64,25 +57,24 @@ public ElementMatcher<? super MethodDescription> getMethodMatcher() {

public static class ElasticsearchRestClientAsyncAdvice {

private static final ElasticsearchRestClientInstrumentationHelper helper = ElasticsearchRestClientInstrumentationHelper.get();

@Nullable
@AssignTo.Argument(index = 1, value = 1)
@Advice.OnMethodEnter(suppress = Throwable.class)
@Advice.OnMethodEnter(suppress = Throwable.class, inline = false)
public static Object[] onBeforeExecute(@Advice.Argument(0) Request request,
@Advice.Argument(1) ResponseListener responseListener) {
ElasticsearchRestClientInstrumentationHelper<HttpEntity, Response, ResponseListener> helper = esClientInstrHelperManager.getForClassLoaderOfClass(Request.class);
if (helper != null) {
Span span = helper.createClientSpan(request.getMethod(), request.getEndpoint(), request.getEntity());
if (span != null) {
Object[] ret = new Object[2];
ret[0] = span;
ret[1] = helper.<ResponseListener>wrapResponseListener(responseListener, span);
return ret;
}
Span span = helper.createClientSpan(request.getMethod(), request.getEndpoint(), request.getEntity());
if (span != null) {
Object[] ret = new Object[2];
ret[0] = span;
ret[1] = helper.wrapResponseListener(responseListener, span);
return ret;
}
return null;
}

@Advice.OnMethodExit(suppress = Throwable.class, onThrowable = Throwable.class)
@Advice.OnMethodExit(suppress = Throwable.class, onThrowable = Throwable.class, inline = false)
public static void onAfterExecute(@Advice.Thrown @Nullable Throwable t,
@Advice.Enter @Nullable Object[] entryArgs) {
if (entryArgs != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,17 @@
* specific language governing permissions and limitations
* under the License.
*/
package co.elastic.apm.agent.es.restclient.v6_4;
package co.elastic.apm.agent.esrestclient.v6_4;

import co.elastic.apm.agent.es.restclient.ElasticsearchRestClientInstrumentation;
import co.elastic.apm.agent.es.restclient.ElasticsearchRestClientInstrumentationHelper;
import co.elastic.apm.agent.impl.ElasticApmTracer;
import co.elastic.apm.agent.esrestclient.ElasticsearchRestClientInstrumentation;
import co.elastic.apm.agent.esrestclient.ElasticsearchRestClientInstrumentationHelper;
import co.elastic.apm.agent.impl.transaction.Span;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;
import org.apache.http.HttpEntity;
import org.elasticsearch.client.Request;
import org.elasticsearch.client.Response;
import org.elasticsearch.client.ResponseListener;

import javax.annotation.Nullable;

Expand All @@ -39,13 +36,9 @@

public class ElasticsearchClientSyncInstrumentation extends ElasticsearchRestClientInstrumentation {

public ElasticsearchClientSyncInstrumentation(ElasticApmTracer tracer) {
super(tracer);
}

@Override
public String getAdviceClassName() {
return "co.elastic.apm.agent.es.restclient.v6_4.ElasticsearchClientSyncInstrumentation$ElasticsearchRestClientSyncAdvice";
return getClass().getName() + "$ElasticsearchRestClientSyncAdvice";
}

@Override
Expand All @@ -61,25 +54,21 @@ public ElementMatcher<? super MethodDescription> getMethodMatcher() {
}

public static class ElasticsearchRestClientSyncAdvice {
@Nullable
@Advice.OnMethodEnter(suppress = Throwable.class)
public static Span onBeforeExecute(@Advice.Argument(0) Request request) {

ElasticsearchRestClientInstrumentationHelper<HttpEntity, Response, ResponseListener> helper =
esClientInstrHelperManager.getForClassLoaderOfClass(Request.class);
if (helper == null) {
return null;
}
private static final ElasticsearchRestClientInstrumentationHelper helper = ElasticsearchRestClientInstrumentationHelper.get();

@Nullable
@Advice.OnMethodEnter(suppress = Throwable.class, inline = false)
public static Object onBeforeExecute(@Advice.Argument(0) Request request) {
return helper.createClientSpan(request.getMethod(), request.getEndpoint(), request.getEntity());
}

@Advice.OnMethodExit(suppress = Throwable.class, onThrowable = Throwable.class)
@Advice.OnMethodExit(suppress = Throwable.class, onThrowable = Throwable.class, inline = false)
public static void onAfterExecute(@Advice.Return @Nullable Response response,
@Advice.Enter @Nullable Span span,
@Advice.Enter @Nullable Object spanObj,
@Advice.Thrown @Nullable Throwable t) {
ElasticsearchRestClientInstrumentationHelper<HttpEntity, Response, ResponseListener> helper =
esClientInstrHelperManager.getForClassLoaderOfClass(Request.class);
if (helper != null && span != null) {
Span span = (Span) spanObj;
if (span != null) {
try {
helper.finishClientSpan(response, span, t);
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
* under the License.
*/
@NonnullApi
package co.elastic.apm.agent.es.restclient.v5_6;
package co.elastic.apm.agent.esrestclient.v6_4;

import co.elastic.apm.agent.sdk.NonnullApi;
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
co.elastic.apm.agent.es.restclient.v6_4.ElasticsearchClientSyncInstrumentation
co.elastic.apm.agent.es.restclient.v6_4.ElasticsearchClientAsyncInstrumentation
co.elastic.apm.agent.esrestclient.v6_4.ElasticsearchClientSyncInstrumentation
co.elastic.apm.agent.esrestclient.v6_4.ElasticsearchClientAsyncInstrumentation
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
* specific language governing permissions and limitations
* under the License.
*/
package co.elastic.apm.agent.es.restclient.v6_4;
package co.elastic.apm.agent.esrestclient.v6_4;

import co.elastic.apm.agent.es.restclient.AbstractEsClientInstrumentationTest;
import co.elastic.apm.agent.esrestclient.AbstractEsClientInstrumentationTest;
import co.elastic.apm.agent.impl.transaction.Span;
import org.elasticsearch.ElasticsearchStatusException;
import org.elasticsearch.action.ActionListener;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package co.elastic.apm.agent.es.restclient.v6_4;
package co.elastic.apm.agent.esrestclient.v6_4;

import co.elastic.apm.agent.impl.transaction.Span;
import org.apache.http.HttpHost;
Expand All @@ -35,7 +35,6 @@
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.testcontainers.elasticsearch.ElasticsearchContainer;

import java.io.IOException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package co.elastic.apm.agent.es.restclient.v6_4;
package co.elastic.apm.agent.esrestclient.v6_4;

import co.elastic.apm.agent.bci.ElasticApmAgent;
import co.elastic.apm.agent.configuration.SpyConfiguration;
Expand Down
Loading