@Immutable @ExperimentalApi public abstract class Resource extends Object
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.| Modifier and Type | Method and Description |
|---|---|
static Resource |
create(String type,
Map<String,String> labels)
Returns a
Resource. |
static Resource |
createFromEnvironmentVariables()
Returns a
Resource. |
abstract Map<String,String> |
getLabels()
Returns a map of labels that describe the resource.
|
abstract String |
getType()
Returns the type identifier for the resource.
|
static Resource |
mergeResources(List<Resource> resources)
Returns a
Resource that runs all input resources sequentially and merges their results. |
@Nullable public abstract String getType()
public abstract Map<String,String> getLabels()
public static Resource createFromEnvironmentVariables()
Resource. This resource information is loaded from the OC_RESOURCE_TYPE and
OC_RESOURCE_LABELS environment variables.Resource.public static Resource create(@Nullable String type, Map<String,String> labels)
Resource.type - the type identifier for the resource.labels - a map of labels that describe the resource.Resource.NullPointerException - if labels is null.IllegalArgumentException - if type or label key or label value is not a valid printable
ASCII string or exceed MAX_LENGTH characters.@Nullable public static Resource mergeResources(List<Resource> resources)
Resource that 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.resources - a list of resources.Resource.