Java Code Examples for brave.Span.Kind#CLIENT

The following examples show how to use brave.Span.Kind#CLIENT . 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: BraveSpan.java    From brave-opentracing with Apache License 2.0 6 votes vote down vote up
@Nullable static Kind trySetKind(String key, String value) {
  if (!Tags.SPAN_KIND.getKey().equals(key)) return null;

  Kind kind;
  if (Tags.SPAN_KIND_CLIENT.equals(value)) {
    kind = Kind.CLIENT;
  } else if (Tags.SPAN_KIND_SERVER.equals(value)) {
    kind = Kind.SERVER;
  } else if (Tags.SPAN_KIND_PRODUCER.equals(value)) {
    kind = Kind.PRODUCER;
  } else if (Tags.SPAN_KIND_CONSUMER.equals(value)) {
    kind = Kind.CONSUMER;
  } else {
    return null;
  }
  return kind;
}
 
Example 2
Source File: OpenTracing0_33_BraveSpanTest.java    From brave-opentracing with Apache License 2.0 5 votes vote down vote up
@DataProvider
public static Object[][] dataProviderKind() {
  return new Object[][] {
      {Tags.SPAN_KIND_CLIENT, Kind.CLIENT},
      {Tags.SPAN_KIND_SERVER, Kind.SERVER},
      {Tags.SPAN_KIND_PRODUCER, Kind.PRODUCER},
      {Tags.SPAN_KIND_CONSUMER, Kind.CONSUMER}
  };
}
 
Example 3
Source File: TextMapPropagation.java    From brave-opentracing with Apache License 2.0 4 votes vote down vote up
@Override public Kind spanKind() {
  return Kind.CLIENT;
}
 
Example 4
Source File: TextMapPropagation.java    From brave with Apache License 2.0 4 votes vote down vote up
@Override public Kind spanKind() {
  return Kind.CLIENT;
}
 
Example 5
Source File: RpcClientRequest.java    From brave with Apache License 2.0 4 votes vote down vote up
@Override public Kind spanKind() {
  return Kind.CLIENT;
}
 
Example 6
Source File: RpcClientRequest.java    From brave with Apache License 2.0 4 votes vote down vote up
@Override public final Kind spanKind() {
  return Kind.CLIENT;
}
 
Example 7
Source File: TracingFilter.java    From brave with Apache License 2.0 4 votes vote down vote up
@Override
public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
  if (!isInit) return invoker.invoke(invocation);
  TraceContext invocationContext = currentTraceContext.get();

  RpcContext rpcContext = RpcContext.getContext();
  Kind kind = rpcContext.isProviderSide() ? Kind.SERVER : Kind.CLIENT;
  Span span;
  DubboRequest request;
  if (kind.equals(Kind.CLIENT)) {
    // When A service invoke B service, then B service then invoke C service, the parentId of the
    // C service span is A when read from invocation.getAttachments(). This is because
    // AbstractInvoker adds attachments via RpcContext.getContext(), not the invocation.
    // See org.apache.dubbo.rpc.protocol.AbstractInvoker(line 141) from v2.7.3
    Map<String, String> attachments = RpcContext.getContext().getAttachments();
    DubboClientRequest clientRequest = new DubboClientRequest(invoker, invocation, attachments);
    request = clientRequest;
    span = clientHandler.handleSendWithParent(clientRequest, invocationContext);
  } else {
    DubboServerRequest serverRequest = new DubboServerRequest(invoker, invocation);
    request = serverRequest;
    span = serverHandler.handleReceive(serverRequest);
  }

  boolean isSynchronous = true;
  Scope scope = currentTraceContext.newScope(span.context());
  Result result = null;
  Throwable error = null;
  try {
    result = invoker.invoke(invocation);
    error = result.getException();
    CompletableFuture<Object> future = rpcContext.getCompletableFuture();
    if (future != null) {
      isSynchronous = false;
      // NOTE: We don't currently instrument CompletableFuture, so callbacks will not see the
      // invocation context unless they use an executor instrumented by CurrentTraceContext
      // If we later instrument this, take care to use the correct context depending on RPC kind!
      future.whenComplete(FinishSpan.create(this, request, result, span));
    }
    return result;
  } catch (Throwable e) {
    propagateIfFatal(e);
    error = e;
    throw e;
  } finally {
    if (isSynchronous) FinishSpan.finish(this, request, result, error, span);
    scope.close();
  }
}
 
Example 8
Source File: HttpClientRequest.java    From brave with Apache License 2.0 4 votes vote down vote up
@Override public Kind spanKind() {
  return Kind.CLIENT;
}
 
Example 9
Source File: HttpClientRequest.java    From brave with Apache License 2.0 4 votes vote down vote up
@Override public final Kind spanKind() {
  return Kind.CLIENT;
}