io.opentracing.Tracer.activeSpan()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(5.9k)|赞(0)|评价(0)|浏览(205)

本文整理了Java中io.opentracing.Tracer.activeSpan()方法的一些代码示例,展示了Tracer.activeSpan()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Tracer.activeSpan()方法的具体详情如下:
包路径:io.opentracing.Tracer
类名称:Tracer
方法名:activeSpan

Tracer.activeSpan介绍

暂无

代码示例

代码示例来源:origin: io.opentracing.contrib/opentracing-concurrent

public TracedCallable(Callable<V> delegate, Tracer tracer) {
 this.delegate = delegate;
 this.tracer = tracer;
 this.span = tracer.activeSpan();
}

代码示例来源:origin: io.opentracing.contrib/opentracing-concurrent

public TracedRunnable(Runnable delegate, Tracer tracer) {
 this.delegate = delegate;
 this.tracer = tracer;
 this.span = tracer.activeSpan();
}

代码示例来源:origin: apache/cxf

@Override
public void annotate(String key, String value) {
  final Span current = tracer.activeSpan();
  if (current != null) {
    current.setTag(key, value);
  }
}

代码示例来源:origin: apache/cxf

@Override
public void timeline(String message) {
  final Span current = tracer.activeSpan();
  if (current != null) {
    current.log(message);
  }
}

代码示例来源:origin: io.opentracing.contrib/opentracing-concurrent

@Override
public ScheduledFuture<?> scheduleAtFixedRate(Runnable runnable, long initialDelay, long period, TimeUnit timeUnit) {
  return delegate.scheduleAtFixedRate(tracer.activeSpan() == null ? runnable :
      new TracedRunnable(runnable, tracer), initialDelay, period, timeUnit);
}

代码示例来源:origin: io.opentracing.contrib/opentracing-concurrent

@Override
public Future<?> submit(Runnable runnable) {
 return delegate.submit(tracer.activeSpan() == null ? runnable :
   new TracedRunnable(runnable, tracer));
}

代码示例来源:origin: io.opentracing.contrib/opentracing-concurrent

private <T> Collection<? extends Callable<T>> toTraced(Collection<? extends Callable<T>> delegate) {
  List<Callable<T>> tracedCallables = new ArrayList<Callable<T>>(delegate.size());

  for (Callable<T> callable: delegate) {
   tracedCallables.add(tracer.activeSpan() == null ? callable :
     new TracedCallable<T>(callable, tracer));
  }

  return tracedCallables;
 }
}

代码示例来源:origin: io.opentracing.contrib/opentracing-concurrent

@Override
 public void execute(Runnable runnable) {
  delegate.execute(tracer.activeSpan() == null ? runnable :
   new TracedRunnable(runnable, tracer));
 }
}

代码示例来源:origin: io.opentracing.contrib/opentracing-concurrent

@Override
public <T> Future<T> submit(Runnable runnable, T t) {
 return delegate.submit(tracer.activeSpan() == null ? runnable :
   new TracedRunnable(runnable, tracer), t);
}

代码示例来源:origin: io.opentracing.contrib/opentracing-concurrent

@Override
public <T> Future<T> submit(Callable<T> callable) {
 return delegate.submit(tracer.activeSpan() == null ? callable :
   new TracedCallable<T>(callable, tracer));
}

代码示例来源:origin: teiid/teiid

@Override
  public void execute(Runnable command) {
    super.execute(tracer.activeSpan() == null ? command :
      new TracedRunnable(command, tracer));
  }
};

代码示例来源:origin: org.teiid/teiid-engine

@Override
  public void execute(Runnable command) {
    super.execute(tracer.activeSpan() == null ? command :
      new TracedRunnable(command, tracer));
  }
};

代码示例来源:origin: nl.talsmasoftware.context/opentracing-span-propagation

/**
 * Return the {@link GlobalTracer#activeSpan() active span} as a {@link Context}.
 * <p>
 * Please note: Closing this context will <strong>not</strong> close the corresponding OpenTracing scope
 * as it is not ours to manage.
 *
 * @return The currently active span as a context.
 */
@Override
public Context<Span> getActiveContext() {
  Span activeSpan = GlobalTracer.get().activeSpan();
  return activeSpan == null ? null : new SpanContext(activeSpan, null);
}

代码示例来源:origin: objectiser/opentracing-prometheus-example

@RequestMapping("/buy")
public String buy() throws InterruptedException {
  Thread.sleep(1 + (long)(Math.random()*500));
  Optional.ofNullable(tracer.activeSpan()).ifPresent(as -> as.setBaggageItem("transaction", "buy"));
  try (Scope scope = tracer.buildSpan("SomeWork").startActive(true)) {
    scope.span().setTag("work", "buying");
    ResponseEntity<String> response = restTemplate.getForEntity(accountMgrUrl + "/account", String.class);
    return "BUY + " + response.getBody();
  }
}

代码示例来源:origin: io.opentracing.contrib/opentracing-redis-common

public Span buildSpan(String operationName) {
  if (traceWithActiveSpanOnly && getNullSafeTracer().activeSpan() == null) {
    return NoopSpan.INSTANCE;
  } else {
    return builder(operationName, tracer, spanNameProvider).start();
  }
}

代码示例来源:origin: teiid/teiid

public Scope activateSpan(Span span) {
  Tracer tr = getTracer(); 
  if (tr.activeSpan() == span) {
    //when a workitem adds itself to a queue the span will already be active
    return null;
  }
  return tr.scopeManager().activate(span, false);
}

代码示例来源:origin: opentracing-contrib/java-spring-web

@Override
  public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain chain) throws IOException, ServletException {
    HttpServletRequest httpRequest = (HttpServletRequest) servletRequest;
    HttpServletResponse httpResponse = (HttpServletResponse) servletResponse;
    Span span = GlobalTracer.get().activeSpan();
    chain.doFilter(httpRequest, httpResponse);
    if (span != GlobalTracer.get().activeSpan()) {
      throw new RuntimeException("we should see the same span before and after");
    }
  }
}

代码示例来源:origin: org.teiid/teiid-engine

public Scope activateSpan(Span span) {
  Tracer tr = getTracer(); 
  if (tr.activeSpan() == span) {
    //when a workitem adds itself to a queue the span will already be active
    return null;
  }
  return tr.scopeManager().activate(span, false);
}

代码示例来源:origin: io.opentracing.contrib/opentracing-redis-common

public Span buildSpan(String operationName, Object[] keys) {
  if (traceWithActiveSpanOnly && getNullSafeTracer().activeSpan() == null) {
    return NoopSpan.INSTANCE;
  } else {
    return builder(operationName, tracer, spanNameProvider).withTag("keys",
        Arrays.toString(limitKeys(keys))).start();
  }
}

代码示例来源:origin: io.opentracing.contrib/opentracing-redis-common

public Span buildSpan(String operationName, Object key) {
  if (traceWithActiveSpanOnly && getNullSafeTracer().activeSpan() == null) {
    return NoopSpan.INSTANCE;
  } else {
    return builder(operationName, tracer, spanNameProvider).withTag("key", nullable(key)).start();
  }
}

相关文章