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


Java Span.isRemote方法代码示例

本文整理汇总了Java中org.springframework.cloud.sleuth.Span.isRemote方法的典型用法代码示例。如果您正苦于以下问题:Java Span.isRemote方法的具体用法?Java Span.isRemote怎么用?Java Span.isRemote使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.cloud.sleuth.Span的用法示例。


在下文中一共展示了Span.isRemote方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: writeStartEndTime

import org.springframework.cloud.sleuth.Span; //导入方法依赖的package包/类
private void writeStartEndTime(Span span, TraceSpan.Builder builder) {
	if (!span.isRemote()) {
		Log clientSend = findLog(span, Span.CLIENT_SEND);
		Log clientReceive = findLog(span, Span.CLIENT_RECV);
		if (clientSend != null) {
			builder.setStartTime(createTimestamp(clientSend.getTimestamp()));
		}
		else {
			builder.setStartTime(createTimestamp(span.getBegin()));
		}
		if (!span.isRunning()) {
			if (clientReceive != null) {
				builder.setEndTime(createTimestamp(clientReceive.getTimestamp()));
			}
			else {
				builder.setEndTime(createTimestamp(span.getEnd()));
			}
		}
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-gcp,代码行数:21,代码来源:StackdriverTraceSpanListener.java

示例2: rewriteIds

import org.springframework.cloud.sleuth.Span; //导入方法依赖的package包/类
private void rewriteIds(Span span, TraceSpan.SpanKind kind, TraceSpan.Builder builder) {
	// Find the parent ID. Use 0 if no parent found.
	long parentId = 0;
	if (span.getParents().size() > 0) {
		if (span.getParents().size() > 1) {
			LOGGER.error("Stackdriver Trace doesn't support spans with multiple parents. Omitting "
					+ "other parents for " + span);
		}
		parentId = span.getParents().get(0);
	}

	// Every span will need a different Span ID.
	// If it's a RPC_CLIENT span, there is likely to be a RPC_SERVER span. Both spans would've
	// had the same Span ID and that won't work. Thus, we need to change one of the Span IDs.
	// If it's a RPC_CLIENT, we'll rewrite the Span ID. Later, we'll need to rewrite the
	// corresponding RPC_SERVER span's parent ID to match this one.
	if (kind == TraceSpan.SpanKind.RPC_CLIENT) {
		builder.setSpanId(rewriteId(span.getSpanId()));
	}
	else {
		builder.setSpanId(span.getSpanId());
	}

	// Change the parentSpanId of RPC_SERVER spans to use the rewritten spanId of the
	// RPC_CLIENT spans.
	if (kind == TraceSpan.SpanKind.RPC_SERVER) {
		if (!span.isRemote()) {
			// Owns the Span.
			// This means the parent RPC_CLIENT span was a separate span with id=span.parentId.
			// When that span was converted, it would have had id=rewriteId(span.parentId)
			builder.setParentSpanId(rewriteId(parentId));
		}
		else {
			// This is a multi-host span.
			// This means the parent client-side span has the same id as this span. When that fragment
			// of the span was converted, it would have had id rewriteId(span.spanId)
			builder.setParentSpanId(rewriteId(span.getSpanId()));
		}
	}
	else {
		builder.setParentSpanId(parentId);
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-gcp,代码行数:44,代码来源:StackdriverTraceSpanListener.java


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