Please take the OpenCensus user survey



An annotation tells a descriptive story in text, of an event that occured 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 ""

    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.fromDescription("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)
  'Cache miss during GC',
  {store: 'memcache', cache_miss: true},

Visual representation


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