当前位置: 首页>>代码示例>>Java>>正文


Java Scope.span方法代码示例

本文整理汇总了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();
	}
}
 
开发者ID:stagemonitor,项目名称:stagemonitor,代码行数:23,代码来源:StagemonitorJdbcEventListener.java

示例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();
}
 
开发者ID:opentracing-contrib,项目名称:java-rxjava,代码行数:8,代码来源:AbstractTracingObserver.java

示例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();
}
 
开发者ID:opentracing-contrib,项目名称:java-rxjava,代码行数:9,代码来源:TracingRunnable.java

示例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();
}
 
开发者ID:opentracing-contrib,项目名称:java-cdi,代码行数:11,代码来源:SpanContextProducer.java

示例5: activeSpan

import io.opentracing.Scope; //导入方法依赖的package包/类
@Override
public Span activeSpan() {
  Scope active = scopeManager.active();
  if (active == null) {
    return null;
  } else {
    return active.span();
  }
}
 
开发者ID:instana,项目名称:instana-java-opentracing,代码行数:10,代码来源:InstanaTracer.java

示例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);
		}
	}
}
 
开发者ID:stagemonitor,项目名称:stagemonitor,代码行数:14,代码来源:SpringMvcRequestNameDeterminerTransformer.java

示例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;
}
 
开发者ID:stagemonitor,项目名称:stagemonitor,代码行数:39,代码来源:MonitoredHttpRequest.java

示例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();
	}
}
 
开发者ID:stagemonitor,项目名称:stagemonitor,代码行数:13,代码来源:RequestMonitor.java

示例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();
	}
}
 
开发者ID:stagemonitor,项目名称:stagemonitor,代码行数:12,代码来源:TracingPlugin.java

示例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;
}
 
开发者ID:stagemonitor,项目名称:stagemonitor,代码行数:11,代码来源:ExternalHttpRequest.java

示例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");
}
 
开发者ID:talsma-ict,项目名称:context-propagation,代码行数:7,代码来源:OpentracingSpanManagerTest.java

示例12: activeSpan

import io.opentracing.Scope; //导入方法依赖的package包/类
@Override
public Span activeSpan() {
    Scope scope = this.scopeManager.active();
    return scope == null ? null : scope.span();
}
 
开发者ID:opentracing,项目名称:opentracing-java,代码行数:6,代码来源:MockTracer.java


注:本文中的io.opentracing.Scope.span方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。