Please take the OpenCensus user survey



To record specific tags against measurements, they need to be isolated and inserted into a collection. This is collection of tags is called a “TagMap”

Source code example

package main

import (

func doWork() {
	// The TagMap is inserted into this context
	ctx, _ := tag.New(ctx,
		tag.Upsert(tagKey, "gomemcache.Client.Get"),
		tag.Upsert(tagKeyRegion, "asia-x1"))
import opencensus.tags import tag_map
import opencensus.tags import tag_value

# Values are inserted 
tag_map.TagMap().insert(keyMethod, tag_value.TagValue("memcache.Client.Get"))
import io.opencensus.tags.TagContext;
import io.opencensus.tags.Tagger;

Tagger TAGGER = Tags.getTagger();
TagContext tagCtx = TAGGER.currentBuilder().
                put(keyMethod, TagValue.create("memcache.Client.Get")).
#include "absl/strings/string_view.h"
#include "opencensus/tags/tag_key.h"
#include "opencensus/tags/tag_map.h"

ABSL_CONST_INIT const absl::string_view kGetMethod = "memcache.Client.Get";

opencensus::tags::TagKey MethodKey() {
  static const auto method = opencensus::tags::TagKey::Register("method");
  return method;

void Get() {
  opencensus::tags::TagMap tm({{MethodKey(), kGetMethod}});
  // ...

void Put() {
  // If the number of tags is variable, we can construct them from a vector.
  std::vector<std::pair<opencensus::tags::TagKey, std::string>> tags;
  // The tag value can also just be a string literal.
  tags.emplace_back(MethodKey(), "memcache.Client.Put");
  opencensus::tags::TagMap tm(std::move(tags));
  // ...
const keyMethod = "method";


Resource URL
Specs reference specs.TagContext
Go reference tag.New
Java reference TagContext