Class TagKey

java.lang.Object
io.opencensus.tags.TagKey
Direct Known Subclasses:
AutoValue_TagKey

@Immutable public abstract class TagKey extends Object
A key to a value stored in a TagContext.

Each TagKey has a String name. Names have a maximum length of MAX_LENGTH and contain only printable ASCII characters.

TagKeys are designed to be used as constants. Declaring each key as a constant prevents key names from being validated multiple times.

Since:
0.8
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    The maximum length for a tag key name.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static TagKey
    create(String name)
    Constructs a TagKey with the given name.
    abstract String
    Returns the name of the key.
    private static boolean
    Determines whether the given String is a valid tag key.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • MAX_LENGTH

      public static final int MAX_LENGTH
      The maximum length for a tag key name. The value is 255.
      Since:
      0.8
      See Also:
  • Constructor Details

    • TagKey

      TagKey()
  • Method Details

    • create

      public static TagKey create(String name)
      Constructs a TagKey with the given name.

      The name must meet the following requirements:

      1. It cannot be longer than MAX_LENGTH.
      2. It can only contain printable ASCII characters.
      Parameters:
      name - the name of the key.
      Returns:
      a TagKey with the given name.
      Throws:
      IllegalArgumentException - if the name is not valid.
      Since:
      0.8
    • getName

      public abstract String getName()
      Returns the name of the key.
      Returns:
      the name of the key.
      Since:
      0.8
    • isValid

      private static boolean isValid(String name)
      Determines whether the given String is a valid tag key.
      Parameters:
      name - the tag key name to be validated.
      Returns:
      whether the name is valid.