Class ResourceBuilder


  • public class ResourceBuilder
    extends java.lang.Object
    A builder of Resource that allows to add key-value pairs and copy attributes from other Attributes or Resource.
    Since:
    1.1.0
    • Field Detail

      • schemaUrl

        @Nullable
        private java.lang.String schemaUrl
    • Constructor Detail

      • ResourceBuilder

        public ResourceBuilder()
    • Method Detail

      • put

        public ResourceBuilder put​(java.lang.String key,
                                   java.lang.String value)
        Puts a String attribute into this.

        Note: It is strongly recommended to use put(AttributeKey, Object), and pre-allocate your keys, if possible.

        Returns:
        this Builder
      • put

        public ResourceBuilder put​(java.lang.String key,
                                   long value)
        Puts a long attribute into this.

        Note: It is strongly recommended to use put(AttributeKey, Object), and pre-allocate your keys, if possible.

        Returns:
        this Builder
      • put

        public ResourceBuilder put​(java.lang.String key,
                                   double value)
        Puts a double attribute into this.

        Note: It is strongly recommended to use put(AttributeKey, Object), and pre-allocate your keys, if possible.

        Returns:
        this Builder
      • put

        public ResourceBuilder put​(java.lang.String key,
                                   boolean value)
        Puts a boolean attribute into this.

        Note: It is strongly recommended to use put(AttributeKey, Object), and pre-allocate your keys, if possible.

        Returns:
        this Builder
      • put

        public ResourceBuilder put​(java.lang.String key,
                                   java.lang.String... values)
        Puts a String array attribute into this.

        Note: It is strongly recommended to use put(AttributeKey, Object), and pre-allocate your keys, if possible.

        Returns:
        this Builder
      • put

        public ResourceBuilder put​(java.lang.String key,
                                   long... values)
        Puts a Long array attribute into this.

        Note: It is strongly recommended to use put(AttributeKey, Object), and pre-allocate your keys, if possible.

        Returns:
        this Builder
      • put

        public ResourceBuilder put​(java.lang.String key,
                                   double... values)
        Puts a Double array attribute into this.

        Note: It is strongly recommended to use put(AttributeKey, Object), and pre-allocate your keys, if possible.

        Returns:
        this Builder
      • put

        public ResourceBuilder put​(java.lang.String key,
                                   boolean... values)
        Puts a Boolean array attribute into this.

        Note: It is strongly recommended to use put(AttributeKey, Object), and pre-allocate your keys, if possible.

        Returns:
        this Builder
      • setSchemaUrl

        public ResourceBuilder setSchemaUrl​(java.lang.String schemaUrl)
        Assign an OpenTelemetry schema URL to the resulting Resource.
        Parameters:
        schemaUrl - The URL of the OpenTelemetry schema being used to create this Resource.
        Returns:
        this
        Since:
        1.4.0