Review comments
This commit is contained in:
parent
56aaccb0c2
commit
57bae1688e
|
@ -10,6 +10,12 @@ muzzle {
|
||||||
versions = "[5.0,6.4)"
|
versions = "[5.0,6.4)"
|
||||||
assertInverse = true
|
assertInverse = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pass {
|
||||||
|
group = "org.elasticsearch.client"
|
||||||
|
module = "elasticsearch-rest-client"
|
||||||
|
versions = "[5.0,6.4)"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
apply from: "${rootDir}/gradle/java.gradle"
|
apply from: "${rootDir}/gradle/java.gradle"
|
||||||
|
@ -43,11 +49,6 @@ dependencies {
|
||||||
testCompile group: 'org.elasticsearch', name: 'elasticsearch', version: '5.0.0'
|
testCompile group: 'org.elasticsearch', name: 'elasticsearch', version: '5.0.0'
|
||||||
testCompile group: 'org.elasticsearch.plugin', name: 'transport-netty3-client', version: '5.0.0'
|
testCompile group: 'org.elasticsearch.plugin', name: 'transport-netty3-client', version: '5.0.0'
|
||||||
|
|
||||||
/*
|
|
||||||
We know that 6.3.+ Doesn't work because they've reworked relevant code.
|
|
||||||
See https://github.com/elastic/elasticsearch/commit/0be443c5bbd4c7eb5776740d8fb7117224124cce#diff-d5bb3520f960a753d8f8a3a2686dfd6b
|
|
||||||
Lock on 6.2.+ to fix tests.
|
|
||||||
*/
|
|
||||||
latestDepTestCompile group: 'org.elasticsearch.client', name: 'elasticsearch-rest-client', version: '6.3.+'
|
latestDepTestCompile group: 'org.elasticsearch.client', name: 'elasticsearch-rest-client', version: '6.3.+'
|
||||||
latestDepTestCompile group: 'org.elasticsearch', name: 'elasticsearch', version: '6.3.+'
|
latestDepTestCompile group: 'org.elasticsearch', name: 'elasticsearch', version: '6.3.+'
|
||||||
latestDepTestCompile group: 'org.elasticsearch.plugin', name: 'transport-netty4-client', version: '6.3.+'
|
latestDepTestCompile group: 'org.elasticsearch.plugin', name: 'transport-netty4-client', version: '6.3.+'
|
||||||
|
|
|
@ -58,11 +58,11 @@ public class Elasticsearch5RestClientInstrumentation extends Instrumenter.Defaul
|
||||||
|
|
||||||
@Advice.OnMethodEnter(suppress = Throwable.class)
|
@Advice.OnMethodEnter(suppress = Throwable.class)
|
||||||
public static Scope startSpan(
|
public static Scope startSpan(
|
||||||
@Advice.Argument(0) String method,
|
@Advice.Argument(0) final String method,
|
||||||
@Advice.Argument(1) String endpoint,
|
@Advice.Argument(1) final String endpoint,
|
||||||
@Advice.Argument(value = 5, readOnly = false) ResponseListener responseListener) {
|
@Advice.Argument(value = 5, readOnly = false) ResponseListener responseListener) {
|
||||||
|
|
||||||
Scope scope =
|
final Scope scope =
|
||||||
GlobalTracer.get()
|
GlobalTracer.get()
|
||||||
.buildSpan("elasticsearch.rest.query")
|
.buildSpan("elasticsearch.rest.query")
|
||||||
.withTag(DDTags.SERVICE_NAME, "elasticsearch")
|
.withTag(DDTags.SERVICE_NAME, "elasticsearch")
|
||||||
|
@ -78,9 +78,10 @@ public class Elasticsearch5RestClientInstrumentation extends Instrumenter.Defaul
|
||||||
}
|
}
|
||||||
|
|
||||||
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
|
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
|
||||||
public static void stopSpan(@Advice.Enter Scope scope, @Advice.Thrown Throwable throwable) {
|
public static void stopSpan(
|
||||||
|
@Advice.Enter final Scope scope, @Advice.Thrown final Throwable throwable) {
|
||||||
if (throwable != null) {
|
if (throwable != null) {
|
||||||
Span span = scope.span();
|
final Span span = scope.span();
|
||||||
Tags.ERROR.set(span, true);
|
Tags.ERROR.set(span, true);
|
||||||
span.log(Collections.singletonMap(ERROR_OBJECT, throwable));
|
span.log(Collections.singletonMap(ERROR_OBJECT, throwable));
|
||||||
span.finish();
|
span.finish();
|
||||||
|
|
|
@ -6,10 +6,17 @@ ext {
|
||||||
muzzle {
|
muzzle {
|
||||||
pass {
|
pass {
|
||||||
group = "org.elasticsearch.client"
|
group = "org.elasticsearch.client"
|
||||||
module = "rest" // elasticsearch-rest-client ?
|
module = "relasticsearch-rest-client"
|
||||||
versions = "[6.4,)"
|
versions = "[6.4,)"
|
||||||
assertInverse = true
|
assertInverse = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fail {
|
||||||
|
group = "org.elasticsearch.client"
|
||||||
|
module = "rest"
|
||||||
|
versions = "(,)"
|
||||||
|
assertInverse = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
apply from: "${rootDir}/gradle/java.gradle"
|
apply from: "${rootDir}/gradle/java.gradle"
|
||||||
|
|
|
@ -58,10 +58,10 @@ public class Elasticsearch6RestClientInstrumentation extends Instrumenter.Defaul
|
||||||
|
|
||||||
@Advice.OnMethodEnter(suppress = Throwable.class)
|
@Advice.OnMethodEnter(suppress = Throwable.class)
|
||||||
public static Scope startSpan(
|
public static Scope startSpan(
|
||||||
@Advice.Argument(0) Request request,
|
@Advice.Argument(0) final Request request,
|
||||||
@Advice.Argument(value = 1, readOnly = false) ResponseListener responseListener) {
|
@Advice.Argument(value = 1, readOnly = false) ResponseListener responseListener) {
|
||||||
|
|
||||||
Scope scope =
|
final Scope scope =
|
||||||
GlobalTracer.get()
|
GlobalTracer.get()
|
||||||
.buildSpan("elasticsearch.rest.query")
|
.buildSpan("elasticsearch.rest.query")
|
||||||
.withTag(DDTags.SERVICE_NAME, "elasticsearch")
|
.withTag(DDTags.SERVICE_NAME, "elasticsearch")
|
||||||
|
@ -77,9 +77,10 @@ public class Elasticsearch6RestClientInstrumentation extends Instrumenter.Defaul
|
||||||
}
|
}
|
||||||
|
|
||||||
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
|
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
|
||||||
public static void stopSpan(@Advice.Enter Scope scope, @Advice.Thrown Throwable throwable) {
|
public static void stopSpan(
|
||||||
|
@Advice.Enter final Scope scope, @Advice.Thrown final Throwable throwable) {
|
||||||
if (throwable != null) {
|
if (throwable != null) {
|
||||||
Span span = scope.span();
|
final Span span = scope.span();
|
||||||
Tags.ERROR.set(span, true);
|
Tags.ERROR.set(span, true);
|
||||||
span.log(Collections.singletonMap(ERROR_OBJECT, throwable));
|
span.log(Collections.singletonMap(ERROR_OBJECT, throwable));
|
||||||
span.finish();
|
span.finish();
|
||||||
|
|
|
@ -13,13 +13,13 @@ public class RestResponseListener implements ResponseListener {
|
||||||
private final ResponseListener listener;
|
private final ResponseListener listener;
|
||||||
private final Span span;
|
private final Span span;
|
||||||
|
|
||||||
public RestResponseListener(ResponseListener listener, Span span) {
|
public RestResponseListener(final ResponseListener listener, final Span span) {
|
||||||
this.listener = listener;
|
this.listener = listener;
|
||||||
this.span = span;
|
this.span = span;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(Response response) {
|
public void onSuccess(final Response response) {
|
||||||
if (response.getHost() != null) {
|
if (response.getHost() != null) {
|
||||||
Tags.PEER_HOSTNAME.set(span, response.getHost().getHostName());
|
Tags.PEER_HOSTNAME.set(span, response.getHost().getHostName());
|
||||||
Tags.PEER_PORT.set(span, response.getHost().getPort());
|
Tags.PEER_PORT.set(span, response.getHost().getPort());
|
||||||
|
@ -33,7 +33,7 @@ public class RestResponseListener implements ResponseListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Exception e) {
|
public void onFailure(final Exception e) {
|
||||||
span.log(Collections.singletonMap(ERROR_OBJECT, e));
|
span.log(Collections.singletonMap(ERROR_OBJECT, e));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in New Issue