io.opencensus.trace.Annotation.getAttributes()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(3.8k)|赞(0)|评价(0)|浏览(105)

本文整理了Java中io.opencensus.trace.Annotation.getAttributes()方法的一些代码示例,展示了Annotation.getAttributes()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Annotation.getAttributes()方法的具体详情如下:
包路径:io.opencensus.trace.Annotation
类名称:Annotation
方法名:getAttributes

Annotation.getAttributes介绍

[英]Return the attributes 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

timestampsInMicros,
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();
}

相关文章