本文整理汇总了Java中com.github.kristofa.brave.SpanId类的典型用法代码示例。如果您正苦于以下问题:Java SpanId类的具体用法?Java SpanId怎么用?Java SpanId使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SpanId类属于com.github.kristofa.brave包,在下文中一共展示了SpanId类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getTraceData
import com.github.kristofa.brave.SpanId; //导入依赖的package包/类
@Override
public TraceData getTraceData() {
final String sampled = request.getAttachment(RpcAttachment.Sampled.getName());
if (sampled != null) {
if (sampled.equals("0") || sampled.toLowerCase().equals("false")) {
reportTraceIdIfSampled(reporter, TraceId.NOT_TRACE);
return TraceData.builder().sample(false).build();
} else {
final String parentSpanId = request.getAttachment(RpcAttachment.ParentSpanId.getName());
final String traceId = request.getAttachment(RpcAttachment.TraceId.getName());
final String spanId = request.getAttachment(RpcAttachment.SpanId.getName());
if (traceId != null && spanId != null) {
reportTraceIdIfSampled(reporter, new CertainTraceId(traceId));
SpanId span = getSpanId(traceId, spanId, parentSpanId);
return TraceData.builder().sample(true).spanId(span).build();
}
}
}
reportTraceIdIfSampled(reporter, TraceId.NOT_TRACE);
return TraceData.builder().build();
}
开发者ID:YanXs,项目名称:nighthawk,代码行数:23,代码来源:BraveDubboServerRequestAdapter.java
示例2: beginTrace
import com.github.kristofa.brave.SpanId; //导入依赖的package包/类
protected void beginTrace(Beginning beginning) {
ClientTracer clientTracer = getClientTracer();
if (clientTracer != null) {
try {
SpanId spanId = clientTracer.startNewSpan(beginning.spanName);
if (spanId != null) {
joinTracingLoop();
submitBinaryAnnotation(clientTracer, beginning.annotations);
setClientSent(clientTracer, beginning.address, beginning.port, beginning.spanName);
}
} catch (Exception e) {
if (inTracingLoop()) {
clientTracer.setClientSent();
}
}
}
}
开发者ID:YanXs,项目名称:nighthawk,代码行数:18,代码来源:ClientTracerSupport.java
示例3: getTraceData
import com.github.kristofa.brave.SpanId; //导入依赖的package包/类
@Override
public TraceData getTraceData() {
String sampled = tracingHeader.getSampled();
if (sampled == null || sampled.equals("0")) {
return TraceData.builder().sample(false).build();
} else {
final String parentSpanId = tracingHeader.getParentSpanId();
final String traceId = tracingHeader.getTraceId();
final String spanId = tracingHeader.getSpanId();
if (traceId != null && spanId != null) {
SpanId span = getSpanId(traceId, spanId, parentSpanId);
return TraceData.builder().sample(true).spanId(span).build();
}
}
return TraceData.builder().build();
}
开发者ID:YanXs,项目名称:nighthawk,代码行数:18,代码来源:KafkaServerRequestAdapter.java
示例4: getTraceData
import com.github.kristofa.brave.SpanId; //导入依赖的package包/类
@Override
public TraceData getTraceData() {
final String sampled = rpcContext.getAttachment(BraveHttpHeaders.Sampled.getName());
if (sampled != null) {
if (sampled.equals("0") || sampled.toLowerCase().equals("false")) {
return TraceData.builder().sample(false).build();
} else {
// final String parentSpanId = rpcContext.getAttachment(BraveHttpHeaders.ParentSpanId.getName());
final String traceId = rpcContext.getAttachment(BraveHttpHeaders.TraceId.getName());
final String spanId = rpcContext.getAttachment(BraveHttpHeaders.SpanId.getName());
if (traceId != null && spanId != null) {
SpanId span = getSpanId(traceId, IdConversion.convertToString(IdConversion.convertToLong(spanId) + 1L), spanId);
return TraceData.builder().sample(true).spanId(span).build();
}
}
}
return TraceData.builder().build();
}
开发者ID:xiaomin0322,项目名称:dubbo_plus,代码行数:21,代码来源:DubboProviderRequestAdapter.java
示例5: addSpanIdToRequest
import com.github.kristofa.brave.SpanId; //导入依赖的package包/类
@Override
public void addSpanIdToRequest(SpanId spanId) {
if (spanId == null) {
rpcContext.setAttachment(BraveHttpHeaders.Sampled.getName(), "0");
} else {
rpcContext.setAttachment(BraveHttpHeaders.Sampled.getName(), "1");
rpcContext.setAttachment(BraveHttpHeaders.TraceId.getName(), IdConversion.convertToString(spanId.getTraceId()));
rpcContext.setAttachment(BraveHttpHeaders.SpanId.getName(), IdConversion.convertToString(spanId.getSpanId()));
// if (spanId.getParentSpanId() != null) {
// rpcContext.setAttachment(BraveHttpHeaders.ParentSpanId.getName(), IdConversion.convertToString(spanId.getParentSpanId()));
// } else {
// rpcContext.setAttachment(BraveHttpHeaders.ParentSpanId.getName(), IdConversion.convertToString(0L));
// }
}
}
开发者ID:xiaomin0322,项目名称:dubbo_plus,代码行数:19,代码来源:DubboConsumerRequestAdapter.java
示例6: onCalled
import com.github.kristofa.brave.SpanId; //导入依赖的package包/类
private void onCalled(final DeliveryContext context, final Message msg) {
final String action = msg.headers().get(Headers.Action.getName());
final SpanId span = localTracer.startNewSpan(msg.address(), msg.address());
LoggingDC.put(span);
if (logger.isDebugEnabled()) {
logger.debug("Publish.Receive ({}): address={}, reply={}, headers={}", action, msg.address(), msg.replyAddress(), msg.headers());
}
try {
context.next();
} finally {
localTracer.finishSpan();
LoggingDC.removeAll();
}
}
开发者ID:emmanuelidi,项目名称:vertx-zipkin,代码行数:19,代码来源:ZipkinEventBusServerInterceptor.java
示例7: getTraceData
import com.github.kristofa.brave.SpanId; //导入依赖的package包/类
@Override
public TraceData getTraceData() {
final String sampled = msg.headers().get(BraveHttpHeaders.Sampled.getName());
if (sampled != null) {
if ("0".equals(sampled) || "false".equals(sampled.toLowerCase())) {
return TraceData.builder().sample(false).build();
} else {
final String parentSpanId = msg.headers().get(BraveHttpHeaders.ParentSpanId.getName());
final String traceId = msg.headers().get(BraveHttpHeaders.TraceId.getName());
final String spanId = msg.headers().get(BraveHttpHeaders.SpanId.getName());
if (traceId != null && spanId != null) {
final SpanId span = SpanId.builder()
.traceId(IdConversion.convertToLong(traceId))
.spanId(IdConversion.convertToLong(spanId))
.parentId(parentSpanId == null ? null : IdConversion.convertToLong(parentSpanId))
.build();
return TraceData.builder().sample(true).spanId(span).build();
}
}
}
return TraceData.builder().build();
}
开发者ID:emmanuelidi,项目名称:vertx-zipkin,代码行数:23,代码来源:ZipkinEventBusServerRequestAdapter.java
示例8: getTraceData
import com.github.kristofa.brave.SpanId; //导入依赖的package包/类
@Override
public TraceData getTraceData() {
String sampled = exchange.getIn().getHeader(ZipkinConstants.SAMPLED, "0", String.class);
if (sampled.equals("0") || sampled.toLowerCase().equals("false")) {
return TraceData.builder().sample(false).build();
} else {
String traceId = exchange.getIn().getHeader(ZipkinConstants.TRACE_ID, String.class);
String spanId = exchange.getIn().getHeader(ZipkinConstants.SPAN_ID, String.class);
String parentSpanId = exchange.getIn().getHeader(ZipkinConstants.PARENT_SPAN_ID, String.class);
if (traceId != null && spanId != null) {
SpanId span = createSpanId(traceId, spanId, parentSpanId);
return TraceData.builder().sample(true).spanId(span).build();
}
}
return TraceData.builder().build();
}
开发者ID:HydAu,项目名称:Camel,代码行数:17,代码来源:ZipkinServerRequestAdapter.java
示例9: addSpanIdToRequest
import com.github.kristofa.brave.SpanId; //导入依赖的package包/类
@Override
public void addSpanIdToRequest(SpanId spanId) {
if (spanId == null) {
request.addAttachment(RpcAttachment.Sampled.getName(), "0");
} else {
request.addAttachment(RpcAttachment.Sampled.getName(), "1");
request.addAttachment(RpcAttachment.TraceId.getName(), IdConversion.convertToString(spanId.traceId));
request.addAttachment(RpcAttachment.SpanId.getName(), IdConversion.convertToString(spanId.spanId));
if (spanId.nullableParentId() != null) {
request.addAttachment(RpcAttachment.ParentSpanId.getName(), IdConversion.convertToString(spanId.parentId));
}
request.addAttachment(RpcAttachment.SpanName.getName(), getSpanName());
}
}
开发者ID:YanXs,项目名称:nighthawk,代码行数:15,代码来源:BraveDubboClientRequestAdapter.java
示例10: startTracing
import com.github.kristofa.brave.SpanId; //导入依赖的package包/类
protected TracingHeader startTracing(String topic) {
SpanId spanId = brave.clientTracer().startNewSpan("kafka - " + topic);
TracingHeader tp = null;
if (spanId != null) {
tp = new TracingHeader();
tp.setTraceId(IdConversion.convertToString(spanId.traceId));
tp.setSpanId(IdConversion.convertToString(spanId.spanId));
tp.setParentSpanId(IdConversion.convertToString(spanId.parentId));
tp.setSampled("1");
}
return tp;
}
开发者ID:YanXs,项目名称:nighthawk,代码行数:13,代码来源:AbstractTracingSerializer.java
示例11: handleInvocation
import com.github.kristofa.brave.SpanId; //导入依赖的package包/类
@Override protected Object handleInvocation(Object proxy, Method method, Object[] args)
throws Throwable {
// Only join traces, don't start them. This prevents LocalCollector's thread from amplifying.
if (brave.serverSpanThreadBinder().getCurrentServerSpan() != null &&
brave.serverSpanThreadBinder().getCurrentServerSpan().getSpan() != null
// Only trace named statements for now, since that's what we use
&& method.getName().equals("executeAsync") && args[0] instanceof NamedBoundStatement) {
NamedBoundStatement statement = (NamedBoundStatement) args[0];
SpanId spanId = brave.clientTracer().startNewSpan(statement.name);
// o.a.c.tracing.Tracing.newSession must use the same format for the key zipkin
if (version.compareTo(ProtocolVersion.V4) >= 0) {
statement.enableTracing();
statement.setOutgoingPayload(singletonMap("zipkin", ByteBuffer.wrap(spanId.bytes())));
}
brave.clientTracer().setClientSent(); // start the span and store it
brave.clientTracer()
.submitBinaryAnnotation("cql.query", statement.preparedStatement().getQueryString());
cache.put(statement, brave.clientSpanThreadBinder().getCurrentClientSpan());
// let go of the client span as it is only used for the RPC (will have no local children)
brave.clientSpanThreadBinder().setCurrentSpan(null);
return new BraveResultSetFuture(target.executeAsync(statement), brave);
}
try {
return method.invoke(target, args);
} catch (InvocationTargetException e) {
if (e.getCause() instanceof RuntimeException) throw e.getCause();
throw e;
}
}
开发者ID:liaominghua,项目名称:zipkin,代码行数:33,代码来源:TracedSession.java
示例12: handleInvocation
import com.github.kristofa.brave.SpanId; //导入依赖的package包/类
@Override protected Object handleInvocation(Object proxy, Method method, Object[] args)
throws Throwable {
// Only join traces, don't start them. This prevents LocalCollector's thread from amplifying.
if (brave.serverSpanThreadBinder().getCurrentServerSpan() != null &&
brave.serverSpanThreadBinder().getCurrentServerSpan().getSpan() != null
&& method.getName().equals("executeAsync") && args[0] instanceof BoundStatement) {
BoundStatement statement = (BoundStatement) args[0];
// via an internal class z.s.cassandra3.NamedBoundStatement, toString() is a nice name
SpanId spanId = brave.clientTracer().startNewSpan(statement.toString());
// o.a.c.tracing.Tracing.newSession must use the same format for the key zipkin
if (version.compareTo(ProtocolVersion.V4) >= 0) {
statement.enableTracing();
statement.setOutgoingPayload(singletonMap("zipkin", ByteBuffer.wrap(spanId.bytes())));
}
brave.clientTracer().setClientSent(); // start the span and store it
brave.clientTracer()
.submitBinaryAnnotation("cql.query", statement.preparedStatement().getQueryString());
cache.put(statement, brave.clientSpanThreadBinder().getCurrentClientSpan());
// let go of the client span as it is only used for the RPC (will have no local children)
brave.clientSpanThreadBinder().setCurrentSpan(null);
return new BraveResultSetFuture(target.executeAsync(statement), brave);
}
try {
return method.invoke(target, args);
} catch (InvocationTargetException e) {
if (e.getCause() instanceof RuntimeException) throw e.getCause();
throw e;
}
}
开发者ID:liaominghua,项目名称:zipkin,代码行数:33,代码来源:TracedSession.java
示例13: put
import com.github.kristofa.brave.SpanId; //导入依赖的package包/类
public static void put(final SpanId id) {
if (id != null) {
put(TRACE_ID, toHexString(id.traceId));
} else {
removeAll();
}
}
开发者ID:emmanuelidi,项目名称:vertx-zipkin,代码行数:8,代码来源:LoggingDC.java
示例14: addSpanIdToRequest
import com.github.kristofa.brave.SpanId; //导入依赖的package包/类
@Override
public void addSpanIdToRequest(@Nullable SpanId spanId) {
if (spanId == null) {
msg.headers().add(BraveHttpHeaders.Sampled.getName(), "0");
} else {
msg.headers().add(BraveHttpHeaders.Sampled.getName(), "1");
msg.headers().add(BraveHttpHeaders.TraceId.getName(), IdConversion.convertToString(spanId.traceId));
msg.headers().add(BraveHttpHeaders.SpanId.getName(), IdConversion.convertToString(spanId.spanId));
if (spanId.nullableParentId() != null) {
msg.headers().add(BraveHttpHeaders.ParentSpanId.getName(), IdConversion.convertToString(spanId.parentId));
}
}
}
开发者ID:emmanuelidi,项目名称:vertx-zipkin,代码行数:14,代码来源:ZipkinEventBusClientRequestAdapter.java
示例15: addSpanIdToRequest
import com.github.kristofa.brave.SpanId; //导入依赖的package包/类
@Override
public void addSpanIdToRequest(@Nullable SpanId spanId) {
if (spanId == null) {
exchange.getIn().setHeader(ZipkinConstants.SAMPLED, "0");
} else {
exchange.getIn().setHeader(ZipkinConstants.SAMPLED, "1");
exchange.getIn().setHeader(ZipkinConstants.TRACE_ID, IdConversion.convertToString(spanId.getTraceId()));
exchange.getIn().setHeader(ZipkinConstants.SPAN_ID, IdConversion.convertToString(spanId.getSpanId()));
if (spanId.getParentSpanId() != null) {
exchange.getIn().setHeader(ZipkinConstants.PARENT_SPAN_ID, IdConversion.convertToString(spanId.getParentSpanId()));
}
}
}
开发者ID:HydAu,项目名称:Camel,代码行数:14,代码来源:ZipkinClientRequestAdapter.java
示例16: getSpanId
import com.github.kristofa.brave.SpanId; //导入依赖的package包/类
private SpanId getSpanId(String traceId, String spanId, String parentSpanId) {
return SpanId.builder()
.traceId(convertToLong(traceId))
.spanId(convertToLong(spanId))
.parentId(parentSpanId == null ? null : convertToLong(parentSpanId)).build();
}
开发者ID:YanXs,项目名称:nighthawk,代码行数:7,代码来源:BraveDubboServerRequestAdapter.java
示例17: getSpanId
import com.github.kristofa.brave.SpanId; //导入依赖的package包/类
private SpanId getSpanId(String traceId, String spanId, String parentSpanId) {
if (parentSpanId != null) {
return SpanId.create(IdConversion.convertToLong(traceId), IdConversion.convertToLong(spanId), IdConversion.convertToLong(parentSpanId));
}
return SpanId.create(IdConversion.convertToLong(traceId), IdConversion.convertToLong(spanId), null);
}
开发者ID:xiaomin0322,项目名称:dubbo_plus,代码行数:7,代码来源:DubboProviderRequestAdapter.java
示例18: createSpanId
import com.github.kristofa.brave.SpanId; //导入依赖的package包/类
public static SpanId createSpanId(String traceId, String spanId, String parentSpanId) {
if (parentSpanId != null) {
return SpanId.create(IdConversion.convertToLong(traceId), IdConversion.convertToLong(spanId), IdConversion.convertToLong(parentSpanId));
}
return SpanId.create(IdConversion.convertToLong(traceId), IdConversion.convertToLong(spanId), null);
}
开发者ID:HydAu,项目名称:Camel,代码行数:7,代码来源:ZipkinHelper.java
示例19: executeWithClientSpan
import com.github.kristofa.brave.SpanId; //导入依赖的package包/类
private ResultSet executeWithClientSpan(BoundStatement boundStatement) {
ClientTracer clientTracer = brave.clientTracer();
SpanId spanId = clientTracer.startNewSpan("query");
clientTracer.submitBinaryAnnotation("sql.query", boundStatement.preparedStatement().getQueryString());
ByteBuffer traceHeaders = ByteBuffer.wrap(spanId.bytes());
boundStatement.setOutgoingPayload(Collections.singletonMap("zipkin", traceHeaders));
clientTracer.setClientSent();
ResultSet resultSet = session.execute(boundStatement.enableTracing());
clientTracer.setClientReceived();
return resultSet;
}
开发者ID:hawkular,项目名称:hawkular-apm,代码行数:17,代码来源:UserDAO.java
注:本文中的com.github.kristofa.brave.SpanId类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论