Skip to content

Commit

Permalink
record exception in dubbo inst (#3851)
Browse files Browse the repository at this point in the history
* record exception in dubbo inst

* record exception in dubbo inst

* remove unused imports

* remove unused imports
  • Loading branch information
tydhot committed Aug 18, 2021
1 parent 667b87b commit 60424e0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
package io.opentelemetry.instrumentation.apachedubbo.v2_7;

import io.opentelemetry.api.trace.SpanBuilder;
import io.opentelemetry.api.trace.StatusCode;
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
import org.apache.dubbo.rpc.Result;

class DubboHelper {

Expand All @@ -22,8 +20,4 @@ static void prepareSpan(SpanBuilder span, String interfaceName, String methodNam
static String getSpanName(String interfaceName, String methodName) {
return interfaceName + "/" + methodName;
}

static StatusCode statusFromResult(Result result) {
return !result.hasException() ? StatusCode.UNSET : StatusCode.ERROR;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
import static io.opentelemetry.api.trace.SpanKind.CLIENT;
import static io.opentelemetry.api.trace.SpanKind.SERVER;

import io.opentelemetry.api.trace.Span;
import io.opentelemetry.api.trace.SpanBuilder;
import io.opentelemetry.api.trace.StatusCode;
import io.opentelemetry.context.Context;
import io.opentelemetry.context.propagation.TextMapGetter;
import io.opentelemetry.instrumentation.api.tracer.RpcServerTracer;
Expand Down Expand Up @@ -46,9 +44,8 @@ public Context startClientSpan(String interfaceName, String methodName) {
}

public void end(Context context, Result result) {
StatusCode statusCode = DubboHelper.statusFromResult(result);
if (statusCode != StatusCode.UNSET) {
Span.fromContext(context).setStatus(statusCode);
if (result.hasException()) {
onException(context, result.getException());
}
end(context);
}
Expand Down

0 comments on commit 60424e0

Please sign in to comment.