Java Code Examples for org.apache.dubbo.rpc.RpcContext#isConsumerSide()
The following examples show how to use
org.apache.dubbo.rpc.RpcContext#isConsumerSide() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ApacheMonitorFilterAdvice.java From apm-agent-java with Apache License 2.0 | 6 votes |
@Advice.OnMethodEnter(suppress = Throwable.class) public static void onEnterFilterInvoke(@Advice.Argument(1) Invocation invocation, @Advice.Local("span") Span span, @Advice.Local("transaction") Transaction transaction) { RpcContext context = RpcContext.getContext(); ApacheDubboAttachmentHelper helper = attachmentHelperClassManager.getForClassLoaderOfClass(Invocation.class); if (helper == null || tracer == null) { return; } AbstractSpan<?> active = tracer.getActive(); // for consumer side, just create span, more information will be collected in provider side if (context.isConsumerSide() && active != null) { span = DubboTraceHelper.createConsumerSpan(tracer, invocation.getInvoker().getInterface(), invocation.getMethodName(), context.getRemoteAddress()); if (span != null) { span.propagateTraceContext(invocation, helper); } } else if (active == null) { // for provider side transaction = tracer.startChildTransaction(invocation, helper, Invocation.class.getClassLoader()); if (transaction != null) { transaction.activate(); DubboTraceHelper.fillTransaction(transaction, invocation.getInvoker().getInterface(), invocation.getMethodName()); } } }
Example 2
Source File: ApacheMonitorFilterAdvice.java From apm-agent-java with Apache License 2.0 | 6 votes |
@Advice.OnMethodExit(suppress = Throwable.class, onThrowable = Throwable.class) public static void onExitFilterInvoke(@Advice.Argument(1) Invocation invocation, @Advice.Return Result result, @Nullable @Advice.Local("span") final Span span, @Advice.Thrown Throwable t, @Nullable @Advice.Local("transaction") Transaction transaction) { RpcContext context = RpcContext.getContext(); AbstractSpan<?> actualSpan = context.isConsumerSide() ? span : transaction; if (actualSpan == null) { return; } actualSpan.deactivate(); if (result instanceof AsyncRpcResult) { AsyncCallbackCreator callbackCreator = asyncCallbackCreatorClassManager.getForClassLoaderOfClass(Result.class); if (callbackCreator == null) { actualSpan.end(); return; } context.set(DubboTraceHelper.SPAN_KEY, actualSpan); result.whenCompleteWithContext(callbackCreator.create(actualSpan)); } else { actualSpan.end(); } }
Example 3
Source File: DubboSofaTracerFilter.java From sofa-tracer with Apache License 2.0 | 4 votes |
private String spanKind(RpcContext rpcContext) { return rpcContext.isConsumerSide() ? Tags.SPAN_KIND_CLIENT : Tags.SPAN_KIND_SERVER; }