Annotation
Annotation
An annotation tells a descriptive story in text, of an event that occurred during a span’s lifetime.
It consists of fields:
Field | Information |
---|---|
Description | The user supplied message that details the event |
Attributes | A set of attributes to articulate the annotate |
Code examples
We’ll add an annotation to a span in the excerpts with a couple of languages:
import "go.opencensus.io/trace"
span.Annotate([]trace.Attribute{
trace.StringAttribute("store", "memcache"),
trace.BoolAttribute("cache_miss", true),
trace.Int64Attribute("age_ns", 13488999),
}, "Cache miss during GC")
import io.opencensus.trace.AttributeValue;
import java.util.HashMap;
HashMap<String, AttributeValue> map = new HashMap<String, AttributeValue>();
map.put("store", AttributeValue.stringAttributeValue("memcache"));
map.put("cache_miss", AttributeValue.booleanAttributeValue(true));
map.put("age_ns", AttributeValue.int64AttributeValue(13488999));
span.addAnnotation(Annotation.fromDescriptionAndAttributes("Cache miss during GC", map));
span.AddAnnotation("Cache miss during GC", {{"store", "memcache"}},
{{"cache_miss", True}}, {{"age_ns", 13488999}});
span.add_annotation("Cache miss during GC", store="memcache", cache_miss=true, age_ns=13488999)
rootSpan.addAnnotation(
'Cache miss during GC',
{store: 'memcache', cache_miss: true},
13488999
);
Visual representation
References
Resource | URL |
---|---|
Data model reference | trace_proto/v1.Annotation |
Go annotation API: Span.Annotate | GoDoc |
Java annotation API: Span.addAnnotation | JavaDoc |
Python annotation API | Definition |
C++ annotation API | Definition |