本文整理了Java中io.opencensus.trace.Annotation.fromDescription()
方法的一些代码示例,展示了Annotation.fromDescription()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Annotation.fromDescription()
方法的具体详情如下:
包路径:io.opencensus.trace.Annotation
类名称:Annotation
方法名:fromDescription
[英]Returns a new Annotation with the given description.
[中]返回具有给定说明的新注释。
代码示例来源:origin: census-instrumentation/opencensus-java
@Test(expected = NullPointerException.class)
public void fromDescription_NullDescription() {
Annotation.fromDescription(null);
}
代码示例来源:origin: census-instrumentation/opencensus-java
@Test
public void annotation_ToString() {
Annotation annotation = Annotation.fromDescription("MyAnnotationText");
assertThat(annotation.toString()).contains("MyAnnotationText");
Map<String, AttributeValue> attributes = new HashMap<String, AttributeValue>();
attributes.put(
"MyStringAttributeKey", AttributeValue.stringAttributeValue("MyStringAttributeValue"));
annotation = Annotation.fromDescriptionAndAttributes("MyAnnotationText2", attributes);
assertThat(annotation.toString()).contains("MyAnnotationText2");
assertThat(annotation.toString()).contains(attributes.toString());
}
}
代码示例来源:origin: census-instrumentation/opencensus-java
@Test
public void annotation_EqualsAndHashCode() {
EqualsTester tester = new EqualsTester();
Map<String, AttributeValue> attributes = new HashMap<String, AttributeValue>();
attributes.put(
"MyStringAttributeKey", AttributeValue.stringAttributeValue("MyStringAttributeValue"));
tester
.addEqualityGroup(
Annotation.fromDescription("MyAnnotationText"),
Annotation.fromDescriptionAndAttributes(
"MyAnnotationText", Collections.<String, AttributeValue>emptyMap()))
.addEqualityGroup(
Annotation.fromDescriptionAndAttributes("MyAnnotationText", attributes),
Annotation.fromDescriptionAndAttributes("MyAnnotationText", attributes))
.addEqualityGroup(Annotation.fromDescription("MyAnnotationText2"));
tester.testEquals();
}
代码示例来源:origin: census-instrumentation/opencensus-java
@Test
public void fromDescription() {
Annotation annotation = Annotation.fromDescription("MyAnnotationText");
assertThat(annotation.getDescription()).isEqualTo("MyAnnotationText");
assertThat(annotation.getAttributes().size()).isEqualTo(0);
}
代码示例来源:origin: census-instrumentation/opencensus-java
span.putAttributes(attributes);
testClock.advanceTime(Duration.create(0, 100));
span.addAnnotation(Annotation.fromDescription(ANNOTATION_DESCRIPTION));
testClock.advanceTime(Duration.create(0, 100));
span.addAnnotation(ANNOTATION_DESCRIPTION, attributes);
.isEqualTo(timestamp.addNanos(100));
assertThat(spanData.getAnnotations().getEvents().get(0).getEvent())
.isEqualTo(Annotation.fromDescription(ANNOTATION_DESCRIPTION));
assertThat(spanData.getAnnotations().getEvents().get(1).getTimestamp())
.isEqualTo(timestamp.addNanos(200));
代码示例来源:origin: census-instrumentation/opencensus-java
timestampConverter,
testClock);
Annotation annotation = Annotation.fromDescription(ANNOTATION_DESCRIPTION);
for (int i = 0; i < 2 * maxNumberOfAnnotations; i++) {
span.addAnnotation(annotation);
代码示例来源:origin: census-instrumentation/opencensus-java
span.putAttributes(attributes);
testClock.advanceTime(Duration.create(0, 100));
span.addAnnotation(Annotation.fromDescription(ANNOTATION_DESCRIPTION));
testClock.advanceTime(Duration.create(0, 100));
span.addAnnotation(ANNOTATION_DESCRIPTION, attributes);
.isEqualTo(timestamp.addNanos(100));
assertThat(spanData.getAnnotations().getEvents().get(0).getEvent())
.isEqualTo(Annotation.fromDescription(ANNOTATION_DESCRIPTION));
assertThat(spanData.getAnnotations().getEvents().get(1).getTimestamp())
.isEqualTo(timestamp.addNanos(200));
代码示例来源:origin: census-instrumentation/opencensus-java
@Test
public void doNotCrash() {
Map<String, AttributeValue> attributes = new HashMap<String, AttributeValue>();
attributes.put(
"MyStringAttributeKey", AttributeValue.stringAttributeValue("MyStringAttributeValue"));
Map<String, AttributeValue> multipleAttributes = new HashMap<String, AttributeValue>();
multipleAttributes.put(
"MyStringAttributeKey", AttributeValue.stringAttributeValue("MyStringAttributeValue"));
multipleAttributes.put("MyBooleanAttributeKey", AttributeValue.booleanAttributeValue(true));
multipleAttributes.put("MyLongAttributeKey", AttributeValue.longAttributeValue(123));
// Tests only that all the methods are not crashing/throwing errors.
BlankSpan.INSTANCE.putAttribute(
"MyStringAttributeKey2", AttributeValue.stringAttributeValue("MyStringAttributeValue2"));
BlankSpan.INSTANCE.addAttributes(attributes);
BlankSpan.INSTANCE.addAttributes(multipleAttributes);
BlankSpan.INSTANCE.addAnnotation("MyAnnotation");
BlankSpan.INSTANCE.addAnnotation("MyAnnotation", attributes);
BlankSpan.INSTANCE.addAnnotation("MyAnnotation", multipleAttributes);
BlankSpan.INSTANCE.addAnnotation(Annotation.fromDescription("MyAnnotation"));
BlankSpan.INSTANCE.addNetworkEvent(NetworkEvent.builder(NetworkEvent.Type.SENT, 1L).build());
BlankSpan.INSTANCE.addMessageEvent(MessageEvent.builder(MessageEvent.Type.SENT, 1L).build());
BlankSpan.INSTANCE.addLink(
Link.fromSpanContext(SpanContext.INVALID, Link.Type.CHILD_LINKED_SPAN));
BlankSpan.INSTANCE.setStatus(Status.OK);
BlankSpan.INSTANCE.end(EndSpanOptions.DEFAULT);
BlankSpan.INSTANCE.end();
}
代码示例来源:origin: census-instrumentation/opencensus-java
@Test
public void doNotCrash() {
Map<String, AttributeValue> attributes = new HashMap<String, AttributeValue>();
attributes.put(
"MyStringAttributeKey", AttributeValue.stringAttributeValue("MyStringAttributeValue"));
Map<String, AttributeValue> multipleAttributes = new HashMap<String, AttributeValue>();
multipleAttributes.put(
"MyStringAttributeKey", AttributeValue.stringAttributeValue("MyStringAttributeValue"));
multipleAttributes.put("MyBooleanAttributeKey", AttributeValue.booleanAttributeValue(true));
multipleAttributes.put("MyLongAttributeKey", AttributeValue.longAttributeValue(123));
// Tests only that all the methods are not crashing/throwing errors.
noRecordEventsSpan.putAttribute(
"MyStringAttributeKey2", AttributeValue.stringAttributeValue("MyStringAttributeValue2"));
noRecordEventsSpan.addAttributes(attributes);
noRecordEventsSpan.addAttributes(multipleAttributes);
noRecordEventsSpan.addAnnotation("MyAnnotation");
noRecordEventsSpan.addAnnotation("MyAnnotation", attributes);
noRecordEventsSpan.addAnnotation("MyAnnotation", multipleAttributes);
noRecordEventsSpan.addAnnotation(Annotation.fromDescription("MyAnnotation"));
noRecordEventsSpan.addNetworkEvent(NetworkEvent.builder(NetworkEvent.Type.SENT, 1L).build());
noRecordEventsSpan.addMessageEvent(MessageEvent.builder(MessageEvent.Type.SENT, 1L).build());
noRecordEventsSpan.addLink(
Link.fromSpanContext(SpanContext.INVALID, Link.Type.CHILD_LINKED_SPAN));
noRecordEventsSpan.setStatus(Status.OK);
noRecordEventsSpan.end(EndSpanOptions.DEFAULT);
noRecordEventsSpan.end();
}
}
代码示例来源:origin: census-instrumentation/opencensus-java
"MySingleStringAttributeKey",
AttributeValue.stringAttributeValue("MySingleStringAttributeValue"));
span.addAnnotation(Annotation.fromDescription(ANNOTATION_DESCRIPTION));
span.addAnnotation(ANNOTATION_DESCRIPTION, attributes);
span.addNetworkEvent(
内容来源于网络,如有侵权,请联系作者删除!