Skip to content

Commit 45a6329

Browse files
authored
Merge branch 'master' into dougqh/dbinfo-default-final
2 parents fa947f9 + 786c771 commit 45a6329

9 files changed

Lines changed: 54 additions & 21 deletions

File tree

.gitlab-ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,8 @@ muzzle-dep-report:
585585
when: on_success
586586
- if: $CI_COMMIT_BRANCH == "master"
587587
when: on_success
588+
- if: '$CI_COMMIT_BRANCH =~ /^mq-working-branch-/'
589+
when: on_success
588590
script:
589591
- *gitlab_base_ref_params
590592
- >

dd-java-agent/instrumentation/elasticsearch/elasticsearch-transport/elasticsearch-transport-2.0/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ muzzle {
44
module = "elasticsearch"
55
versions = "[2.0,3)"
66
assertInverse = true
7-
skipVersions = ["7.11.0", "7.17.8", "8.8.0"]
7+
skipVersions = ["7.11.0", "7.17.8", "8.8.0", "9.3.0"]
88
}
99
}
1010

dd-java-agent/instrumentation/elasticsearch/elasticsearch-transport/elasticsearch-transport-5.0/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ muzzle {
1111
module = "elasticsearch"
1212
versions = "[5.0.0,5.3.0)"
1313
assertInverse = true
14-
skipVersions = ["7.11.0", "7.17.8", "8.8.0"]
14+
skipVersions = ["7.11.0", "7.17.8", "8.8.0", "9.3.0"]
1515
}
1616
}
1717

dd-java-agent/instrumentation/elasticsearch/elasticsearch-transport/elasticsearch-transport-5.3/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ muzzle {
1212
module = "elasticsearch"
1313
versions = "[5.3.0,6.0.0)"
1414
assertInverse = true
15-
skipVersions = ["7.11.0", "7.17.8", "8.8.0"]
15+
skipVersions = ["7.11.0", "7.17.8", "8.8.0", "9.3.0"]
1616
}
1717
}
1818

dd-java-agent/instrumentation/elasticsearch/elasticsearch-transport/elasticsearch-transport-6.0/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ muzzle {
1111
group = "org.elasticsearch"
1212
module = "elasticsearch"
1313
versions = "[6.0.0,8.0.0)"
14-
skipVersions = ["7.11.0", "7.17.8", "8.8.0"]
14+
skipVersions = ["7.11.0", "7.17.8", "8.8.0", "9.3.0"]
1515
assertInverse = true
1616
}
1717
}

dd-java-agent/instrumentation/elasticsearch/elasticsearch-transport/elasticsearch-transport-7.3/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ muzzle {
1212
module = "elasticsearch"
1313
versions = "[7.3,8.0.0)"
1414
assertInverse = true
15-
skipVersions = ["7.11.0", "7.17.8", "8.8.0"]
15+
skipVersions = ["7.11.0", "7.17.8", "8.8.0", "9.3.0"]
1616
}
1717
}
1818

dd-java-agent/instrumentation/elasticsearch/elasticsearch-transport/elasticsearch-transport-common/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ muzzle {
1212
module = "elasticsearch"
1313
versions = "[2.0,)"
1414
assertInverse = true
15-
skipVersions = ["7.11.0", "7.17.8", "8.8.0"]
15+
skipVersions = ["7.11.0", "7.17.8", "8.8.0", "9.3.0"]
1616
}
1717
}
1818

dd-java-agent/instrumentation/synapse-3.0/src/main/java/datadog/trace/instrumentation/synapse3/SynapseClientInstrumentation.java

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import datadog.trace.bootstrap.instrumentation.api.AgentSpan;
2222
import net.bytebuddy.asm.Advice;
2323
import org.apache.axis2.context.MessageContext;
24+
import org.apache.http.HttpResponse;
2425
import org.apache.http.nio.NHttpClientConnection;
2526
import org.apache.synapse.transport.passthru.TargetContext;
2627

@@ -113,8 +114,8 @@ public static final class ClientResponseAdvice {
113114
@Advice.OnMethodEnter(suppress = Throwable.class)
114115
public static ContextScope beginResponse(
115116
@Advice.Argument(0) final NHttpClientConnection connection) {
116-
// check and remove context so it won't be finished twice
117-
Context context = (Context) connection.getContext().removeAttribute(SYNAPSE_CONTEXT_KEY);
117+
// don't remove stored context here because the response callback may run multiple times
118+
Context context = (Context) connection.getContext().getAttribute(SYNAPSE_CONTEXT_KEY);
118119
if (null != context) {
119120
return context.attach();
120121
}
@@ -129,15 +130,30 @@ public static void responseReceived(
129130
if (null == scope) {
130131
return;
131132
}
132-
AgentSpan span = spanFromContext(scope.context());
133-
DECORATE.onResponse(span, connection.getHttpResponse());
133+
final AgentSpan span = spanFromContext(scope.context());
134+
final HttpResponse httpResponse = connection.getHttpResponse();
135+
boolean isFinal = false;
136+
if (httpResponse != null && httpResponse.getStatusLine() != null) {
137+
int statusCode = httpResponse.getStatusLine().getStatusCode();
138+
// 1xx (e.g. 100 Continue) - not final response
139+
isFinal = statusCode >= 200;
140+
}
141+
142+
if (isFinal) {
143+
DECORATE.onResponse(span, httpResponse);
144+
}
134145
if (null != error) {
135146
DECORATE.onError(span, error);
136147
}
137-
DECORATE.beforeFinish(scope.context());
138-
scope.close();
139-
if (span != null) {
140-
span.finish();
148+
if ((isFinal || error != null)
149+
&& connection.getContext().removeAttribute(SYNAPSE_CONTEXT_KEY) != null) {
150+
DECORATE.beforeFinish(scope.context());
151+
scope.close();
152+
if (span != null) {
153+
span.finish();
154+
}
155+
} else {
156+
scope.close();
141157
}
142158
}
143159
}

dd-java-agent/instrumentation/synapse-3.0/src/main/java/datadog/trace/instrumentation/synapse3/SynapseServerInstrumentation.java

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import datadog.trace.bootstrap.instrumentation.api.AgentSpan;
1818
import net.bytebuddy.asm.Advice;
1919
import org.apache.http.HttpRequest;
20+
import org.apache.http.HttpResponse;
2021
import org.apache.http.nio.NHttpServerConnection;
2122

2223
@AutoService(InstrumenterModule.class)
@@ -92,8 +93,8 @@ public static final class ServerResponseAdvice {
9293
@Advice.OnMethodEnter(suppress = Throwable.class)
9394
public static ContextScope beginResponse(
9495
@Advice.Argument(0) final NHttpServerConnection connection) {
95-
// check and remove context so it won't be finished twice
96-
Context context = (Context) connection.getContext().removeAttribute(SYNAPSE_CONTEXT_KEY);
96+
// don't remove stored context here because the response callback may run multiple times
97+
Context context = (Context) connection.getContext().getAttribute(SYNAPSE_CONTEXT_KEY);
9798
if (null != context) {
9899
return context.attach();
99100
}
@@ -108,14 +109,28 @@ public static void responseReady(
108109
if (null == scope) {
109110
return;
110111
}
111-
AgentSpan span = spanFromContext(scope.context());
112-
DECORATE.onResponse(span, connection.getHttpResponse());
112+
final AgentSpan span = spanFromContext(scope.context());
113+
final HttpResponse httpResponse = connection.getHttpResponse();
114+
boolean isFinal = false;
115+
if (httpResponse != null && httpResponse.getStatusLine() != null) {
116+
isFinal = httpResponse.getStatusLine().getStatusCode() >= 200;
117+
}
118+
119+
if (isFinal) {
120+
DECORATE.onResponse(span, httpResponse);
121+
}
113122
if (null != error) {
114123
DECORATE.onError(span, error);
115124
}
116-
DECORATE.beforeFinish(scope.context());
117-
scope.close();
118-
span.finish();
125+
126+
if ((isFinal || error != null)
127+
&& connection.getContext().removeAttribute(SYNAPSE_CONTEXT_KEY) != null) {
128+
DECORATE.beforeFinish(scope.context());
129+
scope.close();
130+
span.finish();
131+
} else {
132+
scope.close();
133+
}
119134
}
120135
}
121136

0 commit comments

Comments
 (0)