本文整理了Java中io.opencensus.trace.Annotation.getDescription()
方法的一些代码示例,展示了Annotation.getDescription()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Annotation.getDescription()
方法的具体详情如下:
包路径:io.opencensus.trace.Annotation
类名称:Annotation
方法名:getDescription
[英]Return the description of the Annotation.
[中]返回注释的说明。
代码示例来源:origin: census-instrumentation/opencensus-java
private static String renderAnnotation(Annotation annotation) {
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append(annotation.getDescription());
if (!annotation.getAttributes().isEmpty()) {
stringBuilder.append(" ");
stringBuilder.append(renderAttributes(annotation.getAttributes()));
}
return stringBuilder.toString();
}
代码示例来源:origin: census-instrumentation/opencensus-java
@Test
public void fromDescriptionAndAttributes_EmptyAttributes() {
Annotation annotation =
Annotation.fromDescriptionAndAttributes(
"MyAnnotationText", Collections.<String, AttributeValue>emptyMap());
assertThat(annotation.getDescription()).isEqualTo("MyAnnotationText");
assertThat(annotation.getAttributes().size()).isEqualTo(0);
}
代码示例来源: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
@Test
public void fromDescriptionAndAttributes() {
Map<String, AttributeValue> attributes = new HashMap<String, AttributeValue>();
attributes.put(
"MyStringAttributeKey", AttributeValue.stringAttributeValue("MyStringAttributeValue"));
Annotation annotation = Annotation.fromDescriptionAndAttributes("MyAnnotationText", attributes);
assertThat(annotation.getDescription()).isEqualTo("MyAnnotationText");
assertThat(annotation.getAttributes()).isEqualTo(attributes);
}
代码示例来源:origin: census-instrumentation/opencensus-java
@Test
public void sqlExecute() throws Exception {
// When
String sql = "select 1";
Sample sample = (Sample) context.getBean("sample");
sample.execute(sql);
// Then
List<SpanData> data = handler.waitForExport(1);
assertThat(data).isNotNull();
assertThat(data.size()).isEqualTo(1);
assertThat(data.get(0).getName()).isEqualTo("execute-4705ea0d"); // sql-{hash of sql statement}
List<SpanData.TimedEvent<Annotation>> events = data.get(0).getAnnotations().getEvents();
assertThat(events.size()).isEqualTo(1);
assertThat(events.get(0).getEvent().getDescription()).isEqualTo(sql);
}
代码示例来源:origin: census-instrumentation/opencensus-java
@Test
public void sqlQuery() throws Exception {
// When
String sql = "select 2";
Sample sample = (Sample) context.getBean("sample");
sample.executeQuery(sql);
// Then
List<SpanData> data = handler.waitForExport(1);
assertThat(data).isNotNull();
assertThat(data.size()).isEqualTo(1);
assertThat(data.get(0).getName()).isEqualTo("executeQuery-4705ea0e");
SpanData.TimedEvents<Annotation> annotations = data.get(0).getAnnotations();
List<SpanData.TimedEvent<Annotation>> events = annotations.getEvents();
assertThat(events.size()).isEqualTo(1);
assertThat(events.get(0).getEvent().getDescription()).isEqualTo(sql);
}
代码示例来源:origin: census-instrumentation/opencensus-java
@Test
public void sqlUpdate() throws Exception {
// When
String sql = "update content set value = 1";
Sample sample = (Sample) context.getBean("sample");
sample.executeUpdate(sql);
// Then
List<SpanData> data = handler.waitForExport(1);
assertThat(data).isNotNull();
assertThat(data.size()).isEqualTo(1);
assertThat(data.get(0).getName()).isEqualTo("executeUpdate-acaeb423");
List<SpanData.TimedEvent<Annotation>> events = data.get(0).getAnnotations().getEvents();
assertThat(events.size()).isEqualTo(1);
assertThat(events.get(0).getEvent().getDescription()).isEqualTo(sql);
}
}
代码示例来源:origin: census-instrumentation/opencensus-java
@Test
public void handlesException() {
// When
Sample sample = (Sample) context.getBean("sample");
try {
sample.boom();
} catch (Exception ignored) {
// ok
}
// Then
List<SpanData> spanList = handler.waitForExport(1);
assertThat(spanList).isNotNull();
assertThat(spanList.size()).isEqualTo(1);
SpanData spanData = spanList.get(0);
assertThat(spanData.getName()).isEqualTo("boom");
assertThat(spanData.getStatus()).isEqualTo(Status.UNKNOWN);
SpanData.TimedEvents<Annotation> annotations = spanData.getAnnotations();
assertThat(annotations).isNotNull();
List<SpanData.TimedEvent<Annotation>> events = annotations.getEvents();
assertThat(events.size()).isEqualTo(1);
assertThat(events.get(0).getEvent().getDescription()).isEqualTo("error");
}
代码示例来源:origin: census-instrumentation/opencensus-java
attributesToTags(
event.getEvent().getAttributes(),
descriptionToTag(event.getEvent().getDescription()))));
代码示例来源:origin: census-instrumentation/opencensus-java
private static TimeEvent toTimeAnnotationProto(TimedEvent<Annotation> timedEvent) {
TimeEvent.Builder timeEventBuilder =
TimeEvent.newBuilder().setTime(toTimestampProto(timedEvent.getTimestamp()));
Annotation annotation = timedEvent.getEvent();
timeEventBuilder.setAnnotation(
TimeEvent.Annotation.newBuilder()
.setDescription(toTruncatableStringProto(annotation.getDescription()))
.setAttributes(toAttributesBuilderProto(annotation.getAttributes(), 0))
.build());
return timeEventBuilder.build();
}
代码示例来源:origin: census-instrumentation/opencensus-java
private static TimeEvent toTimeAnnotationProto(TimedEvent<Annotation> timedEvent) {
TimeEvent.Builder timeEventBuilder =
TimeEvent.newBuilder().setTime(toTimestampProto(timedEvent.getTimestamp()));
Annotation annotation = timedEvent.getEvent();
timeEventBuilder.setAnnotation(
TimeEvent.Annotation.newBuilder()
.setDescription(toTruncatableStringProto(annotation.getDescription()))
.setAttributes(toAttributesBuilderProto(annotation.getAttributes(), 0))
.build());
return timeEventBuilder.build();
}
代码示例来源:origin: io.opencensus/opencensus-exporter-trace-stackdriver
private static TimeEvent toTimeAnnotationProto(TimedEvent<Annotation> timedEvent) {
TimeEvent.Builder timeEventBuilder =
TimeEvent.newBuilder().setTime(toTimestampProto(timedEvent.getTimestamp()));
Annotation annotation = timedEvent.getEvent();
timeEventBuilder.setAnnotation(
TimeEvent.Annotation.newBuilder()
.setDescription(toTruncatableStringProto(annotation.getDescription()))
.setAttributes(toAttributesBuilderProto(annotation.getAttributes(), 0))
.build());
return timeEventBuilder.build();
}
代码示例来源:origin: census-instrumentation/opencensus-java
toEpochMicros(annotation.getTimestamp()), annotation.getEvent().getDescription());
内容来源于网络,如有侵权,请联系作者删除!