record exception in dubbo inst (#3851)
* record exception in dubbo inst * record exception in dubbo inst * remove unused imports * remove unused imports
This commit is contained in:
parent
667b87bac7
commit
60424e0d38
|
@ -6,9 +6,7 @@
|
||||||
package io.opentelemetry.instrumentation.apachedubbo.v2_7;
|
package io.opentelemetry.instrumentation.apachedubbo.v2_7;
|
||||||
|
|
||||||
import io.opentelemetry.api.trace.SpanBuilder;
|
import io.opentelemetry.api.trace.SpanBuilder;
|
||||||
import io.opentelemetry.api.trace.StatusCode;
|
|
||||||
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
|
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
|
||||||
import org.apache.dubbo.rpc.Result;
|
|
||||||
|
|
||||||
class DubboHelper {
|
class DubboHelper {
|
||||||
|
|
||||||
|
@ -22,8 +20,4 @@ class DubboHelper {
|
||||||
static String getSpanName(String interfaceName, String methodName) {
|
static String getSpanName(String interfaceName, String methodName) {
|
||||||
return interfaceName + "/" + methodName;
|
return interfaceName + "/" + methodName;
|
||||||
}
|
}
|
||||||
|
|
||||||
static StatusCode statusFromResult(Result result) {
|
|
||||||
return !result.hasException() ? StatusCode.UNSET : StatusCode.ERROR;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,9 +8,7 @@ package io.opentelemetry.instrumentation.apachedubbo.v2_7;
|
||||||
import static io.opentelemetry.api.trace.SpanKind.CLIENT;
|
import static io.opentelemetry.api.trace.SpanKind.CLIENT;
|
||||||
import static io.opentelemetry.api.trace.SpanKind.SERVER;
|
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.SpanBuilder;
|
||||||
import io.opentelemetry.api.trace.StatusCode;
|
|
||||||
import io.opentelemetry.context.Context;
|
import io.opentelemetry.context.Context;
|
||||||
import io.opentelemetry.context.propagation.TextMapGetter;
|
import io.opentelemetry.context.propagation.TextMapGetter;
|
||||||
import io.opentelemetry.instrumentation.api.tracer.RpcServerTracer;
|
import io.opentelemetry.instrumentation.api.tracer.RpcServerTracer;
|
||||||
|
@ -46,9 +44,8 @@ class DubboTracer extends RpcServerTracer<RpcInvocation> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void end(Context context, Result result) {
|
public void end(Context context, Result result) {
|
||||||
StatusCode statusCode = DubboHelper.statusFromResult(result);
|
if (result.hasException()) {
|
||||||
if (statusCode != StatusCode.UNSET) {
|
onException(context, result.getException());
|
||||||
Span.fromContext(context).setStatus(statusCode);
|
|
||||||
}
|
}
|
||||||
end(context);
|
end(context);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue