Class Resource


  • @Immutable
    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.
    • Method Detail

      • getEmpty

        public static Resource getEmpty()
        Returns an empty Resource.
        Returns:
        an empty Resource.
      • getTelemetrySdk

        public static Resource getTelemetrySdk()
        Returns the telemetry sdk Resource.
        Returns:
        a Resource with telemetry sdk attributes.
      • getAttributes

        public abstract io.opentelemetry.api.common.Attributes getAttributes()
        Returns a map of attributes that describe the resource.
        Returns:
        a map of attributes.
      • hashCode

        @Memoized
        public abstract int hashCode()
        Overrides:
        hashCode in class Object
      • create

        public static Resource create​(io.opentelemetry.api.common.Attributes attributes)
        Returns a Resource.
        Parameters:
        attributes - a map of attributes that describe the resource.
        Returns:
        a Resource.
        Throws:
        NullPointerException - if attributes is null.
        IllegalArgumentException - if attribute key or attribute value is not a valid printable ASCII string or exceed MAX_LENGTH characters.
      • getDefault

        public static Resource getDefault()
        Returns a Resource. This resource information is loaded from the OTEL_RESOURCE_ATTRIBUTES environment variable or otel.resource.attributes system properties.
        Returns:
        a Resource.
      • merge

        public Resource merge​(@Nullable
                              Resource other)
        Returns a new, merged Resource by merging the current Resource with the other Resource. In case of a collision, current Resource takes precedence.
        Parameters:
        other - the Resource that will be merged with this.
        Returns:
        the newly merged Resource.