Package io.opentelemetry.sdk.resources
Class Resource
- java.lang.Object
-
- io.opentelemetry.sdk.resources.Resource
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static Resource
create(io.opentelemetry.api.common.Attributes attributes)
Returns aResource
.static Resource
empty()
Returns an emptyResource
.abstract io.opentelemetry.api.common.Attributes
getAttributes()
Returns a map of attributes that describe the resource.static Resource
getDefault()
Returns the defaultResource
.abstract int
hashCode()
Resource
merge(Resource other)
-
-
-
Method Detail
-
getDefault
public static Resource getDefault()
Returns the defaultResource
. This resource contains the default attributes provided by the SDK.- Returns:
- a
Resource
.
-
empty
public static Resource empty()
Returns an emptyResource
. When creating aResource
, it is strongly recommended to start withgetDefault()
instead of this method to include SDK required attributes.- Returns:
- an empty
Resource
.
-
create
public static Resource create(io.opentelemetry.api.common.Attributes attributes)
Returns aResource
.- Parameters:
attributes
- a map of attributes that describe the resource.- Returns:
- a
Resource
. - Throws:
NullPointerException
- ifattributes
is null.IllegalArgumentException
- if attribute key or attribute value is not a valid printable ASCII string or exceedMAX_LENGTH
characters.
-
getAttributes
public abstract io.opentelemetry.api.common.Attributes getAttributes()
Returns a map of attributes that describe the resource.- Returns:
- a map of attributes.
-
merge
public Resource merge(@Nullable Resource other)
Returns a new, mergedResource
by merging the currentResource
with theother
Resource
. In case of a collision, the "other"Resource
takes precedence.- Parameters:
other
- theResource
that will be merged withthis
.- Returns:
- the newly merged
Resource
.
-
-