本文整理了Java中io.opencensus.trace.Annotation.fromDescriptionAndAttributes()
方法的一些代码示例,展示了Annotation.fromDescriptionAndAttributes()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Annotation.fromDescriptionAndAttributes()
方法的具体详情如下:
包路径:io.opencensus.trace.Annotation
类名称:Annotation
方法名:fromDescriptionAndAttributes
[英]Returns a new Annotation with the given description and set of attributes.
[中]
代码示例来源:origin: googleapis/google-cloud-java
private Annotation sessionAnnotation(Session session) {
AttributeValue sessionId = AttributeValue.stringAttributeValue(session.getName());
return Annotation.fromDescriptionAndAttributes(
"Using Session", ImmutableMap.of("sessionId", sessionId));
}
代码示例来源:origin: com.google.cloud/google-cloud-spanner
private Annotation sessionAnnotation(Session session) {
AttributeValue sessionId = AttributeValue.stringAttributeValue(session.getName());
return Annotation.fromDescriptionAndAttributes(
"Using Session", ImmutableMap.of("sessionId", sessionId));
}
代码示例来源:origin: census-instrumentation/opencensus-java
@Override
public void addAnnotation(String description, Map<String, AttributeValue> attributes) {
Preconditions.checkNotNull(description, "description");
Preconditions.checkNotNull(attributes, "attribute");
synchronized (this) {
if (hasBeenEnded) {
logger.log(Level.FINE, "Calling addAnnotation() on an ended Span.");
return;
}
getInitializedAnnotations()
.addEvent(
new EventWithNanoTime<Annotation>(
clock.nowNanos(),
Annotation.fromDescriptionAndAttributes(description, attributes)));
}
}
代码示例来源:origin: io.opencensus/opencensus-impl-core
@Override
public void addAnnotation(String description, Map<String, AttributeValue> attributes) {
Preconditions.checkNotNull(description, "description");
Preconditions.checkNotNull(attributes, "attribute");
synchronized (this) {
if (hasBeenEnded) {
logger.log(Level.FINE, "Calling addAnnotation() on an ended Span.");
return;
}
getInitializedAnnotations()
.addEvent(
new EventWithNanoTime<Annotation>(
clock.nowNanos(),
Annotation.fromDescriptionAndAttributes(description, attributes)));
}
}
代码示例来源:origin: census-instrumentation/opencensus-java
@Test(expected = NullPointerException.class)
public void fromDescriptionAndAttributes_NullDescription() {
Annotation.fromDescriptionAndAttributes(null, Collections.<String, AttributeValue>emptyMap());
}
代码示例来源:origin: census-instrumentation/opencensus-java
@Test(expected = NullPointerException.class)
public void fromDescriptionAndAttributes_NullAttributes() {
Annotation.fromDescriptionAndAttributes("", 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 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 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 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
private static SpanData.TimedEvent<Annotation> sampleAnnotation() {
return SpanData.TimedEvent.create(
Timestamp.create(1519629872L, 987654321),
Annotation.fromDescriptionAndAttributes(
"annotation #1",
ImmutableMap.of(
"bool", AttributeValue.booleanAttributeValue(true),
"long", AttributeValue.longAttributeValue(1337L),
"string",
AttributeValue.stringAttributeValue(
"Kind words do not cost much. Yet they accomplish much. -- Pascal"))));
}
代码示例来源:origin: GoogleCloudPlatform/cloud-bigtable-client
/**
* Calls {@link BigtableAsyncRpc#newCall(CallOptions)} and
* {@link BigtableAsyncRpc#start(Object, io.grpc.ClientCall.Listener, Metadata, ClientCall)} }
* with this as the listener so that retries happen correctly.
*/
protected void run() {
try (Scope scope = TRACER.withSpan(operationSpan)) {
rpcTimerContext = rpc.getRpcMetrics().timeRpc();
operationSpan.addAnnotation(Annotation.fromDescriptionAndAttributes("rpcStart",
ImmutableMap.of("attempt", AttributeValue.longAttributeValue(failedCount))));
Metadata metadata = new Metadata();
metadata.merge(originalMetadata);
callWrapper.setCallAndStart(rpc, getRpcCallOptions(), getRetryRequest(), this, metadata);
} catch (Exception e) {
setException(e);
}
}
代码示例来源:origin: census-instrumentation/opencensus-java
.isEqualTo(timestamp.addNanos(200));
assertThat(spanData.getAnnotations().getEvents().get(1).getEvent())
.isEqualTo(Annotation.fromDescriptionAndAttributes(ANNOTATION_DESCRIPTION, attributes));
assertThat(spanData.getNetworkEvents().getDroppedEventsCount()).isEqualTo(0);
assertThat(spanData.getNetworkEvents().getEvents().size()).isEqualTo(1);
代码示例来源:origin: census-instrumentation/opencensus-java
.isEqualTo(timestamp.addNanos(200));
assertThat(spanData.getAnnotations().getEvents().get(1).getEvent())
.isEqualTo(Annotation.fromDescriptionAndAttributes(ANNOTATION_DESCRIPTION, attributes));
assertThat(spanData.getNetworkEvents().getDroppedEventsCount()).isEqualTo(0);
assertThat(spanData.getNetworkEvents().getEvents().size()).isEqualTo(1);
内容来源于网络,如有侵权,请联系作者删除!