Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import co.elastic.apm.agent.collections.WeakConcurrentProviderImpl;
import co.elastic.apm.agent.impl.Tracer;
import co.elastic.apm.agent.impl.context.web.ResultUtil;
import co.elastic.apm.agent.impl.transaction.Outcome;
import co.elastic.apm.agent.impl.transaction.Span;
import co.elastic.apm.agent.sdk.weakconcurrent.WeakMap;
Expand Down Expand Up @@ -72,13 +73,11 @@ public void onNext(T t) {
boolean hasActivated = doEnter("onNext", span);
Throwable thrown = null;
try {
if (t instanceof ClientResponse) {
if (span != null && t instanceof ClientResponse) {
ClientResponse clientResponse = (ClientResponse) t;
int statusCode = clientResponse.rawStatusCode();
if (400 <= statusCode && statusCode < 500 && span.getOutcome() == null) {
span.withOutcome(Outcome.FAILURE);
}
span.getContext().getHttp().withStatusCode(clientResponse.rawStatusCode());
span.withOutcome(ResultUtil.getOutcomeByHttpClientStatus(statusCode));
span.getContext().getHttp().withStatusCode(statusCode);
}
subscriber.onNext(t);
} catch (Throwable e) {
Expand All @@ -96,7 +95,6 @@ public void onError(Throwable throwable) {
boolean hasActivated = doEnter("onError", span);
try {
subscriber.onError(throwable);
span = span.withOutcome(Outcome.FAILURE);
} finally {
doExit(hasActivated, "onError", span);
discardIf(true);
Expand All @@ -110,9 +108,6 @@ public void onComplete() {
boolean hasActivated = doEnter("onComplete", span);
try {
subscriber.onComplete();
if (span.getOutcome() == null) {
span.withOutcome(Outcome.SUCCESS);
}
} finally {
doExit(hasActivated, "onComplete", span);
discardIf(true);
Expand Down Expand Up @@ -190,12 +185,10 @@ private void cancelSpan() {
Span span = getSpan();
debugTrace(true, "cancelSpan", span);
try {
if (span == null) {
return;
if (span != null) {
endSpan(null, span);
spanMap.remove(this);
}
endSpan(null, span);

spanMap.remove(this);
} finally {
debugTrace(false, "cancelSpan", span);
}
Expand Down