Package io.opencensus.tags
Class TagKey
- java.lang.Object
-
- io.opencensus.tags.TagKey
-
- Direct Known Subclasses:
AutoValue_TagKey
@Immutable public abstract class TagKey extends java.lang.ObjectA key to a value stored in aTagContext.Each
TagKeyhas aStringname. Names have a maximum length ofMAX_LENGTHand 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 intMAX_LENGTHThe maximum length for a tag key name.
-
Constructor Summary
Constructors Constructor Description TagKey()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static TagKeycreate(java.lang.String name)Constructs aTagKeywith the given name.abstract java.lang.StringgetName()Returns the name of the key.private static booleanisValid(java.lang.String name)Determines whether the givenStringis a valid tag key.
-
-
-
Field Detail
-
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:
- Constant Field Values
-
-
Method Detail
-
create
public static TagKey create(java.lang.String name)
Constructs aTagKeywith the given name.The name must meet the following requirements:
- It cannot be longer than
MAX_LENGTH. - It can only contain printable ASCII characters.
- Parameters:
name- the name of the key.- Returns:
- a
TagKeywith the given name. - Throws:
java.lang.IllegalArgumentException- if the name is not valid.- Since:
- 0.8
- It cannot be longer than
-
getName
public abstract java.lang.String getName()
Returns the name of the key.- Returns:
- the name of the key.
- Since:
- 0.8
-
isValid
private static boolean isValid(java.lang.String name)
Determines whether the givenStringis a valid tag key.- Parameters:
name- the tag key name to be validated.- Returns:
- whether the name is valid.
-
-