Class Resource
java.lang.Object
io.opencensus.resource.Resource
- Direct Known Subclasses:
AutoValue_Resource
Resource represents a resource, which capture identifying information about the entities
for which signals (stats or traces) are reported. It further provides a framework for detection
of resource information from the environment and progressive population as signals propagate from
the core instrumentation library to a backend's exporter.- Since:
- 0.18
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ResourceReturns aResource.static ResourceReturns aResource.private static ResourcecreateInternal(String type, Map<String, String> labels) Returns a map of labels that describe the resource.abstract StringgetType()Returns the type identifier for the resource.private static booleanDetermines whether the givenStringis a valid printable ASCII string with a length not exceedMAX_LENGTHcharacters.private static booleanisValidAndNotEmpty(String name) Determines whether the givenStringis a valid printable ASCII string with a length greater than 0 and not exceedMAX_LENGTHcharacters.private static ResourceReturns a new, mergedResourceby merging two resources.static ResourcemergeResources(List<Resource> resources) Returns aResourcethat runs all input resources sequentially and merges their results.parseResourceLabels(String rawEnvLabels) (package private) static StringparseResourceType(String rawEnvType) Creates a resource type from the OC_RESOURCE_TYPE environment variable.
-
Field Details
-
MAX_LENGTH
static final int MAX_LENGTH- See Also:
-
OC_RESOURCE_TYPE_ENV
- See Also:
-
OC_RESOURCE_LABELS_ENV
- See Also:
-
LABEL_LIST_SPLITTER
- See Also:
-
LABEL_KEY_VALUE_SPLITTER
- See Also:
-
ERROR_MESSAGE_INVALID_CHARS
- See Also:
-
ERROR_MESSAGE_INVALID_VALUE
- See Also:
-
ENV_TYPE
-
ENV_LABEL_MAP
-
-
Constructor Details
-
Resource
Resource()
-
-
Method Details
-
getType
-
getLabels
-
createFromEnvironmentVariables
-
create
Returns aResource.- Parameters:
type- the type identifier for the resource.labels- a map of labels that describe the resource.- Returns:
- a
Resource. - Throws:
NullPointerException- iflabelsis null.IllegalArgumentException- if type or label key or label value is not a valid printable ASCII string or exceedMAX_LENGTHcharacters.- Since:
- 0.18
-
mergeResources
Returns aResourcethat runs all input resources sequentially and merges their results. In case a type of label key is already set, the first set value takes precedence.- Parameters:
resources- a list of resources.- Returns:
- a
Resource. - Since:
- 0.18
-
createInternal
-
parseResourceType
-
parseResourceLabels
-
merge
-
isValid
Determines whether the givenStringis a valid printable ASCII string with a length not exceedMAX_LENGTHcharacters.- Parameters:
name- the name to be validated.- Returns:
- whether the name is valid.
-
isValidAndNotEmpty
Determines whether the givenStringis a valid printable ASCII string with a length greater than 0 and not exceedMAX_LENGTHcharacters.- Parameters:
name- the name to be validated.- Returns:
- whether the name is valid.
-