@Test public void testStartRpc() throws Exception { this.rpcSofaTracer.startRpc(sofaRequest); SofaTraceContext sofaTraceContext = SofaTraceContextHolder.getSofaTraceContext(); SofaTracerSpan sofaTracerSpan = sofaTraceContext.pop(); assertNotNull(sofaTracerSpan); System.err.println("\n" + sofaTracerSpan); }
@Override public void startRpc(SofaRequest request) { SofaTraceContext sofaTraceContext = SofaTraceContextHolder.getSofaTraceContext(); SofaTracerSpan serverSpan = sofaTraceContext.pop(); SofaTracerSpan clientSpan = (SofaTracerSpan) this.sofaTracer.buildSpan(request.getInterfaceName()) .asChildOf(serverSpan) .withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_CLIENT) .start(); if (RpcInternalContext.isAttachmentEnable()) { RpcInternalContext context = RpcInternalContext.getContext(); clientSpan .setTag(RpcSpanTags.LOCAL_APP, (String) context.getAttachment(RpcConstants.INTERNAL_KEY_APP_NAME)); clientSpan.setTag(RpcSpanTags.PROTOCOL, (String) context.getAttachment(RpcConstants.INTERNAL_KEY_PROTOCOL_NAME)); SofaTracerSpanContext spanContext = clientSpan.getSofaTracerSpanContext(); if (spanContext != null) { context.setAttachment(RpcConstants.INTERNAL_KEY_TRACE_ID, spanContext.getTraceId()); context.setAttachment(RpcConstants.INTERNAL_KEY_SPAN_ID, spanContext.getSpanId()); } } clientSpan.setTag(RpcSpanTags.SERVICE, request.getTargetServiceUniqueName()); clientSpan.setTag(RpcSpanTags.METHOD, request.getMethodName()); clientSpan.setTag(RpcSpanTags.CURRENT_THREAD_NAME, Thread.currentThread().getName()); clientSpan.setParentSofaTracerSpan(serverSpan); sofaTraceContext.push(clientSpan); }
RpcSofaTracer extends Tracer { @Override public void startRpc(SofaRequest request) { SofaTraceContext sofaTraceContext = SofaTraceContextHolder.getSofaTraceContext(); SofaTracerSpan serverSpan = sofaTraceContext.pop(); SofaTracerSpan clientSpan = (SofaTracerSpan) this.sofaTracer.buildSpan(request.getInterfaceName()) .asChildOf(serverSpan) .withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_CLIENT) .start(); if (RpcInternalContext.isAttachmentEnable()) { RpcInternalContext context = RpcInternalContext.getContext(); clientSpan .setTag(RpcSpanTags.LOCAL_APP, (String) context.getAttachment(RpcConstants.INTERNAL_KEY_APP_NAME)); clientSpan.setTag(RpcSpanTags.PROTOCOL, (String) context.getAttachment(RpcConstants.INTERNAL_KEY_PROTOCOL_NAME)); SofaTracerSpanContext spanContext = clientSpan.getSofaTracerSpanContext(); if (spanContext != null) { context.setAttachment(RpcConstants.INTERNAL_KEY_TRACE_ID, spanContext.getTraceId()); context.setAttachment(RpcConstants.INTERNAL_KEY_SPAN_ID, spanContext.getSpanId()); } } clientSpan.setTag(RpcSpanTags.SERVICE, request.getTargetServiceUniqueName()); clientSpan.setTag(RpcSpanTags.METHOD, request.getMethodName()); clientSpan.setTag(RpcSpanTags.CURRENT_THREAD_NAME, Thread.currentThread().getName()); clientSpan.setParentSofaTracerSpan(serverSpan); sofaTraceContext.push(clientSpan); } }
RpcSofaTracer extends Tracer { @Override public void startRpc(SofaRequest request) { SofaTraceContext sofaTraceContext = SofaTraceContextHolder.getSofaTraceContext(); SofaTracerSpan serverSpan = sofaTraceContext.pop(); SofaTracerSpan clientSpan = (SofaTracerSpan) this.sofaTracer.buildSpan(request.getInterfaceName()) .asChildOf(serverSpan) .withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_CLIENT) .start(); if (RpcInternalContext.isAttachmentEnable()) { RpcInternalContext context = RpcInternalContext.getContext(); clientSpan .setTag(RpcSpanTags.LOCAL_APP, (String) context.getAttachment(RpcConstants.INTERNAL_KEY_APP_NAME)); clientSpan.setTag(RpcSpanTags.PROTOCOL, (String) context.getAttachment(RpcConstants.INTERNAL_KEY_PROTOCOL_NAME)); SofaTracerSpanContext spanContext = clientSpan.getSofaTracerSpanContext(); if (spanContext != null) { context.setAttachment(RpcConstants.INTERNAL_KEY_TRACE_ID, spanContext.getTraceId()); context.setAttachment(RpcConstants.INTERNAL_KEY_SPAN_ID, spanContext.getSpanId()); } } clientSpan.setTag(RpcSpanTags.SERVICE, request.getTargetServiceUniqueName()); clientSpan.setTag(RpcSpanTags.METHOD, request.getMethodName()); clientSpan.setTag(RpcSpanTags.CURRENT_THREAD_NAME, Thread.currentThread().getName()); clientSpan.setParentSofaTracerSpan(serverSpan); sofaTraceContext.push(clientSpan); } RpcSofaTracer(); }
RpcSofaTracer extends Tracer { @Override public void startRpc(SofaRequest request) { SofaTraceContext sofaTraceContext = SofaTraceContextHolder.getSofaTraceContext(); SofaTracerSpan serverSpan = sofaTraceContext.pop(); SofaTracerSpan clientSpan = (SofaTracerSpan) this.sofaTracer.buildSpan(request.getInterfaceName()) .asChildOf(serverSpan) .withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_CLIENT) .start(); if (RpcInternalContext.isAttachmentEnable()) { RpcInternalContext context = RpcInternalContext.getContext(); clientSpan .setTag(RpcSpanTags.LOCAL_APP, (String) context.getAttachment(RpcConstants.INTERNAL_KEY_APP_NAME)); clientSpan.setTag(RpcSpanTags.PROTOCOL, (String) context.getAttachment(RpcConstants.INTERNAL_KEY_PROTOCOL_NAME)); SofaTracerSpanContext spanContext = clientSpan.getSofaTracerSpanContext(); if (spanContext != null) { context.setAttachment(RpcConstants.INTERNAL_KEY_TRACE_ID, spanContext.getTraceId()); context.setAttachment(RpcConstants.INTERNAL_KEY_SPAN_ID, spanContext.getSpanId()); } } clientSpan.setTag(RpcSpanTags.SERVICE, request.getTargetServiceUniqueName()); clientSpan.setTag(RpcSpanTags.METHOD, request.getMethodName()); clientSpan.setTag(RpcSpanTags.CURRENT_THREAD_NAME, Thread.currentThread().getName()); clientSpan.setParentSofaTracerSpan(serverSpan); sofaTraceContext.push(clientSpan); } RpcSofaTracer(); @Override void startRpc(SofaRequest request); @Override void clientBeforeSend(SofaRequest request); @Override void clientReceived(SofaRequest request, SofaResponse response, Throwable exceptionThrow); @Override void serverReceived(SofaRequest request); @Override void serverSend(SofaRequest request, SofaResponse response, Throwable exception); @Override void clientAsyncAfterSend(SofaRequest request); @Override void clientAsyncReceivedPrepare(); @Override void checkState(); @Override void profile(String profileApp, String code, String message); SofaTracer getSofaTracer(); }
RpcSofaTracer extends Tracer { @Override public void startRpc(SofaRequest request) { SofaTraceContext sofaTraceContext = SofaTraceContextHolder.getSofaTraceContext(); SofaTracerSpan serverSpan = sofaTraceContext.pop(); SofaTracerSpan clientSpan = (SofaTracerSpan) this.sofaTracer.buildSpan(request.getInterfaceName()) .asChildOf(serverSpan) .withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_CLIENT) .start(); if (RpcInternalContext.isAttachmentEnable()) { RpcInternalContext context = RpcInternalContext.getContext(); clientSpan .setTag(RpcSpanTags.LOCAL_APP, (String) context.getAttachment(RpcConstants.INTERNAL_KEY_APP_NAME)); clientSpan.setTag(RpcSpanTags.PROTOCOL, (String) context.getAttachment(RpcConstants.INTERNAL_KEY_PROTOCOL_NAME)); SofaTracerSpanContext spanContext = clientSpan.getSofaTracerSpanContext(); if (spanContext != null) { context.setAttachment(RpcConstants.INTERNAL_KEY_TRACE_ID, spanContext.getTraceId()); context.setAttachment(RpcConstants.INTERNAL_KEY_SPAN_ID, spanContext.getSpanId()); } } clientSpan.setTag(RpcSpanTags.SERVICE, request.getTargetServiceUniqueName()); clientSpan.setTag(RpcSpanTags.METHOD, request.getMethodName()); clientSpan.setTag(RpcSpanTags.CURRENT_THREAD_NAME, Thread.currentThread().getName()); clientSpan.setParentSofaTracerSpan(serverSpan); sofaTraceContext.push(clientSpan); } RpcSofaTracer(); @Override void startRpc(SofaRequest request); @Override void clientBeforeSend(SofaRequest request); @Override void clientReceived(SofaRequest request, SofaResponse response, Throwable exceptionThrow); @Override void serverReceived(SofaRequest request); @Override void serverSend(SofaRequest request, SofaResponse response, Throwable exception); @Override void clientAsyncAfterSend(SofaRequest request); @Override void clientAsyncReceivedPrepare(); @Override void checkState(); @Override void profile(String profileApp, String code, String message); SofaTracer getSofaTracer(); static final String RPC_TRACER_TYPE; static final String ERROR_SOURCE; }