From bd73afb0ad2e1ff91487173a1c1e395d95c39363 Mon Sep 17 00:00:00 2001 From: kananindzya Date: Wed, 26 Aug 2020 13:30:43 +0600 Subject: [PATCH 1/2] moved helper to advice classes. Migrate es-restclient to indy plugin --- ...asticsearchClientAsyncInstrumentation.java | 28 ++- ...lasticsearchClientSyncInstrumentation.java | 38 ++-- ...asticsearchClientAsyncInstrumentation.java | 25 +-- ...lasticsearchClientSyncInstrumentation.java | 30 +--- ...lasticsearchRestClientInstrumentation.java | 28 --- ...searchRestClientInstrumentationHelper.java | 134 +++++++++++++- ...chRestClientInstrumentationHelperImpl.java | 165 ------------------ .../restclient/ResponseListenerWrapper.java | 8 +- .../AbstractEsClientInstrumentationTest.java | 6 +- 9 files changed, 173 insertions(+), 289 deletions(-) delete mode 100644 apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-common/src/main/java/co/elastic/apm/agent/es/restclient/ElasticsearchRestClientInstrumentationHelperImpl.java diff --git a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-5_6/src/main/java/co/elastic/apm/agent/es/restclient/v5_6/ElasticsearchClientAsyncInstrumentation.java b/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-5_6/src/main/java/co/elastic/apm/agent/es/restclient/v5_6/ElasticsearchClientAsyncInstrumentation.java index fc26aa250a..e238c4ca9f 100644 --- a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-5_6/src/main/java/co/elastic/apm/agent/es/restclient/v5_6/ElasticsearchClientAsyncInstrumentation.java +++ b/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-5_6/src/main/java/co/elastic/apm/agent/es/restclient/v5_6/ElasticsearchClientAsyncInstrumentation.java @@ -24,10 +24,9 @@ */ package co.elastic.apm.agent.es.restclient.v5_6; -import co.elastic.apm.agent.bci.VisibleForAdvice; 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.impl.transaction.AbstractSpan; import co.elastic.apm.agent.impl.transaction.Span; import co.elastic.apm.agent.sdk.advice.AssignTo; import co.elastic.apm.agent.sdk.state.GlobalThreadLocal; @@ -36,7 +35,6 @@ 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; @@ -49,10 +47,6 @@ public class ElasticsearchClientAsyncInstrumentation extends ElasticsearchRestClientInstrumentation { - public ElasticsearchClientAsyncInstrumentation(ElasticApmTracer tracer) { - super(tracer); - } - @Override public Class getAdviceClass() { return ElasticsearchRestClientAsyncAdvice.class; @@ -77,27 +71,25 @@ public ElementMatcher getMethodMatcher() { public static class ElasticsearchRestClientAsyncAdvice { - @VisibleForAdvice + public static ElasticsearchRestClientInstrumentationHelper helper = new ElasticsearchRestClientInstrumentationHelper(); public static final GlobalThreadLocal spanTls = GlobalThreadLocal.get(ElasticsearchRestClientAsyncAdvice.class, "spanTls"); + @AssignTo.Argument(5) - @Advice.OnMethodEnter(suppress = Throwable.class) + @Advice.OnMethodEnter(suppress = Throwable.class, inline = false) public static ResponseListener onBeforeExecute(@Advice.Argument(0) String method, @Advice.Argument(1) String endpoint, @Advice.Argument(3) @Nullable HttpEntity entity, @Advice.Argument(5) ResponseListener responseListener) { - - ElasticsearchRestClientInstrumentationHelper helper = esClientInstrHelperManager.getForClassLoaderOfClass(Response.class); - if (helper != null) { - Span span = helper.createClientSpan(method, endpoint, entity); - spanTls.set(span); - if (span != null) { - return helper.wrapResponseListener(responseListener, span); - } + AbstractSpan activeSpan = tracer.getActive(); + Span span = helper.createClientSpan(activeSpan, method, endpoint, entity); + spanTls.set(span); + if (span != null) { + return helper.wrapResponseListener(responseListener, span); } return responseListener; } - @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) { final Span span = spanTls.getAndRemove(); if (span != null) { diff --git a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-5_6/src/main/java/co/elastic/apm/agent/es/restclient/v5_6/ElasticsearchClientSyncInstrumentation.java b/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-5_6/src/main/java/co/elastic/apm/agent/es/restclient/v5_6/ElasticsearchClientSyncInstrumentation.java index c92322fc38..8c96c7a698 100644 --- a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-5_6/src/main/java/co/elastic/apm/agent/es/restclient/v5_6/ElasticsearchClientSyncInstrumentation.java +++ b/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-5_6/src/main/java/co/elastic/apm/agent/es/restclient/v5_6/ElasticsearchClientSyncInstrumentation.java @@ -26,7 +26,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.impl.transaction.Span; import net.bytebuddy.asm.Advice; import net.bytebuddy.description.method.MethodDescription; @@ -34,7 +33,6 @@ import net.bytebuddy.matcher.ElementMatcher; import org.apache.http.HttpEntity; import org.elasticsearch.client.Response; -import org.elasticsearch.client.ResponseListener; import javax.annotation.Nullable; @@ -46,31 +44,28 @@ public class ElasticsearchClientSyncInstrumentation extends ElasticsearchRestClientInstrumentation { - public ElasticsearchClientSyncInstrumentation(ElasticApmTracer tracer) { - super(tracer); + @Override + public Class getAdviceClass() { + return ElasticsearchRestClientAdvice.class; } public static class ElasticsearchRestClientAdvice { + public static ElasticsearchRestClientInstrumentationHelper helper = new ElasticsearchRestClientInstrumentationHelper(); + @Nullable - @Advice.OnMethodEnter(suppress = Throwable.class) - public static Span onBeforeExecute(@Advice.Argument(0) String method, - @Advice.Argument(1) String endpoint, - @Advice.Argument(3) @Nullable HttpEntity entity) { - ElasticsearchRestClientInstrumentationHelper helper = - esClientInstrHelperManager.getForClassLoaderOfClass(Response.class); - if (helper == null) { - return null; - } - return helper.createClientSpan(method, endpoint, entity); + @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) { + return helper.createClientSpan(tracer.getActive(), 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 objSpan, @Advice.Thrown @Nullable Throwable t) { - ElasticsearchRestClientInstrumentationHelper helper = - esClientInstrHelperManager.getForClassLoaderOfClass(Response.class); - if (helper != null && span != null) { + if (objSpan instanceof Span) { + Span span = (Span) objSpan; try { helper.finishClientSpan(response, span, t); } finally { @@ -80,11 +75,6 @@ public static void onAfterExecute(@Advice.Return @Nullable Response response, } } - @Override - public Class getAdviceClass() { - return ElasticsearchRestClientAdvice.class; - } - @Override public ElementMatcher getTypeMatcher() { return named("org.elasticsearch.client.RestClient"). diff --git a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-6_4/src/main/java/co/elastic/apm/agent/es/restclient/v6_4/ElasticsearchClientAsyncInstrumentation.java b/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-6_4/src/main/java/co/elastic/apm/agent/es/restclient/v6_4/ElasticsearchClientAsyncInstrumentation.java index d123b172f0..23ed76c0b8 100644 --- a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-6_4/src/main/java/co/elastic/apm/agent/es/restclient/v6_4/ElasticsearchClientAsyncInstrumentation.java +++ b/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-6_4/src/main/java/co/elastic/apm/agent/es/restclient/v6_4/ElasticsearchClientAsyncInstrumentation.java @@ -24,10 +24,8 @@ */ package co.elastic.apm.agent.es.restclient.v6_4; -import co.elastic.apm.agent.bci.VisibleForAdvice; 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.impl.transaction.Span; import co.elastic.apm.agent.sdk.advice.AssignTo; import co.elastic.apm.agent.sdk.state.GlobalThreadLocal; @@ -35,9 +33,7 @@ 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; @@ -48,10 +44,6 @@ public class ElasticsearchClientAsyncInstrumentation extends ElasticsearchRestClientInstrumentation { - public ElasticsearchClientAsyncInstrumentation(ElasticApmTracer tracer) { - super(tracer); - } - @Override public Class getAdviceClass() { return ElasticsearchRestClientAsyncAdvice.class; @@ -71,25 +63,22 @@ public ElementMatcher getMethodMatcher() { } public static class ElasticsearchRestClientAsyncAdvice { - @VisibleForAdvice + public static ElasticsearchRestClientInstrumentationHelper helper = new ElasticsearchRestClientInstrumentationHelper(); public static final GlobalThreadLocal spanTls = GlobalThreadLocal.get(ElasticsearchRestClientAsyncAdvice.class, "spanTls"); @AssignTo.Argument(1) - @Advice.OnMethodEnter(suppress = Throwable.class) + @Advice.OnMethodEnter(suppress = Throwable.class, inline = false) public static ResponseListener onBeforeExecute(@Advice.Argument(0) Request request, @Advice.Argument(1) ResponseListener responseListener) { - ElasticsearchRestClientInstrumentationHelper helper = esClientInstrHelperManager.getForClassLoaderOfClass(Request.class); - if (helper != null) { - Span span = helper.createClientSpan(request.getMethod(), request.getEndpoint(), request.getEntity()); - if (span != null) { - spanTls.set(span); - return helper.wrapResponseListener(responseListener, span); - } + Span span = helper.createClientSpan(tracer.getActive(), request.getMethod(), request.getEndpoint(), request.getEntity()); + if (span != null) { + spanTls.set(span); + return helper.wrapResponseListener(responseListener, span); } return responseListener; } - @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) { final Span span = spanTls.getAndRemove(); if (span != null) { diff --git a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-6_4/src/main/java/co/elastic/apm/agent/es/restclient/v6_4/ElasticsearchClientSyncInstrumentation.java b/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-6_4/src/main/java/co/elastic/apm/agent/es/restclient/v6_4/ElasticsearchClientSyncInstrumentation.java index acf70bd3a6..a2719e42b2 100644 --- a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-6_4/src/main/java/co/elastic/apm/agent/es/restclient/v6_4/ElasticsearchClientSyncInstrumentation.java +++ b/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-6_4/src/main/java/co/elastic/apm/agent/es/restclient/v6_4/ElasticsearchClientSyncInstrumentation.java @@ -26,16 +26,13 @@ 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.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; @@ -45,10 +42,6 @@ public class ElasticsearchClientSyncInstrumentation extends ElasticsearchRestClientInstrumentation { - public ElasticsearchClientSyncInstrumentation(ElasticApmTracer tracer) { - super(tracer); - } - @Override public Class getAdviceClass() { return ElasticsearchRestClientSyncAdvice.class; @@ -67,25 +60,20 @@ public ElementMatcher getMethodMatcher() { } public static class ElasticsearchRestClientSyncAdvice { - @Nullable - @Advice.OnMethodEnter(suppress = Throwable.class) - public static Span onBeforeExecute(@Advice.Argument(0) Request request) { + public static ElasticsearchRestClientInstrumentationHelper helper = new ElasticsearchRestClientInstrumentationHelper(); - ElasticsearchRestClientInstrumentationHelper helper = - esClientInstrHelperManager.getForClassLoaderOfClass(Request.class); - if (helper == null) { - return null; - } - return helper.createClientSpan(request.getMethod(), request.getEndpoint(), request.getEntity()); + @Nullable + @Advice.OnMethodEnter(suppress = Throwable.class, inline = false) + public static Object onBeforeExecute(@Advice.Argument(0) Request request) { + return helper.createClientSpan(tracer.getActive(), 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 helper = - esClientInstrHelperManager.getForClassLoaderOfClass(Request.class); - if (helper != null && span != null) { + if (spanObj instanceof Span) { + Span span = (Span) spanObj; try { helper.finishClientSpan(response, span, t); } finally { diff --git a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-common/src/main/java/co/elastic/apm/agent/es/restclient/ElasticsearchRestClientInstrumentation.java b/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-common/src/main/java/co/elastic/apm/agent/es/restclient/ElasticsearchRestClientInstrumentation.java index bb743f22a5..5fe44cb648 100644 --- a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-common/src/main/java/co/elastic/apm/agent/es/restclient/ElasticsearchRestClientInstrumentation.java +++ b/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-common/src/main/java/co/elastic/apm/agent/es/restclient/ElasticsearchRestClientInstrumentation.java @@ -24,44 +24,16 @@ */ package co.elastic.apm.agent.es.restclient; -import co.elastic.apm.agent.bci.HelperClassManager; import co.elastic.apm.agent.bci.TracerAwareInstrumentation; -import co.elastic.apm.agent.bci.VisibleForAdvice; -import co.elastic.apm.agent.impl.ElasticApmTracer; -import org.apache.http.HttpEntity; -import org.elasticsearch.client.Response; -import org.elasticsearch.client.ResponseListener; -import javax.annotation.Nullable; import java.util.Collection; import java.util.Collections; public abstract class ElasticsearchRestClientInstrumentation extends TracerAwareInstrumentation { - @Nullable - @VisibleForAdvice - // Referencing ES classes is legal due to type erasure. The field must be public in order for it to be accessible from injected code - public static HelperClassManager> esClientInstrHelperManager; - - public ElasticsearchRestClientInstrumentation(ElasticApmTracer tracer) { - synchronized (ElasticsearchRestClientInstrumentation.class) { - if (esClientInstrHelperManager == null) { - esClientInstrHelperManager = HelperClassManager.ForAnyClassLoader.of(tracer, - "co.elastic.apm.agent.es.restclient.ElasticsearchRestClientInstrumentationHelperImpl", - "co.elastic.apm.agent.es.restclient.ResponseListenerWrapper", - "co.elastic.apm.agent.es.restclient.ElasticsearchRestClientInstrumentationHelperImpl$ResponseListenerAllocator"); - } - } - } - @Override public Collection getInstrumentationGroupNames() { return Collections.singleton("elasticsearch-restclient"); } - - @Override - public boolean indyPlugin() { - return false; - } } diff --git a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-common/src/main/java/co/elastic/apm/agent/es/restclient/ElasticsearchRestClientInstrumentationHelper.java b/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-common/src/main/java/co/elastic/apm/agent/es/restclient/ElasticsearchRestClientInstrumentationHelper.java index f6162de29d..5f998b6573 100644 --- a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-common/src/main/java/co/elastic/apm/agent/es/restclient/ElasticsearchRestClientInstrumentationHelper.java +++ b/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-common/src/main/java/co/elastic/apm/agent/es/restclient/ElasticsearchRestClientInstrumentationHelper.java @@ -11,9 +11,9 @@ * 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 @@ -24,18 +24,136 @@ */ package co.elastic.apm.agent.es.restclient; -import co.elastic.apm.agent.bci.VisibleForAdvice; +import co.elastic.apm.agent.impl.transaction.AbstractSpan; import co.elastic.apm.agent.impl.transaction.Span; +import co.elastic.apm.agent.matcher.WildcardMatcher; +import co.elastic.apm.agent.objectpool.Allocator; +import co.elastic.apm.agent.objectpool.ObjectPool; +import co.elastic.apm.agent.objectpool.impl.QueueBasedObjectPool; +import co.elastic.apm.agent.util.IOUtils; +import org.apache.http.HttpEntity; +import org.apache.http.HttpHost; +import org.elasticsearch.client.Response; +import org.elasticsearch.client.ResponseException; +import org.elasticsearch.client.ResponseListener; +import org.jctools.queues.atomic.AtomicQueueFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import javax.annotation.Nullable; +import java.io.IOException; +import java.util.Arrays; +import java.util.List; -@VisibleForAdvice -public interface ElasticsearchRestClientInstrumentationHelper { +import static org.jctools.queues.spec.ConcurrentQueueSpec.createBoundedMpmc; + +public class ElasticsearchRestClientInstrumentationHelper { + + private static final Logger logger = LoggerFactory.getLogger(ElasticsearchRestClientInstrumentationHelper.class); + + public static final List QUERY_WILDCARD_MATCHERS = Arrays.asList( + WildcardMatcher.valueOf("*_search"), + WildcardMatcher.valueOf("*_msearch"), + WildcardMatcher.valueOf("*_msearch/template"), + WildcardMatcher.valueOf("*_search/template"), + WildcardMatcher.valueOf("*_count")); + + public static final String SPAN_TYPE = "db"; + public static final String ELASTICSEARCH = "elasticsearch"; + public static final String SPAN_ACTION = "request"; + private static final int MAX_POOLED_ELEMENTS = 256; + + private final ObjectPool responseListenerObjectPool; + + public ElasticsearchRestClientInstrumentationHelper() { + responseListenerObjectPool = QueueBasedObjectPool.ofRecyclable( + AtomicQueueFactory.newQueue(createBoundedMpmc(MAX_POOLED_ELEMENTS)), + false, + new ElasticsearchRestClientInstrumentationHelper.ResponseListenerAllocator()); + } + + private class ResponseListenerAllocator implements Allocator { + @Override + public ResponseListenerWrapper createInstance() { + return new ResponseListenerWrapper(ElasticsearchRestClientInstrumentationHelper.this); + } + } @Nullable - Span createClientSpan(String method, String endpoint, @Nullable H httpEntity); + public Span createClientSpan(@Nullable AbstractSpan activeSpan, String method, String endpoint, @Nullable HttpEntity httpEntity) { + if (activeSpan == null) { + return null; + } + + Span span = activeSpan.createExitSpan(); + + // Don't record nested spans. In 5.x clients the instrumented sync method is calling the instrumented async method + if (span == null) { + return null; + } + + span.withType(SPAN_TYPE) + .withSubtype(ELASTICSEARCH) + .withAction(SPAN_ACTION) + .appendToName("Elasticsearch: ").appendToName(method).appendToName(" ").appendToName(endpoint); + span.getContext().getDb().withType(ELASTICSEARCH); + span.activate(); + + if (span.isSampled()) { + span.getContext().getHttp().withMethod(method); + if (WildcardMatcher.isAnyMatch(QUERY_WILDCARD_MATCHERS, endpoint)) { + if (httpEntity != null && httpEntity.isRepeatable()) { + try { + IOUtils.readUtf8Stream(httpEntity.getContent(), span.getContext().getDb().withStatementBuffer()); + } catch (IOException e) { + logger.error("Failed to read Elasticsearch client query from request body", e); + } + } + } + span.getContext().getDestination().getService().withName(ELASTICSEARCH).withResource(ELASTICSEARCH).withType(SPAN_TYPE); + } + return span; + } + + public void finishClientSpan(@Nullable Response response, Span span, @Nullable Throwable t) { + try { + String url = null; + int statusCode = -1; + String address = null; + int port = -1; + if (response != null) { + HttpHost host = response.getHost(); + address = host.getHostName(); + port = host.getPort(); + url = host.toURI(); + statusCode = response.getStatusLine().getStatusCode(); + } else if (t != null) { + if (t instanceof ResponseException) { + ResponseException esre = (ResponseException) t; + HttpHost host = esre.getResponse().getHost(); + address = host.getHostName(); + port = host.getPort(); + url = host.toURI(); + statusCode = esre.getResponse().getStatusLine().getStatusCode(); + } + span.captureException(t); + } + + if (url != null && !url.isEmpty()) { + span.getContext().getHttp().withUrl(url); + } + span.getContext().getHttp().withStatusCode(statusCode); + span.getContext().getDestination().withAddress(address).withPort(port); + } finally { + span.end(); + } + } - void finishClientSpan(@Nullable R responseObject, Span span, @Nullable Throwable t); + public ResponseListener wrapResponseListener(ResponseListener listener, Span span) { + return responseListenerObjectPool.createInstance().with(listener, span); + } - L wrapResponseListener(L listener, Span span); + void recycle(ResponseListenerWrapper listenerWrapper) { + responseListenerObjectPool.recycle(listenerWrapper); + } } diff --git a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-common/src/main/java/co/elastic/apm/agent/es/restclient/ElasticsearchRestClientInstrumentationHelperImpl.java b/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-common/src/main/java/co/elastic/apm/agent/es/restclient/ElasticsearchRestClientInstrumentationHelperImpl.java deleted file mode 100644 index 92666520b7..0000000000 --- a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-common/src/main/java/co/elastic/apm/agent/es/restclient/ElasticsearchRestClientInstrumentationHelperImpl.java +++ /dev/null @@ -1,165 +0,0 @@ -/*- - * #%L - * Elastic APM Java agent - * %% - * Copyright (C) 2018 - 2020 Elastic and contributors - * %% - * 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. - * #L% - */ -package co.elastic.apm.agent.es.restclient; - -import co.elastic.apm.agent.impl.ElasticApmTracer; -import co.elastic.apm.agent.impl.transaction.AbstractSpan; -import co.elastic.apm.agent.impl.transaction.Span; -import co.elastic.apm.agent.matcher.WildcardMatcher; -import co.elastic.apm.agent.objectpool.Allocator; -import co.elastic.apm.agent.objectpool.ObjectPool; -import co.elastic.apm.agent.objectpool.impl.QueueBasedObjectPool; -import co.elastic.apm.agent.util.IOUtils; -import org.apache.http.HttpEntity; -import org.apache.http.HttpHost; -import org.elasticsearch.client.Response; -import org.elasticsearch.client.ResponseException; -import org.elasticsearch.client.ResponseListener; -import org.jctools.queues.atomic.AtomicQueueFactory; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.annotation.Nullable; -import java.io.IOException; -import java.util.Arrays; -import java.util.List; - -import static org.jctools.queues.spec.ConcurrentQueueSpec.createBoundedMpmc; - -public class ElasticsearchRestClientInstrumentationHelperImpl implements ElasticsearchRestClientInstrumentationHelper { - - private static final Logger logger = LoggerFactory.getLogger(ElasticsearchRestClientInstrumentationHelperImpl.class); - - public static final List QUERY_WILDCARD_MATCHERS = Arrays.asList( - WildcardMatcher.valueOf("*_search"), - WildcardMatcher.valueOf("*_msearch"), - WildcardMatcher.valueOf("*_msearch/template"), - WildcardMatcher.valueOf("*_search/template"), - WildcardMatcher.valueOf("*_count")); - public static final String SPAN_TYPE = "db"; - 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 ObjectPool responseListenerObjectPool; - - public ElasticsearchRestClientInstrumentationHelperImpl(ElasticApmTracer tracer) { - this.tracer = tracer; - responseListenerObjectPool = QueueBasedObjectPool.ofRecyclable( - AtomicQueueFactory.newQueue(createBoundedMpmc(MAX_POOLED_ELEMENTS)), - false, - new ResponseListenerAllocator()); - } - - private class ResponseListenerAllocator implements Allocator { - @Override - public ResponseListenerWrapper createInstance() { - return new ResponseListenerWrapper(ElasticsearchRestClientInstrumentationHelperImpl.this); - } - } - - @Override - @Nullable - public Span createClientSpan(String method, String endpoint, @Nullable HttpEntity httpEntity) { - final AbstractSpan activeSpan = tracer.getActive(); - if (activeSpan == null) { - return null; - } - - Span span = activeSpan.createExitSpan(); - - // Don't record nested spans. In 5.x clients the instrumented sync method is calling the instrumented async method - if (span == null) { - return null; - } - - span.withType(SPAN_TYPE) - .withSubtype(ELASTICSEARCH) - .withAction(SPAN_ACTION) - .appendToName("Elasticsearch: ").appendToName(method).appendToName(" ").appendToName(endpoint); - span.getContext().getDb().withType(ELASTICSEARCH); - span.activate(); - - if (span.isSampled()) { - span.getContext().getHttp().withMethod(method); - if (WildcardMatcher.isAnyMatch(QUERY_WILDCARD_MATCHERS, endpoint)) { - if (httpEntity != null && httpEntity.isRepeatable()) { - try { - IOUtils.readUtf8Stream(httpEntity.getContent(), span.getContext().getDb().withStatementBuffer()); - } catch (IOException e) { - logger.error("Failed to read Elasticsearch client query from request body", e); - } - } - } - span.getContext().getDestination().getService().withName(ELASTICSEARCH).withResource(ELASTICSEARCH).withType(SPAN_TYPE); - } - return span; - } - - @Override - public void finishClientSpan(@Nullable Response response, Span span, @Nullable Throwable t) { - try { - String url = null; - int statusCode = -1; - String address = null; - int port = -1; - if (response != null) { - HttpHost host = response.getHost(); - address = host.getHostName(); - port = host.getPort(); - url = host.toURI(); - statusCode = response.getStatusLine().getStatusCode(); - } else if (t != null) { - if (t instanceof ResponseException) { - ResponseException esre = (ResponseException) t; - HttpHost host = esre.getResponse().getHost(); - address = host.getHostName(); - port = host.getPort(); - url = host.toURI(); - statusCode = esre.getResponse().getStatusLine().getStatusCode(); - } - span.captureException(t); - } - - if (url != null && !url.isEmpty()) { - span.getContext().getHttp().withUrl(url); - } - span.getContext().getHttp().withStatusCode(statusCode); - span.getContext().getDestination().withAddress(address).withPort(port); - } finally { - span.end(); - } - } - - @Override - public ResponseListener wrapResponseListener(ResponseListener listener, Span span) { - return responseListenerObjectPool.createInstance().with(listener, span); - } - - void recycle(ResponseListenerWrapper listenerWrapper) { - responseListenerObjectPool.recycle(listenerWrapper); - } -} diff --git a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-common/src/main/java/co/elastic/apm/agent/es/restclient/ResponseListenerWrapper.java b/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-common/src/main/java/co/elastic/apm/agent/es/restclient/ResponseListenerWrapper.java index da1819db0a..94f2888d60 100644 --- a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-common/src/main/java/co/elastic/apm/agent/es/restclient/ResponseListenerWrapper.java +++ b/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-common/src/main/java/co/elastic/apm/agent/es/restclient/ResponseListenerWrapper.java @@ -11,9 +11,9 @@ * 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 @@ -33,13 +33,13 @@ public class ResponseListenerWrapper implements ResponseListener, Recyclable { - private ElasticsearchRestClientInstrumentationHelperImpl helper; + private ElasticsearchRestClientInstrumentationHelper helper; @Nullable private ResponseListener delegate; @Nullable private volatile Span span; - ResponseListenerWrapper(ElasticsearchRestClientInstrumentationHelperImpl helper) { + ResponseListenerWrapper(ElasticsearchRestClientInstrumentationHelper helper) { this.helper = helper; } diff --git a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-common/src/test/java/co/elastic/apm/agent/es/restclient/AbstractEsClientInstrumentationTest.java b/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-common/src/test/java/co/elastic/apm/agent/es/restclient/AbstractEsClientInstrumentationTest.java index c5df95e0d4..94cdf7dfa3 100644 --- a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-common/src/test/java/co/elastic/apm/agent/es/restclient/AbstractEsClientInstrumentationTest.java +++ b/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-common/src/test/java/co/elastic/apm/agent/es/restclient/AbstractEsClientInstrumentationTest.java @@ -40,9 +40,9 @@ import java.util.Arrays; import java.util.List; -import static co.elastic.apm.agent.es.restclient.ElasticsearchRestClientInstrumentationHelperImpl.ELASTICSEARCH; -import static co.elastic.apm.agent.es.restclient.ElasticsearchRestClientInstrumentationHelperImpl.SPAN_ACTION; -import static co.elastic.apm.agent.es.restclient.ElasticsearchRestClientInstrumentationHelperImpl.SPAN_TYPE; +import static co.elastic.apm.agent.es.restclient.ElasticsearchRestClientInstrumentationHelper.ELASTICSEARCH; +import static co.elastic.apm.agent.es.restclient.ElasticsearchRestClientInstrumentationHelper.SPAN_ACTION; +import static co.elastic.apm.agent.es.restclient.ElasticsearchRestClientInstrumentationHelper.SPAN_TYPE; import static org.assertj.core.api.Assertions.assertThat; public abstract class AbstractEsClientInstrumentationTest extends AbstractInstrumentationTest { From 59ef6ba54293510fb35a74553c6e2c8329443389 Mon Sep 17 00:00:00 2001 From: kananindzya Date: Sun, 30 Aug 2020 02:15:43 +0600 Subject: [PATCH 2/2] renamed packages --- .../ElasticsearchClientAsyncInstrumentation.java | 6 +++--- .../ElasticsearchClientSyncInstrumentation.java | 6 +++--- .../elastic/apm/agent/esrestclient5_6}/package-info.java | 2 +- .../co.elastic.apm.agent.sdk.ElasticApmInstrumentation | 4 ++-- .../ElasticsearchRestClientInstrumentationIT.java | 4 ++-- .../ElasticsearchClientAsyncInstrumentation.java | 6 +++--- .../ElasticsearchClientSyncInstrumentation.java | 6 +++--- .../elastic/apm/agent/esrestclient6_4}/package-info.java | 2 +- .../co.elastic.apm.agent.sdk.ElasticApmInstrumentation | 4 ++-- .../AbstractEs6_4ClientInstrumentationTest.java | 4 ++-- .../ElasticsearchRestClientInstrumentationIT.java | 2 +- ...ticsearchRestClientInstrumentationIT_RealReporter.java | 2 +- .../ElasticsearchRestClientInstrumentationIT.java | 4 ++-- .../ElasticsearchRestClientInstrumentation.java | 2 +- .../ElasticsearchRestClientInstrumentationHelper.java | 2 +- .../ResponseListenerWrapper.java | 2 +- .../{es/restclient => esrestclient}/package-info.java | 2 +- .../AbstractEsClientInstrumentationTest.java | 8 ++++---- 18 files changed, 34 insertions(+), 34 deletions(-) rename apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-5_6/src/main/java/co/elastic/apm/agent/{es/restclient/v5_6 => esrestclient5_6}/ElasticsearchClientAsyncInstrumentation.java (95%) rename apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-5_6/src/main/java/co/elastic/apm/agent/{es/restclient/v5_6 => esrestclient5_6}/ElasticsearchClientSyncInstrumentation.java (94%) rename apm-agent-plugins/apm-es-restclient-plugin/{apm-es-restclient-plugin-6_4/src/main/java/co/elastic/apm/agent/es/restclient/v6_4 => apm-es-restclient-plugin-5_6/src/main/java/co/elastic/apm/agent/esrestclient5_6}/package-info.java (95%) rename apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-5_6/src/test/java/co/elastic/apm/agent/{es/restclient/v5_6 => esrestclient5_6}/ElasticsearchRestClientInstrumentationIT.java (98%) rename apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-6_4/src/main/java/co/elastic/apm/agent/{es/restclient/v6_4 => esrestclient6_4}/ElasticsearchClientAsyncInstrumentation.java (94%) rename apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-6_4/src/main/java/co/elastic/apm/agent/{es/restclient/v6_4 => esrestclient6_4}/ElasticsearchClientSyncInstrumentation.java (93%) rename apm-agent-plugins/apm-es-restclient-plugin/{apm-es-restclient-plugin-5_6/src/main/java/co/elastic/apm/agent/es/restclient/v5_6 => apm-es-restclient-plugin-6_4/src/main/java/co/elastic/apm/agent/esrestclient6_4}/package-info.java (95%) rename apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-6_4/src/test/java/co/elastic/apm/agent/{es/restclient/v6_4 => esrestclient6_4}/AbstractEs6_4ClientInstrumentationTest.java (99%) rename apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-6_4/src/test/java/co/elastic/apm/agent/{es/restclient/v6_4 => esrestclient6_4}/ElasticsearchRestClientInstrumentationIT.java (98%) rename apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-6_4/src/test/java/co/elastic/apm/agent/{es/restclient/v6_4 => esrestclient6_4}/ElasticsearchRestClientInstrumentationIT_RealReporter.java (99%) rename apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-7_1/src/test/java/co/elastic/apm/agent/{es/restclient/v7_1 => esrestclient7_1}/ElasticsearchRestClientInstrumentationIT.java (97%) rename apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-common/src/main/java/co/elastic/apm/agent/{es/restclient => esrestclient}/ElasticsearchRestClientInstrumentation.java (96%) rename apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-common/src/main/java/co/elastic/apm/agent/{es/restclient => esrestclient}/ElasticsearchRestClientInstrumentationHelper.java (99%) rename apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-common/src/main/java/co/elastic/apm/agent/{es/restclient => esrestclient}/ResponseListenerWrapper.java (98%) rename apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-common/src/main/java/co/elastic/apm/agent/{es/restclient => esrestclient}/package-info.java (95%) rename apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-common/src/test/java/co/elastic/apm/agent/{es/restclient => esrestclient}/AbstractEsClientInstrumentationTest.java (94%) diff --git a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-5_6/src/main/java/co/elastic/apm/agent/es/restclient/v5_6/ElasticsearchClientAsyncInstrumentation.java b/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-5_6/src/main/java/co/elastic/apm/agent/esrestclient5_6/ElasticsearchClientAsyncInstrumentation.java similarity index 95% rename from apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-5_6/src/main/java/co/elastic/apm/agent/es/restclient/v5_6/ElasticsearchClientAsyncInstrumentation.java rename to apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-5_6/src/main/java/co/elastic/apm/agent/esrestclient5_6/ElasticsearchClientAsyncInstrumentation.java index e238c4ca9f..1ef9f70dd7 100644 --- a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-5_6/src/main/java/co/elastic/apm/agent/es/restclient/v5_6/ElasticsearchClientAsyncInstrumentation.java +++ b/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-5_6/src/main/java/co/elastic/apm/agent/esrestclient5_6/ElasticsearchClientAsyncInstrumentation.java @@ -22,10 +22,10 @@ * under the License. * #L% */ -package co.elastic.apm.agent.es.restclient.v5_6; +package co.elastic.apm.agent.esrestclient5_6; -import co.elastic.apm.agent.es.restclient.ElasticsearchRestClientInstrumentation; -import co.elastic.apm.agent.es.restclient.ElasticsearchRestClientInstrumentationHelper; +import co.elastic.apm.agent.esrestclient.ElasticsearchRestClientInstrumentation; +import co.elastic.apm.agent.esrestclient.ElasticsearchRestClientInstrumentationHelper; import co.elastic.apm.agent.impl.transaction.AbstractSpan; import co.elastic.apm.agent.impl.transaction.Span; import co.elastic.apm.agent.sdk.advice.AssignTo; diff --git a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-5_6/src/main/java/co/elastic/apm/agent/es/restclient/v5_6/ElasticsearchClientSyncInstrumentation.java b/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-5_6/src/main/java/co/elastic/apm/agent/esrestclient5_6/ElasticsearchClientSyncInstrumentation.java similarity index 94% rename from apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-5_6/src/main/java/co/elastic/apm/agent/es/restclient/v5_6/ElasticsearchClientSyncInstrumentation.java rename to apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-5_6/src/main/java/co/elastic/apm/agent/esrestclient5_6/ElasticsearchClientSyncInstrumentation.java index 8c96c7a698..9dc1ada2a0 100644 --- a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-5_6/src/main/java/co/elastic/apm/agent/es/restclient/v5_6/ElasticsearchClientSyncInstrumentation.java +++ b/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-5_6/src/main/java/co/elastic/apm/agent/esrestclient5_6/ElasticsearchClientSyncInstrumentation.java @@ -22,10 +22,10 @@ * under the License. * #L% */ -package co.elastic.apm.agent.es.restclient.v5_6; +package co.elastic.apm.agent.esrestclient5_6; -import co.elastic.apm.agent.es.restclient.ElasticsearchRestClientInstrumentation; -import co.elastic.apm.agent.es.restclient.ElasticsearchRestClientInstrumentationHelper; +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; diff --git a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-6_4/src/main/java/co/elastic/apm/agent/es/restclient/v6_4/package-info.java b/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-5_6/src/main/java/co/elastic/apm/agent/esrestclient5_6/package-info.java similarity index 95% rename from apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-6_4/src/main/java/co/elastic/apm/agent/es/restclient/v6_4/package-info.java rename to apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-5_6/src/main/java/co/elastic/apm/agent/esrestclient5_6/package-info.java index 8fab03706c..ca5cff39e8 100644 --- a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-6_4/src/main/java/co/elastic/apm/agent/es/restclient/v6_4/package-info.java +++ b/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-5_6/src/main/java/co/elastic/apm/agent/esrestclient5_6/package-info.java @@ -23,6 +23,6 @@ * #L% */ @NonnullApi -package co.elastic.apm.agent.es.restclient.v6_4; +package co.elastic.apm.agent.esrestclient5_6; import co.elastic.apm.agent.sdk.NonnullApi; diff --git a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-5_6/src/main/resources/META-INF/services/co.elastic.apm.agent.sdk.ElasticApmInstrumentation b/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-5_6/src/main/resources/META-INF/services/co.elastic.apm.agent.sdk.ElasticApmInstrumentation index 1e8b589aba..2827c8d845 100644 --- a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-5_6/src/main/resources/META-INF/services/co.elastic.apm.agent.sdk.ElasticApmInstrumentation +++ b/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-5_6/src/main/resources/META-INF/services/co.elastic.apm.agent.sdk.ElasticApmInstrumentation @@ -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.esrestclient5_6.ElasticsearchClientSyncInstrumentation +co.elastic.apm.agent.esrestclient5_6.ElasticsearchClientAsyncInstrumentation diff --git a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-5_6/src/test/java/co/elastic/apm/agent/es/restclient/v5_6/ElasticsearchRestClientInstrumentationIT.java b/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-5_6/src/test/java/co/elastic/apm/agent/esrestclient5_6/ElasticsearchRestClientInstrumentationIT.java similarity index 98% rename from apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-5_6/src/test/java/co/elastic/apm/agent/es/restclient/v5_6/ElasticsearchRestClientInstrumentationIT.java rename to apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-5_6/src/test/java/co/elastic/apm/agent/esrestclient5_6/ElasticsearchRestClientInstrumentationIT.java index c73a4457d0..e9c3ded9dd 100644 --- a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-5_6/src/test/java/co/elastic/apm/agent/es/restclient/v5_6/ElasticsearchRestClientInstrumentationIT.java +++ b/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-5_6/src/test/java/co/elastic/apm/agent/esrestclient5_6/ElasticsearchRestClientInstrumentationIT.java @@ -22,9 +22,9 @@ * under the License. * #L% */ -package co.elastic.apm.agent.es.restclient.v5_6; +package co.elastic.apm.agent.esrestclient5_6; -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.apache.http.HttpHost; import org.apache.http.auth.AuthScope; diff --git a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-6_4/src/main/java/co/elastic/apm/agent/es/restclient/v6_4/ElasticsearchClientAsyncInstrumentation.java b/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-6_4/src/main/java/co/elastic/apm/agent/esrestclient6_4/ElasticsearchClientAsyncInstrumentation.java similarity index 94% rename from apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-6_4/src/main/java/co/elastic/apm/agent/es/restclient/v6_4/ElasticsearchClientAsyncInstrumentation.java rename to apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-6_4/src/main/java/co/elastic/apm/agent/esrestclient6_4/ElasticsearchClientAsyncInstrumentation.java index 23ed76c0b8..f42378245b 100644 --- a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-6_4/src/main/java/co/elastic/apm/agent/es/restclient/v6_4/ElasticsearchClientAsyncInstrumentation.java +++ b/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-6_4/src/main/java/co/elastic/apm/agent/esrestclient6_4/ElasticsearchClientAsyncInstrumentation.java @@ -22,10 +22,10 @@ * under the License. * #L% */ -package co.elastic.apm.agent.es.restclient.v6_4; +package co.elastic.apm.agent.esrestclient6_4; -import co.elastic.apm.agent.es.restclient.ElasticsearchRestClientInstrumentation; -import co.elastic.apm.agent.es.restclient.ElasticsearchRestClientInstrumentationHelper; +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 co.elastic.apm.agent.sdk.state.GlobalThreadLocal; diff --git a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-6_4/src/main/java/co/elastic/apm/agent/es/restclient/v6_4/ElasticsearchClientSyncInstrumentation.java b/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-6_4/src/main/java/co/elastic/apm/agent/esrestclient6_4/ElasticsearchClientSyncInstrumentation.java similarity index 93% rename from apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-6_4/src/main/java/co/elastic/apm/agent/es/restclient/v6_4/ElasticsearchClientSyncInstrumentation.java rename to apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-6_4/src/main/java/co/elastic/apm/agent/esrestclient6_4/ElasticsearchClientSyncInstrumentation.java index a2719e42b2..256c9a7779 100644 --- a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-6_4/src/main/java/co/elastic/apm/agent/es/restclient/v6_4/ElasticsearchClientSyncInstrumentation.java +++ b/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-6_4/src/main/java/co/elastic/apm/agent/esrestclient6_4/ElasticsearchClientSyncInstrumentation.java @@ -22,10 +22,10 @@ * under the License. * #L% */ -package co.elastic.apm.agent.es.restclient.v6_4; +package co.elastic.apm.agent.esrestclient6_4; -import co.elastic.apm.agent.es.restclient.ElasticsearchRestClientInstrumentation; -import co.elastic.apm.agent.es.restclient.ElasticsearchRestClientInstrumentationHelper; +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; diff --git a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-5_6/src/main/java/co/elastic/apm/agent/es/restclient/v5_6/package-info.java b/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-6_4/src/main/java/co/elastic/apm/agent/esrestclient6_4/package-info.java similarity index 95% rename from apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-5_6/src/main/java/co/elastic/apm/agent/es/restclient/v5_6/package-info.java rename to apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-6_4/src/main/java/co/elastic/apm/agent/esrestclient6_4/package-info.java index b3b59c752c..9dbd09ff15 100644 --- a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-5_6/src/main/java/co/elastic/apm/agent/es/restclient/v5_6/package-info.java +++ b/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-6_4/src/main/java/co/elastic/apm/agent/esrestclient6_4/package-info.java @@ -23,6 +23,6 @@ * #L% */ @NonnullApi -package co.elastic.apm.agent.es.restclient.v5_6; +package co.elastic.apm.agent.esrestclient6_4; import co.elastic.apm.agent.sdk.NonnullApi; diff --git a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-6_4/src/main/resources/META-INF/services/co.elastic.apm.agent.sdk.ElasticApmInstrumentation b/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-6_4/src/main/resources/META-INF/services/co.elastic.apm.agent.sdk.ElasticApmInstrumentation index 6062b97fc5..5041b57284 100644 --- a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-6_4/src/main/resources/META-INF/services/co.elastic.apm.agent.sdk.ElasticApmInstrumentation +++ b/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-6_4/src/main/resources/META-INF/services/co.elastic.apm.agent.sdk.ElasticApmInstrumentation @@ -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.esrestclient6_4.ElasticsearchClientSyncInstrumentation +co.elastic.apm.agent.esrestclient6_4.ElasticsearchClientAsyncInstrumentation diff --git a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-6_4/src/test/java/co/elastic/apm/agent/es/restclient/v6_4/AbstractEs6_4ClientInstrumentationTest.java b/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-6_4/src/test/java/co/elastic/apm/agent/esrestclient6_4/AbstractEs6_4ClientInstrumentationTest.java similarity index 99% rename from apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-6_4/src/test/java/co/elastic/apm/agent/es/restclient/v6_4/AbstractEs6_4ClientInstrumentationTest.java rename to apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-6_4/src/test/java/co/elastic/apm/agent/esrestclient6_4/AbstractEs6_4ClientInstrumentationTest.java index 6236a6ef0c..84bfeefb1d 100644 --- a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-6_4/src/test/java/co/elastic/apm/agent/es/restclient/v6_4/AbstractEs6_4ClientInstrumentationTest.java +++ b/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-6_4/src/test/java/co/elastic/apm/agent/esrestclient6_4/AbstractEs6_4ClientInstrumentationTest.java @@ -22,9 +22,9 @@ * under the License. * #L% */ -package co.elastic.apm.agent.es.restclient.v6_4; +package co.elastic.apm.agent.esrestclient6_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; diff --git a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-6_4/src/test/java/co/elastic/apm/agent/es/restclient/v6_4/ElasticsearchRestClientInstrumentationIT.java b/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-6_4/src/test/java/co/elastic/apm/agent/esrestclient6_4/ElasticsearchRestClientInstrumentationIT.java similarity index 98% rename from apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-6_4/src/test/java/co/elastic/apm/agent/es/restclient/v6_4/ElasticsearchRestClientInstrumentationIT.java rename to apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-6_4/src/test/java/co/elastic/apm/agent/esrestclient6_4/ElasticsearchRestClientInstrumentationIT.java index 59e6e07e2f..c91e857e97 100644 --- a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-6_4/src/test/java/co/elastic/apm/agent/es/restclient/v6_4/ElasticsearchRestClientInstrumentationIT.java +++ b/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-6_4/src/test/java/co/elastic/apm/agent/esrestclient6_4/ElasticsearchRestClientInstrumentationIT.java @@ -22,7 +22,7 @@ * under the License. * #L% */ -package co.elastic.apm.agent.es.restclient.v6_4; +package co.elastic.apm.agent.esrestclient6_4; import co.elastic.apm.agent.impl.transaction.Span; import org.apache.http.HttpHost; diff --git a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-6_4/src/test/java/co/elastic/apm/agent/es/restclient/v6_4/ElasticsearchRestClientInstrumentationIT_RealReporter.java b/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-6_4/src/test/java/co/elastic/apm/agent/esrestclient6_4/ElasticsearchRestClientInstrumentationIT_RealReporter.java similarity index 99% rename from apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-6_4/src/test/java/co/elastic/apm/agent/es/restclient/v6_4/ElasticsearchRestClientInstrumentationIT_RealReporter.java rename to apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-6_4/src/test/java/co/elastic/apm/agent/esrestclient6_4/ElasticsearchRestClientInstrumentationIT_RealReporter.java index d03765bffc..26912d83de 100644 --- a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-6_4/src/test/java/co/elastic/apm/agent/es/restclient/v6_4/ElasticsearchRestClientInstrumentationIT_RealReporter.java +++ b/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-6_4/src/test/java/co/elastic/apm/agent/esrestclient6_4/ElasticsearchRestClientInstrumentationIT_RealReporter.java @@ -22,7 +22,7 @@ * under the License. * #L% */ -package co.elastic.apm.agent.es.restclient.v6_4; +package co.elastic.apm.agent.esrestclient6_4; import co.elastic.apm.agent.bci.ElasticApmAgent; import co.elastic.apm.agent.configuration.SpyConfiguration; diff --git a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-7_1/src/test/java/co/elastic/apm/agent/es/restclient/v7_1/ElasticsearchRestClientInstrumentationIT.java b/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-7_1/src/test/java/co/elastic/apm/agent/esrestclient7_1/ElasticsearchRestClientInstrumentationIT.java similarity index 97% rename from apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-7_1/src/test/java/co/elastic/apm/agent/es/restclient/v7_1/ElasticsearchRestClientInstrumentationIT.java rename to apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-7_1/src/test/java/co/elastic/apm/agent/esrestclient7_1/ElasticsearchRestClientInstrumentationIT.java index c4c89ac684..586460d685 100644 --- a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-7_1/src/test/java/co/elastic/apm/agent/es/restclient/v7_1/ElasticsearchRestClientInstrumentationIT.java +++ b/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-7_1/src/test/java/co/elastic/apm/agent/esrestclient7_1/ElasticsearchRestClientInstrumentationIT.java @@ -22,9 +22,9 @@ * under the License. * #L% */ -package co.elastic.apm.agent.es.restclient.v7_1; +package co.elastic.apm.agent.esrestclient7_1; -import co.elastic.apm.agent.es.restclient.v6_4.AbstractEs6_4ClientInstrumentationTest; +import co.elastic.apm.agent.esrestclient6_4.AbstractEs6_4ClientInstrumentationTest; import co.elastic.apm.agent.impl.transaction.Span; import org.apache.http.HttpHost; import org.apache.http.impl.client.BasicCredentialsProvider; diff --git a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-common/src/main/java/co/elastic/apm/agent/es/restclient/ElasticsearchRestClientInstrumentation.java b/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-common/src/main/java/co/elastic/apm/agent/esrestclient/ElasticsearchRestClientInstrumentation.java similarity index 96% rename from apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-common/src/main/java/co/elastic/apm/agent/es/restclient/ElasticsearchRestClientInstrumentation.java rename to apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-common/src/main/java/co/elastic/apm/agent/esrestclient/ElasticsearchRestClientInstrumentation.java index 5fe44cb648..5c5bc66dd4 100644 --- a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-common/src/main/java/co/elastic/apm/agent/es/restclient/ElasticsearchRestClientInstrumentation.java +++ b/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-common/src/main/java/co/elastic/apm/agent/esrestclient/ElasticsearchRestClientInstrumentation.java @@ -22,7 +22,7 @@ * under the License. * #L% */ -package co.elastic.apm.agent.es.restclient; +package co.elastic.apm.agent.esrestclient; import co.elastic.apm.agent.bci.TracerAwareInstrumentation; diff --git a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-common/src/main/java/co/elastic/apm/agent/es/restclient/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 similarity index 99% rename from apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-common/src/main/java/co/elastic/apm/agent/es/restclient/ElasticsearchRestClientInstrumentationHelper.java rename to apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-common/src/main/java/co/elastic/apm/agent/esrestclient/ElasticsearchRestClientInstrumentationHelper.java index 5f998b6573..6c9dcebdfb 100644 --- a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-common/src/main/java/co/elastic/apm/agent/es/restclient/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 @@ -22,7 +22,7 @@ * under the License. * #L% */ -package co.elastic.apm.agent.es.restclient; +package co.elastic.apm.agent.esrestclient; import co.elastic.apm.agent.impl.transaction.AbstractSpan; import co.elastic.apm.agent.impl.transaction.Span; diff --git a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-common/src/main/java/co/elastic/apm/agent/es/restclient/ResponseListenerWrapper.java b/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-common/src/main/java/co/elastic/apm/agent/esrestclient/ResponseListenerWrapper.java similarity index 98% rename from apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-common/src/main/java/co/elastic/apm/agent/es/restclient/ResponseListenerWrapper.java rename to apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-common/src/main/java/co/elastic/apm/agent/esrestclient/ResponseListenerWrapper.java index 94f2888d60..5d1e00c647 100644 --- a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-common/src/main/java/co/elastic/apm/agent/es/restclient/ResponseListenerWrapper.java +++ b/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-common/src/main/java/co/elastic/apm/agent/esrestclient/ResponseListenerWrapper.java @@ -22,7 +22,7 @@ * under the License. * #L% */ -package co.elastic.apm.agent.es.restclient; +package co.elastic.apm.agent.esrestclient; import co.elastic.apm.agent.impl.transaction.Span; import co.elastic.apm.agent.objectpool.Recyclable; diff --git a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-common/src/main/java/co/elastic/apm/agent/es/restclient/package-info.java b/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-common/src/main/java/co/elastic/apm/agent/esrestclient/package-info.java similarity index 95% rename from apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-common/src/main/java/co/elastic/apm/agent/es/restclient/package-info.java rename to apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-common/src/main/java/co/elastic/apm/agent/esrestclient/package-info.java index 4b2c3e7f3d..1804b1631e 100644 --- a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-common/src/main/java/co/elastic/apm/agent/es/restclient/package-info.java +++ b/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-common/src/main/java/co/elastic/apm/agent/esrestclient/package-info.java @@ -23,6 +23,6 @@ * #L% */ @NonnullApi -package co.elastic.apm.agent.es.restclient; +package co.elastic.apm.agent.esrestclient; import co.elastic.apm.agent.sdk.NonnullApi; diff --git a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-common/src/test/java/co/elastic/apm/agent/es/restclient/AbstractEsClientInstrumentationTest.java b/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-common/src/test/java/co/elastic/apm/agent/esrestclient/AbstractEsClientInstrumentationTest.java similarity index 94% rename from apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-common/src/test/java/co/elastic/apm/agent/es/restclient/AbstractEsClientInstrumentationTest.java rename to apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-common/src/test/java/co/elastic/apm/agent/esrestclient/AbstractEsClientInstrumentationTest.java index 94cdf7dfa3..f843462dc2 100644 --- a/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-common/src/test/java/co/elastic/apm/agent/es/restclient/AbstractEsClientInstrumentationTest.java +++ b/apm-agent-plugins/apm-es-restclient-plugin/apm-es-restclient-plugin-common/src/test/java/co/elastic/apm/agent/esrestclient/AbstractEsClientInstrumentationTest.java @@ -22,7 +22,7 @@ * under the License. * #L% */ -package co.elastic.apm.agent.es.restclient; +package co.elastic.apm.agent.esrestclient; import co.elastic.apm.agent.AbstractInstrumentationTest; import co.elastic.apm.agent.impl.context.Db; @@ -40,9 +40,9 @@ import java.util.Arrays; import java.util.List; -import static co.elastic.apm.agent.es.restclient.ElasticsearchRestClientInstrumentationHelper.ELASTICSEARCH; -import static co.elastic.apm.agent.es.restclient.ElasticsearchRestClientInstrumentationHelper.SPAN_ACTION; -import static co.elastic.apm.agent.es.restclient.ElasticsearchRestClientInstrumentationHelper.SPAN_TYPE; +import static co.elastic.apm.agent.esrestclient.ElasticsearchRestClientInstrumentationHelper.ELASTICSEARCH; +import static co.elastic.apm.agent.esrestclient.ElasticsearchRestClientInstrumentationHelper.SPAN_ACTION; +import static co.elastic.apm.agent.esrestclient.ElasticsearchRestClientInstrumentationHelper.SPAN_TYPE; import static org.assertj.core.api.Assertions.assertThat; public abstract class AbstractEsClientInstrumentationTest extends AbstractInstrumentationTest {