Class Identity
- java.lang.Object
-
- com.lightbend.cinnamon.meta.Identity
-
public class Identity extends java.lang.ObjectGeneral purpose identity for instrumented entities.Entities can be identified by class (only has a class), instance (has both class and name), or group (only has a name).
Identities belong to a category, for grouping instruments into categories like 'actors' or 'dispatchers'. Expressed in plural form.
Identities have a key, used for tags.
Identities can be organised in hierarchies, where each identity can have a parent identity, for forming full identifier keys.
Identities can be hidden, where they are in the hierarchy but not used.
Identities can be marked as being 'unique', unique to this instance of Cinnamon, such as host name and application identifier.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classIdentity.Builderstatic classIdentity.IdentityCache<T>
-
Constructor Summary
Constructors Modifier Constructor Description protectedIdentity(Identity.Builder builder)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Identity.Builderbuilder()Create a new identity builder, based on this identity.protected Identity.BuildercopyToBuilder(Identity.Builder builder)static Identity.BuildercreateFor(java.lang.String category, java.lang.String key)Create a new identity builder.booleanequals(java.lang.Object o)java.lang.StringgetCategory()The category for this identity (used for grouping, expressed in plural form).java.lang.ClassgetEntityClass()The entity class for this identity.java.lang.StringgetEntityName()The entity name for this identity (for instance or group identities).java.lang.StringgetKey()The key for this identity (used for tags).java.lang.StringgetName()Get the entity name (for instance or group) otherwise get the entity class name.static <T> Identity.IdentityCache<T>getNewCache()IdentitygetParent()The enclosing parent identity for this identity.java.util.Map<java.lang.String,java.lang.String>getTags()The tags for this identity.booleanhasCategory()Whether this identity has an associated category (used for grouping, expressed in plural form).booleanhasEntityClass()Whether this identity has an associated entity class.booleanhasEntityName()Whether this identity has an associated entity name (for instance or group identities).inthashCode()booleanhasKey()Whether this identity has an associated key (used for tags).booleanhasName()Whether this identity has an associated name (either entity name or entity class).booleanhasParent()Whether this identity has an enclosing parent identity.booleanisDestroyable()Whether instruments for this identity can be destroyed, once the entity for this identity has terminated in some way.booleanisUnique()Whether this identity is unique to this instance of Cinnamon, such as host name or application identifier.booleanisVisible()Whether this identity is visible, and should be included in metric keys or tags.static IdentityofClass(java.lang.String category, java.lang.String key, java.lang.Class entityClass)Create a new identity with class only, and no parent identity.static IdentityofClass(java.lang.String category, java.lang.String key, java.lang.Class entityClass, Identity parent)Create a new identity with class only.static IdentityofGroup(java.lang.String entityName)Create a new identity with name only, and no category, key, or parent identity.static IdentityofGroup(java.lang.String entityName, Identity parent)Create a new identity with name and parent only, no category or key.static IdentityofGroup(java.lang.String category, java.lang.String key, java.lang.String entityName)Create a new identity with name only, and no parent identity.static IdentityofGroup(java.lang.String category, java.lang.String key, java.lang.String entityName, Identity parent)Create a new identity with name only.static IdentityofInstance(java.lang.Class entityClass, java.lang.String entityName)Create a new identity with both class and name, and no category or parent identity.static IdentityofInstance(java.lang.String category, java.lang.String key, java.lang.Class entityClass, java.lang.String entityName)Create a new identity with both class and name, and no parent identity.static IdentityofInstance(java.lang.String category, java.lang.String key, java.lang.Class entityClass, java.lang.String entityName, Identity parent)Create a new identity with both class and name.static IdentityofTag(java.lang.String category, java.lang.String key, java.lang.String tag, Identity parent)Create a new identity with name only.java.lang.StringtoString()
-
-
-
Field Detail
-
NONE
public static Identity NONE
Empty identity.
-
-
Constructor Detail
-
Identity
protected Identity(Identity.Builder builder)
-
-
Method Detail
-
createFor
public static Identity.Builder createFor(java.lang.String category, java.lang.String key)
Create a new identity builder.- Parameters:
category- category for entity (plural form)key- key for entity (used in tags)- Returns:
- new
Identity.Builderto create identity
-
ofClass
public static Identity ofClass(java.lang.String category, java.lang.String key, java.lang.Class entityClass)
Create a new identity with class only, and no parent identity. Identifies all instances in a class, so not destroyable.- Parameters:
category- category for entity (plural form)key- key for entity (used in tags)entityClass- class for entity- Returns:
- new class Identity
-
ofClass
public static Identity ofClass(java.lang.String category, java.lang.String key, java.lang.Class entityClass, Identity parent)
Create a new identity with class only. Identifies all instances in a class, so not destroyable.- Parameters:
category- category for entity (plural form)key- key for entity (used in tags)entityClass- class for entityparent- enclosing parent identity- Returns:
- new class Identity
-
ofInstance
public static Identity ofInstance(java.lang.Class entityClass, java.lang.String entityName)
Create a new identity with both class and name, and no category or parent identity. Assumed to be an instance, therefore destroyable.- Parameters:
entityClass- class for entityentityName- instance name for entity- Returns:
- new instance Identity
-
ofInstance
public static Identity ofInstance(java.lang.String category, java.lang.String key, java.lang.Class entityClass, java.lang.String entityName)
Create a new identity with both class and name, and no parent identity. Assumed to be an instance, therefore destroyable.- Parameters:
category- category for entity (plural form)key- key for entity (used in tags)entityClass- class for entityentityName- instance name for entity- Returns:
- new instance Identity
-
ofInstance
public static Identity ofInstance(java.lang.String category, java.lang.String key, java.lang.Class entityClass, java.lang.String entityName, Identity parent)
Create a new identity with both class and name. Assumed to be an instance, therefore destroyable.- Parameters:
category- category for entity (plural form)key- key for entity (used in tags)entityClass- class for entityentityName- instance name for entityparent- enclosing parent identity- Returns:
- new instance Identity
-
ofGroup
public static Identity ofGroup(java.lang.String entityName)
Create a new identity with name only, and no category, key, or parent identity. Assumed to be a group of entities, so not destroyable.- Parameters:
entityName- group name for entity- Returns:
- new group Identity
-
ofGroup
public static Identity ofGroup(java.lang.String entityName, Identity parent)
Create a new identity with name and parent only, no category or key. Assumed to be a group of entities, so not destroyable.- Parameters:
entityName- group name for entityparent- enclosing parent identity- Returns:
- new group Identity
-
ofGroup
public static Identity ofGroup(java.lang.String category, java.lang.String key, java.lang.String entityName)
Create a new identity with name only, and no parent identity. Assumed to be a group of entities, so not destroyable.- Parameters:
category- category for entity (plural form)key- key for entity (used in tags)entityName- group name for entity- Returns:
- new group Identity
-
ofGroup
public static Identity ofGroup(java.lang.String category, java.lang.String key, java.lang.String entityName, Identity parent)
Create a new identity with name only. Assumed to be a group of entities, so not destroyable.- Parameters:
category- category for entity (plural form)key- key for entity (used in tags)entityName- group name for entityparent- enclosing parent identity- Returns:
- new group Identity
-
ofTag
public static Identity ofTag(java.lang.String category, java.lang.String key, java.lang.String tag, Identity parent)
Create a new identity with name only. Assumed to be a group of entities, so not destroyable.- Parameters:
category- category for entity (plural form)key- key for entitytag- name of the groupparent- enclosing parent identity- Returns:
- new group Identity
-
hasEntityClass
public boolean hasEntityClass()
Whether this identity has an associated entity class.- Returns:
booleanwhether a class is specified
-
getEntityClass
public java.lang.Class getEntityClass()
The entity class for this identity. May be null.- Returns:
Classfor this identity, or null if not present
-
hasEntityName
public boolean hasEntityName()
Whether this identity has an associated entity name (for instance or group identities).- Returns:
booleanwhether a name is specified
-
getEntityName
public java.lang.String getEntityName()
The entity name for this identity (for instance or group identities). May be null.- Returns:
Stringname for this identity, or null if not present
-
hasName
public boolean hasName()
Whether this identity has an associated name (either entity name or entity class).- Returns:
booleanwhether a name is specified
-
getName
public java.lang.String getName()
Get the entity name (for instance or group) otherwise get the entity class name.- Returns:
Stringeither the name or class name for this identity
-
hasCategory
public boolean hasCategory()
Whether this identity has an associated category (used for grouping, expressed in plural form).- Returns:
booleanwhether a category is specified
-
getCategory
public java.lang.String getCategory()
The category for this identity (used for grouping, expressed in plural form). May be null.- Returns:
Stringcategory for this identity, or null if not present
-
hasKey
public boolean hasKey()
Whether this identity has an associated key (used for tags).- Returns:
booleanwhether a key is specified
-
getKey
public java.lang.String getKey()
The key for this identity (used for tags). May be null.- Returns:
Stringkey for this identity, or null if not present
-
getTags
public java.util.Map<java.lang.String,java.lang.String> getTags()
The tags for this identity. Used in both the metric key and metric tags.- Returns:
Map<String, String>of tags.
-
hasParent
public boolean hasParent()
Whether this identity has an enclosing parent identity.- Returns:
booleanwhether parent identity is specified
-
getParent
public Identity getParent()
The enclosing parent identity for this identity. May be null.- Returns:
Identityparent for this identity, or null if not present
-
isDestroyable
public boolean isDestroyable()
Whether instruments for this identity can be destroyed, once the entity for this identity has terminated in some way.Instance identities are destroyable, while class and group identities are assumed to be not destroyable given that other instances with the same identity could still continue to exist.
- Returns:
booleanwhether this identity is destroyable
-
isVisible
public boolean isVisible()
Whether this identity is visible, and should be included in metric keys or tags.- Returns:
booleanwhether this identity is visible
-
isUnique
public boolean isUnique()
Whether this identity is unique to this instance of Cinnamon, such as host name or application identifier.- Returns:
booleanwhether this identity is unique
-
builder
public Identity.Builder builder()
Create a new identity builder, based on this identity.- Returns:
- new Identity.Builder to create new identity
-
copyToBuilder
protected Identity.Builder copyToBuilder(Identity.Builder builder)
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
getNewCache
public static <T> Identity.IdentityCache<T> getNewCache()
-
-