本文整理汇总了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);
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例7: serverAddress
import com.twitter.zipkin.gen.Endpoint; //导入依赖的package包/类
@Override
public Endpoint serverAddress() {
return null;
}
示例8: serverAddress
import com.twitter.zipkin.gen.Endpoint; //导入依赖的package包/类
@Override
public Endpoint serverAddress() {
return null;
}
示例9: generateEndpoint
import com.twitter.zipkin.gen.Endpoint; //导入依赖的package包/类
@Nonnull
private Endpoint generateEndpoint(@Nonnull ZipkinData zipkinData) {
return new Endpoint(serviceIPv4, zipkinData.getPort(), serviceName);
}
示例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);
}