本文整理汇总了Java中io.opentracing.Scope.span方法的典型用法代码示例。如果您正苦于以下问题:Java Scope.span方法的具体用法?Java Scope.span怎么用?Java Scope.span使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.opentracing.Scope
的用法示例。
在下文中一共展示了Scope.span方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onAfterAnyExecute
import io.opentracing.Scope; //导入方法依赖的package包/类
@Override
public void onAfterAnyExecute(StatementInformation statementInformation, long timeElapsedNanos, SQLException e) {
final Scope activeScope = tracingPlugin.getTracer().scopeManager().active();
if (activeScope != null) {
final Span span = activeScope.span();
if (statementInformation.getConnectionInformation().getDataSource() instanceof DataSource && jdbcPlugin.isCollectSql()) {
MetaData metaData = dataSourceUrlMap.get(statementInformation.getConnectionInformation().getDataSource());
Tags.PEER_SERVICE.set(span, metaData.serviceName);
span.setTag("db.type", metaData.productName);
span.setTag("db.user", metaData.userName);
if (StringUtils.isNotEmpty(statementInformation.getSql())) {
String sql = getSql(statementInformation.getSql(), statementInformation.getSqlWithValues());
Profiler.addIOCall(sql, timeElapsedNanos);
span.setTag(AbstractExternalRequest.EXTERNAL_REQUEST_METHOD, getMethod(sql));
span.setTag(DB_STATEMENT, sql);
}
}
tracingPlugin.getRequestMonitor().monitorStop();
}
}
示例2: onSubscribe
import io.opentracing.Scope; //导入方法依赖的package包/类
@Override
public void onSubscribe(Disposable d) {
Scope scope = tracer.buildSpan(operationName)
.withTag(Tags.COMPONENT.getKey(), COMPONENT_NAME).startActive(false);
SpanHolder.set(scope);
span = scope.span();
}
示例3: getSpan
import io.opentracing.Scope; //导入方法依赖的package包/类
private Span getSpan(Tracer tracer) {
if (SpanHolder.get() != null) {
Scope scope = SpanHolder.get();
SpanHolder.clear();
return scope.span();
}
return tracer.activeSpan();
}
示例4: produceSpan
import io.opentracing.Scope; //导入方法依赖的package包/类
@Produces
public Span produceSpan(InjectionPoint ip) {
Scope scope = tracer.scopeManager().active();
if (null == scope) {
String spanName = ip.getMember().getName();
return tracer.buildSpan(spanName).startActive().span();
}
return scope.span();
}
示例5: activeSpan
import io.opentracing.Scope; //导入方法依赖的package包/类
@Override
public Span activeSpan() {
Scope active = scopeManager.active();
if (active == null) {
return null;
} else {
return active.span();
}
}
示例6: setRequestNameByHandler
import io.opentracing.Scope; //导入方法依赖的package包/类
public static void setRequestNameByHandler(Object handler) {
final Scope activeScope = GlobalTracer.get().scopeManager().active();
if (activeScope != null) {
final BusinessTransactionNamingStrategy namingStrategy = Stagemonitor.getPlugin(TracingPlugin.class)
.getBusinessTransactionNamingStrategy();
final String requestNameFromHandler = getRequestNameFromHandler(handler, namingStrategy);
if (requestNameFromHandler != null) {
final Span span = activeScope.span();
span.setTag(MetricsSpanEventListener.ENABLE_TRACKING_METRICS_TAG, true);
span.setOperationName(requestNameFromHandler);
}
}
}
示例7: createScope
import io.opentracing.Scope; //导入方法依赖的package包/类
@Override
public Scope createScope() {
boolean sample = true;
if (servletPlugin.isHonorDoNotTrackHeader() && "1".equals(httpServletRequest.getHeader("dnt"))) {
sample = false;
}
final Tracer tracer = tracingPlugin.getTracer();
io.opentracing.SpanContext spanCtx = tracer.extract(Format.Builtin.HTTP_HEADERS, new HttpServletRequestTextMapExtractAdapter(httpServletRequest));
Tracer.SpanBuilder spanBuilder = tracer.buildSpan(getRequestName())
.asChildOf(spanCtx)
.withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_SERVER);
if (widgetAndStagemonitorEndpointsAllowed) {
// use null as value so that the tag is not really set
spanBuilder = spanBuilder.withTag(WIDGET_ALLOWED_ATTRIBUTE, (String) null);
}
if (!sample) {
spanBuilder = spanBuilder.withTag(Tags.SAMPLING_PRIORITY.getKey(), 0);
}
spanBuilder.withTag(SpanUtils.OPERATION_TYPE, "http");
final Scope scope = spanBuilder.startActive();
final Span span = scope.span();
Tags.HTTP_URL.set(span, httpServletRequest.getRequestURI());
Tags.PEER_PORT.set(span, httpServletRequest.getRemotePort());
span.setTag("method", httpServletRequest.getMethod());
span.setTag("http.referring_site", getReferringSite());
if (servletPlugin.isCollectHttpHeaders()) {
SpanUtils.setHttpHeaders(span, getHeaders(httpServletRequest));
}
SpanContextInformation info = SpanContextInformation.forSpan(span);
info.addRequestAttribute(CONNECTION_ID_ATTRIBUTE, connectionId);
info.addRequestAttribute(MONITORED_HTTP_REQUEST_ATTRIBUTE, this);
if (tracingPlugin.isSampled(span) && servletPlugin.isParseUserAgent() && StringUtils.isNotEmpty(userAgentHeader)) {
parseUserAgentAsync(span, info);
}
return scope;
}
示例8: monitorStop
import io.opentracing.Scope; //导入方法依赖的package包/类
public void monitorStop() {
final Scope activeScope = tracingPlugin.getTracer().scopeManager().active();
if (activeScope != null) {
final Span currentSpan = activeScope.span();
final SpanContextInformation info = SpanContextInformation.get(currentSpan);
if (info != null) {
long overhead2 = System.nanoTime();
trackOverhead(info.getOverhead1(), overhead2);
}
activeScope.close();
}
}
示例9: getCurrentSpan
import io.opentracing.Scope; //导入方法依赖的package包/类
/**
* @return the {@link Span} of the current request or a noop {@link Span} (never <code>null</code>)
*/
public static Span getCurrentSpan() {
final Scope activeScope = GlobalTracer.get().scopeManager().active();
if (activeScope != null) {
return activeScope.span();
} else {
return NoopTracerFactory.create().buildSpan(null).startManual();
}
}
示例10: createScope
import io.opentracing.Scope; //导入方法依赖的package包/类
@Override
public Scope createScope() {
final Scope scope = super.createScope();
final Span span = scope.span();
Tags.HTTP_URL.set(span, url);
Tags.PEER_HOSTNAME.set(span, host);
Tags.PEER_PORT.set(span, port);
span.setTag(AbstractExternalRequest.EXTERNAL_REQUEST_METHOD, method);
return scope;
}
示例11: call
import io.opentracing.Scope; //导入方法依赖的package包/类
@Override
public String call() {
Scope activeScope = GlobalTracer.get().scopeManager().active();
Span activeSpan = activeScope == null ? null : activeScope.span();
return activeSpan == null ? "no-active-span" : activeSpan.getBaggageItem("baggage-item");
}
示例12: activeSpan
import io.opentracing.Scope; //导入方法依赖的package包/类
@Override
public Span activeSpan() {
Scope scope = this.scopeManager.active();
return scope == null ? null : scope.span();
}