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


Java Endpoint类代码示例

本文整理汇总了Java中com.twitter.zipkin.gen.Endpoint的典型用法代码示例。如果您正苦于以下问题:Java Endpoint类的具体用法?Java Endpoint怎么用?Java Endpoint使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: update

import com.twitter.zipkin.gen.Endpoint; //导入依赖的package包/类
@Override public void update(Host host, Statement statement, Exception e, long nanos) {
  if (!(statement instanceof NamedBoundStatement)) return;
  Span span = cache.remove(statement);
  if (span == null) {
    if (statement.isTracing()) {
      LOG.warn("{} not in the cache eventhough tracing is on", statement);
    }
    return;
  }
  span.setDuration(nanos / 1000); // TODO: allow client tracer to end with duration
  Endpoint local = span.getAnnotations().get(0).host; // TODO: expose in brave
  long endTs = span.getTimestamp() + span.getDuration();
  if (e != null) {
    span.addToBinary_annotations(BinaryAnnotation.create("cql.error", e.getMessage(), local));
  } else {
    span.addToAnnotations(Annotation.create(endTs, "cr", local));
  }
  int ipv4 = ByteBuffer.wrap(host.getAddress().getAddress()).getInt();
  Endpoint endpoint = Endpoint.create("cassandra", ipv4, host.getSocketAddress().getPort());
  span.addToBinary_annotations(BinaryAnnotation.address("sa", endpoint));
  collector.collect(span);
}
 
开发者ID:liaominghua,项目名称:zipkin,代码行数:23,代码来源:TracedSession.java

示例2: update

import com.twitter.zipkin.gen.Endpoint; //导入依赖的package包/类
@Override public void update(Host host, Statement statement, Exception e, long nanos) {
  if (!(statement instanceof BoundStatement)) return;
  Span span = cache.remove(statement);
  if (span == null) {
    if (statement.isTracing()) {
      LOG.warn("{} not in the cache eventhough tracing is on", statement);
    }
    return;
  }
  span.setDuration(nanos / 1000); // TODO: allow client tracer to end with duration
  Endpoint local = span.getAnnotations().get(0).host; // TODO: expose in brave
  long endTs = span.getTimestamp() + span.getDuration();
  span.addToAnnotations(Annotation.create(endTs, "cr", local));
  if (e != null) {
    span.addToBinary_annotations(BinaryAnnotation.create(Constants.ERROR, e.getMessage(), local));
  }
  int ipv4 = ByteBuffer.wrap(host.getAddress().getAddress()).getInt();
  Endpoint endpoint = Endpoint.create("cassandra3", ipv4, host.getSocketAddress().getPort());
  span.addToBinary_annotations(BinaryAnnotation.address("sa", endpoint));
  collector.collect(span);
}
 
开发者ID:liaominghua,项目名称:zipkin,代码行数:22,代码来源:TracedSession.java

示例3: convert

import com.twitter.zipkin.gen.Endpoint; //导入依赖的package包/类
/**
 * Converts a given HTrace span to a Zipkin Span.
 * <ul>
 * <li>First set the start annotation. [CS, SR], depending whether it is a client service or not.
 * <li>Set other id's, etc [TraceId's etc]
 * <li>Create binary annotations based on data from HTrace Span object.
 * <li>Set the last annotation. [SS, CR]
 * </ul>
 */
public Span convert(org.apache.htrace.core.Span hTraceSpan) {
  Span zipkinSpan = new Span();
  String serviceName = hTraceSpan.getTracerId().toLowerCase();
  Endpoint ep = new Endpoint(ipv4Address, (short) getPort(serviceName), serviceName);
  List<Annotation> annotationList = createZipkinAnnotations(hTraceSpan, ep);
  List<BinaryAnnotation> binaryAnnotationList = createZipkinBinaryAnnotations(hTraceSpan, ep);
  zipkinSpan.setTrace_id(hTraceSpan.getSpanId().getHigh());
  if (hTraceSpan.getParents().length > 0) {
    if (hTraceSpan.getParents().length > 1) {
      LOG.error("zipkin doesn't support spans with multiple parents.  Omitting " +
          "other parents for " + hTraceSpan);
    }
    zipkinSpan.setParent_id(hTraceSpan.getParents()[0].getLow());
  }
  zipkinSpan.setId(hTraceSpan.getSpanId().getLow());
  zipkinSpan.setName(hTraceSpan.getDescription());
  zipkinSpan.setAnnotations(annotationList);
  zipkinSpan.setBinary_annotations(binaryAnnotationList);
  return zipkinSpan;
}
 
开发者ID:apache,项目名称:incubator-htrace,代码行数:30,代码来源:HTraceToZipkinConverter.java

示例4: createZipkinAnnotations

import com.twitter.zipkin.gen.Endpoint; //导入依赖的package包/类
/**
 * Add annotations from the htrace Span.
 */
private List<Annotation> createZipkinAnnotations(org.apache.htrace.core.Span hTraceSpan,
                                                 Endpoint ep) {
  List<Annotation> annotationList = new ArrayList<Annotation>();

  // add first zipkin  annotation.
  annotationList.add(createZipkinAnnotation(zipkinCoreConstants.CLIENT_SEND, hTraceSpan.getStartTimeMillis(), ep, true));
  annotationList.add(createZipkinAnnotation(zipkinCoreConstants.SERVER_RECV, hTraceSpan.getStartTimeMillis(), ep, true));
  // add HTrace time annotation
  for (TimelineAnnotation ta : hTraceSpan.getTimelineAnnotations()) {
    annotationList.add(createZipkinAnnotation(ta.getMessage(), ta.getTime(), ep, true));
  }
  // add last zipkin annotation
  annotationList.add(createZipkinAnnotation(zipkinCoreConstants.SERVER_SEND, hTraceSpan.getStopTimeMillis(), ep, false));
  annotationList.add(createZipkinAnnotation(zipkinCoreConstants.CLIENT_RECV, hTraceSpan.getStopTimeMillis(), ep, false));
  return annotationList;
}
 
开发者ID:apache,项目名称:incubator-htrace,代码行数:20,代码来源:HTraceToZipkinConverter.java

示例5: createZipkinAnnotation

import com.twitter.zipkin.gen.Endpoint; //导入依赖的package包/类
/**
 * Create an annotation with the correct times and endpoint.
 *
 * @param value       Annotation value
 * @param time        timestamp will be extracted
 * @param ep          the endopint this annotation will be associated with.
 * @param sendRequest use the first or last timestamp.
 */
private static Annotation createZipkinAnnotation(String value, long time,
                                                 Endpoint ep, boolean sendRequest) {
  Annotation annotation = new Annotation();
  annotation.setHost(ep);

  // Zipkin is in microseconds
  if (sendRequest) {
    annotation.setTimestamp(time * 1000);
  } else {
    annotation.setTimestamp(time * 1000);
  }

  annotation.setValue(value);
  return annotation;
}
 
开发者ID:apache,项目名称:incubator-htrace,代码行数:24,代码来源:HTraceToZipkinConverter.java

示例6: createZipkinBinaryAnnotations

import com.twitter.zipkin.gen.Endpoint; //导入依赖的package包/类
/**
 * Creates a list of Annotations that are present in HTrace Span object.
 *
 * @return list of Annotations that could be added to Zipkin Span.
 */
private List<BinaryAnnotation> createZipkinBinaryAnnotations(org.apache.htrace.core.Span span,
                                                             Endpoint ep) {
  List<BinaryAnnotation> l = new ArrayList<BinaryAnnotation>();
  for (Map.Entry<String, String> e : span.getKVAnnotations().entrySet()) {
    BinaryAnnotation binaryAnn = new BinaryAnnotation();
    binaryAnn.setAnnotation_type(AnnotationType.STRING);
    binaryAnn.setKey(e.getKey());
    binaryAnn.setValue(e.getValue().getBytes(StandardCharsets.UTF_8));
    binaryAnn.setHost(ep);
    l.add(binaryAnn);
  }
  return l;
}
 
开发者ID:apache,项目名称:incubator-htrace,代码行数:19,代码来源:HTraceToZipkinConverter.java

示例7: serverAddress

import com.twitter.zipkin.gen.Endpoint; //导入依赖的package包/类
@Override
public Endpoint serverAddress() {
    return null;
}
 
开发者ID:YanXs,项目名称:nighthawk,代码行数:5,代码来源:BraveDubboClientRequestAdapter.java

示例8: serverAddress

import com.twitter.zipkin.gen.Endpoint; //导入依赖的package包/类
@Override
public Endpoint serverAddress() {
  return null;
}
 
开发者ID:emmanuelidi,项目名称:vertx-zipkin,代码行数:5,代码来源:ZipkinEventBusClientRequestAdapter.java

示例9: generateEndpoint

import com.twitter.zipkin.gen.Endpoint; //导入依赖的package包/类
@Nonnull
private Endpoint generateEndpoint(@Nonnull ZipkinData zipkinData) {
    return new Endpoint(serviceIPv4, zipkinData.getPort(), serviceName);
}
 
开发者ID:betfair,项目名称:cougar,代码行数:5,代码来源:ZipkinEmitter.java

示例10: buildAnnotationsStore

import com.twitter.zipkin.gen.Endpoint; //导入依赖的package包/类
/**
 * Builds an annotations store for a specific ZipkinData object.
 * <p/>
 * The returning object should be used to emit more than 1 annotation at once. After adding your annotations you
 * will need to call emitAnnotations in order to send the span with all the annotations to Zipkin.
 *
 * @param zipkinData Zipkin request data
 * @return Zipkin annotations storage capable of merging multiple annotations per emission
 */
@Nonnull
public ZipkinAnnotationsStore buildAnnotationsStore(@Nonnull ZipkinData zipkinData) {
    Objects.requireNonNull(zipkinData);
    Endpoint endpoint = generateEndpoint(zipkinData);
    return new ZipkinAnnotationsStore(zipkinData).defaultEndpoint(endpoint);
}
 
开发者ID:betfair,项目名称:cougar,代码行数:16,代码来源:ZipkinEmitter.java


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