New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bump co.elastic.clients:elasticsearch-java from 8.8.1 to 8.9.0 #3283
Changes from 3 commits
0179867
d164ad3
60b6856
07260ba
879fe59
43980ee
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,35 +21,35 @@ | |
import co.elastic.apm.agent.esrestclient.ElasticsearchRestClientInstrumentation; | ||
import co.elastic.apm.agent.esrestclient.ElasticsearchRestClientInstrumentationHelper; | ||
import co.elastic.clients.transport.Endpoint; | ||
import co.elastic.clients.transport.TransportOptions; | ||
import net.bytebuddy.asm.Advice; | ||
import net.bytebuddy.description.method.MethodDescription; | ||
import net.bytebuddy.description.type.TypeDescription; | ||
import net.bytebuddy.matcher.ElementMatcher; | ||
import org.elasticsearch.client.Request; | ||
|
||
import static net.bytebuddy.matcher.ElementMatchers.named; | ||
import static net.bytebuddy.matcher.ElementMatchers.returns; | ||
import static net.bytebuddy.matcher.ElementMatchers.takesArgument; | ||
import static net.bytebuddy.matcher.ElementMatchers.takesArguments; | ||
import static net.bytebuddy.matcher.ElementMatchers.*; | ||
|
||
/** | ||
* Instruments {@link co.elastic.clients.transport.rest_client.RestClientTransport#prepareLowLevelRequest(Object, Endpoint, TransportOptions)}. | ||
* Instruments: | ||
* <ul> | ||
* <li>{@link co.elastic.clients.transport.rest_client.RestClientTransport#performRequest}</li> | ||
* <li>{@link co.elastic.clients.transport.rest_client.RestClientTransport#performRequestAsync} </li> | ||
* </ul> | ||
* To store the current endpoint ID in a thread-local storage | ||
*/ | ||
@SuppressWarnings("JavadocReference") | ||
public class RestClientTransportInstrumentation extends ElasticsearchRestClientInstrumentation { | ||
|
||
@Override | ||
public ElementMatcher<? super TypeDescription> getTypeMatcher() { | ||
return named("co.elastic.clients.transport.rest_client.RestClientTransport"); | ||
return named("co.elastic.clients.transport.rest_client.RestClientTransport") // 8.x up to 8.8.x | ||
.or(named("co.elastic.clients.transport.ElasticsearchTransportBase")); // 8.9.0+ | ||
} | ||
|
||
@Override | ||
public ElementMatcher<? super MethodDescription> getMethodMatcher() { | ||
return named("prepareLowLevelRequest") | ||
return named("performRequest") | ||
.or(named("performRequestAsync")) | ||
.and(takesArguments(3)) | ||
.and(takesArgument(1, named("co.elastic.clients.transport.Endpoint"))) | ||
.and(returns(named("org.elasticsearch.client.Request"))); | ||
.and(takesArgument(1, named("co.elastic.clients.transport.Endpoint"))); | ||
} | ||
|
||
@Override | ||
|
@@ -61,10 +61,14 @@ public static class RestClientTransportAdvice { | |
|
||
private static final ElasticsearchRestClientInstrumentationHelper helper = ElasticsearchRestClientInstrumentationHelper.get(); | ||
|
||
@Advice.OnMethodEnter(suppress = Throwable.class, inline = false) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [for reviewer] instead of keeping track of the request object (which is wrapped/replaced at least twice in the new implementation), we just use a thread-local value to store the endpoint ID for the duration of the |
||
public static void onEnter(@Advice.Argument(1) Endpoint<?, ?, ?> endpoint) { | ||
helper.setCurrentEndpoint(endpoint.id()); | ||
} | ||
|
||
@Advice.OnMethodExit(suppress = Throwable.class, inline = false) | ||
public static void onPrepareLowLevelRequest(@Advice.Argument(1) Endpoint<?, ?, ?> endpoint, @Advice.Return Request request) { | ||
helper.registerEndpointId(request, endpoint.id()); | ||
@Advice.OnMethodExit(suppress = Throwable.class, onThrowable = Throwable.class, inline = false) | ||
public static void onExit() { | ||
helper.clearCurrentEndpoint(); | ||
} | ||
|
||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -875,14 +875,16 @@ public final class ElasticsearchEndpointMap { | |
private ElasticsearchEndpointMap() { | ||
} | ||
|
||
private static void initEndpoint( | ||
Map<String, ElasticsearchEndpointDefinition> map, | ||
String endpointId, | ||
boolean isSearchEndpoint, | ||
String... routes) { | ||
ElasticsearchEndpointDefinition endpointDef = | ||
new ElasticsearchEndpointDefinition(endpointId, routes, isSearchEndpoint); | ||
private static void initEndpoint(Map<String, ElasticsearchEndpointDefinition> map, | ||
String endpointId, | ||
boolean isSearchEndpoint, | ||
String... routes) { | ||
|
||
ElasticsearchEndpointDefinition endpointDef = new ElasticsearchEndpointDefinition(endpointId, routes, isSearchEndpoint); | ||
map.put(endpointId, endpointDef); | ||
|
||
// duplicate entries for allocation-free lookup with 'es/' prefix. | ||
map.put("es/" + endpointId, endpointDef); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [for reviewer] this allows to make the lookup allocation free (endpoint ID was modified before lookup in in |
||
} | ||
|
||
@Nullable | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[for reviewer] this annotation was already present in interface implementation.