From d7692a21c12d9cd83201c8020b9a1b03f70d584f Mon Sep 17 00:00:00 2001 From: Piotr Glazar Date: Fri, 26 Mar 2021 15:03:32 +0100 Subject: [PATCH 1/7] Resource.Builder for convenient work with Resource class --- .../thrift/JaegerThriftIntegrationTest.java | 8 +- .../jaeger/JaegerIntegrationTest.java | 8 +- .../JaegerExporterIntegrationTest.java | 8 +- .../opentelemetry/sdk/resources/Resource.java | 79 +++++++++++++++++++ .../sdk/resources/ResourceTest.java | 29 +++++++ 5 files changed, 117 insertions(+), 15 deletions(-) diff --git a/exporters/jaeger-thrift/src/test/java/io/opentelemetry/exporter/jaeger/thrift/JaegerThriftIntegrationTest.java b/exporters/jaeger-thrift/src/test/java/io/opentelemetry/exporter/jaeger/thrift/JaegerThriftIntegrationTest.java index 5b40088c049..355e92a798e 100644 --- a/exporters/jaeger-thrift/src/test/java/io/opentelemetry/exporter/jaeger/thrift/JaegerThriftIntegrationTest.java +++ b/exporters/jaeger-thrift/src/test/java/io/opentelemetry/exporter/jaeger/thrift/JaegerThriftIntegrationTest.java @@ -8,7 +8,6 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import io.opentelemetry.api.OpenTelemetry; -import io.opentelemetry.api.common.Attributes; import io.opentelemetry.api.trace.Span; import io.opentelemetry.sdk.OpenTelemetrySdk; import io.opentelemetry.sdk.resources.Resource; @@ -67,10 +66,9 @@ private static OpenTelemetry initOpenTelemetry() { SdkTracerProvider.builder() .addSpanProcessor(SimpleSpanProcessor.create(jaegerExporter)) .setResource( - Resource.getDefault() - .merge( - Resource.create( - Attributes.of(ResourceAttributes.SERVICE_NAME, SERVICE_NAME)))) + Resource.getDefault().toBuilder() + .put(ResourceAttributes.SERVICE_NAME, SERVICE_NAME) + .build()) .build()) .build(); } diff --git a/exporters/jaeger/src/test/java/io/opentelemetry/exporter/jaeger/JaegerIntegrationTest.java b/exporters/jaeger/src/test/java/io/opentelemetry/exporter/jaeger/JaegerIntegrationTest.java index f104e8d8aa8..906297798fb 100644 --- a/exporters/jaeger/src/test/java/io/opentelemetry/exporter/jaeger/JaegerIntegrationTest.java +++ b/exporters/jaeger/src/test/java/io/opentelemetry/exporter/jaeger/JaegerIntegrationTest.java @@ -10,7 +10,6 @@ import io.grpc.ManagedChannel; import io.grpc.ManagedChannelBuilder; import io.opentelemetry.api.OpenTelemetry; -import io.opentelemetry.api.common.Attributes; import io.opentelemetry.api.trace.Span; import io.opentelemetry.sdk.OpenTelemetrySdk; import io.opentelemetry.sdk.resources.Resource; @@ -71,10 +70,9 @@ private static OpenTelemetry initOpenTelemetry() { SdkTracerProvider.builder() .addSpanProcessor(SimpleSpanProcessor.create(jaegerExporter)) .setResource( - Resource.getDefault() - .merge( - Resource.create( - Attributes.of(ResourceAttributes.SERVICE_NAME, SERVICE_NAME)))) + Resource.getDefault().toBuilder() + .put(ResourceAttributes.SERVICE_NAME, SERVICE_NAME) + .build()) .build()) .build(); } diff --git a/integration-tests/src/test/java/io/opentelemetry/JaegerExporterIntegrationTest.java b/integration-tests/src/test/java/io/opentelemetry/JaegerExporterIntegrationTest.java index fba6d8886a6..ffccc5ea235 100644 --- a/integration-tests/src/test/java/io/opentelemetry/JaegerExporterIntegrationTest.java +++ b/integration-tests/src/test/java/io/opentelemetry/JaegerExporterIntegrationTest.java @@ -117,11 +117,9 @@ private static OpenTelemetry initOpenTelemetry(String ip, int port) { SdkTracerProvider.builder() .addSpanProcessor(SimpleSpanProcessor.create(jaegerExporter)) .setResource( - Resource.getDefault() - .merge( - Resource.create( - Attributes.of( - ResourceAttributes.SERVICE_NAME, "integration test")))) + Resource.getDefault().toBuilder() + .put(ResourceAttributes.SERVICE_NAME, "integration test") + .build()) .build()) .buildAndRegisterGlobal(); } diff --git a/sdk/common/src/main/java/io/opentelemetry/sdk/resources/Resource.java b/sdk/common/src/main/java/io/opentelemetry/sdk/resources/Resource.java index 92842db377d..87a4d258029 100644 --- a/sdk/common/src/main/java/io/opentelemetry/sdk/resources/Resource.java +++ b/sdk/common/src/main/java/io/opentelemetry/sdk/resources/Resource.java @@ -168,4 +168,83 @@ private static boolean isValid(String name) { private static boolean isValidAndNotEmpty(AttributeKey name) { return !name.getKey().isEmpty() && isValid(name.getKey()); } + + public static Resource.Builder builder() { + return new Resource.Builder(); + } + + public Builder toBuilder() { + return builder().putAll(this); + } + + public static class Builder { + + private final AttributesBuilder attributesBuilder = Attributes.builder(); + + public Builder put(String key, String value) { + attributesBuilder.put(key, value); + return this; + } + + public Builder put(String key, long value) { + attributesBuilder.put(key, value); + return this; + } + + public Builder put(String key, double value) { + attributesBuilder.put(key, value); + return this; + } + + public Builder put(String key, boolean value) { + attributesBuilder.put(key, value); + return this; + } + + public Builder put(String key, String... values) { + attributesBuilder.put(key, values); + return this; + } + + public Builder put(String key, long... values) { + attributesBuilder.put(key, values); + return this; + } + + public Builder put(String key, double... values) { + attributesBuilder.put(key, values); + return this; + } + + public Builder put(String key, boolean... values) { + attributesBuilder.put(key, values); + return this; + } + + public Builder put(AttributeKey key, T value) { + attributesBuilder.put(key, value); + return this; + } + + public Builder put(AttributeKey key, int value) { + attributesBuilder.put(key, value); + return this; + } + + public Builder putAll(Attributes attributes) { + attributesBuilder.putAll(attributes); + return this; + } + + public Builder putAll(@Nullable Resource resource) { + if (resource != null) { + attributesBuilder.putAll(resource.getAttributes()); + } + return this; + } + + public Resource build() { + return new AutoValue_Resource(attributesBuilder.build()); + } + } } diff --git a/sdk/common/src/test/java/io/opentelemetry/sdk/resources/ResourceTest.java b/sdk/common/src/test/java/io/opentelemetry/sdk/resources/ResourceTest.java index 4ab07545143..f8d7ae67f39 100644 --- a/sdk/common/src/test/java/io/opentelemetry/sdk/resources/ResourceTest.java +++ b/sdk/common/src/test/java/io/opentelemetry/sdk/resources/ResourceTest.java @@ -193,4 +193,33 @@ void testDefaultResources() { assertThat(attributes.get(ResourceAttributes.TELEMETRY_SDK_LANGUAGE)).isEqualTo("java"); assertThat(attributes.get(ResourceAttributes.TELEMETRY_SDK_VERSION)).isNotNull(); } + + @Test + void shouldBuilderNotFailWithNullResource() { + // given + Resource.Builder builder = Resource.getDefault().toBuilder(); + + // when + builder.putAll((Resource) null); + + // then no exception is thrown + // and + assertThat(builder.build().getAttributes().get(ResourceAttributes.SERVICE_NAME)) + .isEqualTo("unknown_service:java"); + } + + @Test + void shouldBuilderCopyResource() { + // given + Resource.Builder builder = Resource.getDefault().toBuilder(); + + // when + builder.put("dog says what?", "woof"); + + // then + Resource resource = builder.build(); + // yes, it's supposed to be the reference check + assertThat(resource != Resource.getDefault()).isTrue(); + assertThat(resource.getAttributes().get(stringKey("dog says what?"))).isEqualTo("woof"); + } } From 6075859fe6242554ece309e76325114eca6a5b37 Mon Sep 17 00:00:00 2001 From: Piotr Glazar Date: Fri, 26 Mar 2021 15:46:22 +0100 Subject: [PATCH 2/7] Remove unused import --- .../java/io/opentelemetry/JaegerExporterIntegrationTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/integration-tests/src/test/java/io/opentelemetry/JaegerExporterIntegrationTest.java b/integration-tests/src/test/java/io/opentelemetry/JaegerExporterIntegrationTest.java index ffccc5ea235..277dc47e2cf 100644 --- a/integration-tests/src/test/java/io/opentelemetry/JaegerExporterIntegrationTest.java +++ b/integration-tests/src/test/java/io/opentelemetry/JaegerExporterIntegrationTest.java @@ -10,7 +10,6 @@ import io.grpc.ManagedChannel; import io.grpc.ManagedChannelBuilder; import io.opentelemetry.api.OpenTelemetry; -import io.opentelemetry.api.common.Attributes; import io.opentelemetry.api.trace.Span; import io.opentelemetry.exporter.jaeger.JaegerGrpcSpanExporter; import io.opentelemetry.sdk.OpenTelemetrySdk; From 4cd39f54908bf46599c06f83d0e7381f33ef5faa Mon Sep 17 00:00:00 2001 From: Piotr Glazar Date: Fri, 26 Mar 2021 15:57:53 +0100 Subject: [PATCH 3/7] Adding javadoc comment --- .../main/java/io/opentelemetry/sdk/resources/Resource.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sdk/common/src/main/java/io/opentelemetry/sdk/resources/Resource.java b/sdk/common/src/main/java/io/opentelemetry/sdk/resources/Resource.java index 87a4d258029..e2b02f09770 100644 --- a/sdk/common/src/main/java/io/opentelemetry/sdk/resources/Resource.java +++ b/sdk/common/src/main/java/io/opentelemetry/sdk/resources/Resource.java @@ -236,6 +236,11 @@ public Builder putAll(Attributes attributes) { return this; } + /** + * Adds all attributes from given {@link Resource}, if it is not null. + * @param resource {@link Resource} whoose attributes will be copied + * @return this Builder + */ public Builder putAll(@Nullable Resource resource) { if (resource != null) { attributesBuilder.putAll(resource.getAttributes()); From f0d96fa9e2351266dc527455d148286261e94c2b Mon Sep 17 00:00:00 2001 From: Piotr Glazar Date: Fri, 26 Mar 2021 16:08:53 +0100 Subject: [PATCH 4/7] Spotless fix --- .../src/main/java/io/opentelemetry/sdk/resources/Resource.java | 1 + 1 file changed, 1 insertion(+) diff --git a/sdk/common/src/main/java/io/opentelemetry/sdk/resources/Resource.java b/sdk/common/src/main/java/io/opentelemetry/sdk/resources/Resource.java index e2b02f09770..61f8d5283e8 100644 --- a/sdk/common/src/main/java/io/opentelemetry/sdk/resources/Resource.java +++ b/sdk/common/src/main/java/io/opentelemetry/sdk/resources/Resource.java @@ -238,6 +238,7 @@ public Builder putAll(Attributes attributes) { /** * Adds all attributes from given {@link Resource}, if it is not null. + * * @param resource {@link Resource} whoose attributes will be copied * @return this Builder */ From cc40e2957295734cca37060919bb4a35fcd55b0f Mon Sep 17 00:00:00 2001 From: Piotr Glazar Date: Mon, 29 Mar 2021 12:01:33 +0200 Subject: [PATCH 5/7] Code review fixes --- .../opentelemetry/sdk/resources/Resource.java | 83 +-------- .../sdk/resources/ResourceBuilder.java | 173 ++++++++++++++++++ .../sdk/resources/ResourceTest.java | 51 +++++- 3 files changed, 223 insertions(+), 84 deletions(-) create mode 100644 sdk/common/src/main/java/io/opentelemetry/sdk/resources/ResourceBuilder.java diff --git a/sdk/common/src/main/java/io/opentelemetry/sdk/resources/Resource.java b/sdk/common/src/main/java/io/opentelemetry/sdk/resources/Resource.java index 61f8d5283e8..32cfc6e8fb7 100644 --- a/sdk/common/src/main/java/io/opentelemetry/sdk/resources/Resource.java +++ b/sdk/common/src/main/java/io/opentelemetry/sdk/resources/Resource.java @@ -169,88 +169,11 @@ private static boolean isValidAndNotEmpty(AttributeKey name) { return !name.getKey().isEmpty() && isValid(name.getKey()); } - public static Resource.Builder builder() { - return new Resource.Builder(); + public static ResourceBuilder builder() { + return new ResourceBuilder(); } - public Builder toBuilder() { + public ResourceBuilder toBuilder() { return builder().putAll(this); } - - public static class Builder { - - private final AttributesBuilder attributesBuilder = Attributes.builder(); - - public Builder put(String key, String value) { - attributesBuilder.put(key, value); - return this; - } - - public Builder put(String key, long value) { - attributesBuilder.put(key, value); - return this; - } - - public Builder put(String key, double value) { - attributesBuilder.put(key, value); - return this; - } - - public Builder put(String key, boolean value) { - attributesBuilder.put(key, value); - return this; - } - - public Builder put(String key, String... values) { - attributesBuilder.put(key, values); - return this; - } - - public Builder put(String key, long... values) { - attributesBuilder.put(key, values); - return this; - } - - public Builder put(String key, double... values) { - attributesBuilder.put(key, values); - return this; - } - - public Builder put(String key, boolean... values) { - attributesBuilder.put(key, values); - return this; - } - - public Builder put(AttributeKey key, T value) { - attributesBuilder.put(key, value); - return this; - } - - public Builder put(AttributeKey key, int value) { - attributesBuilder.put(key, value); - return this; - } - - public Builder putAll(Attributes attributes) { - attributesBuilder.putAll(attributes); - return this; - } - - /** - * Adds all attributes from given {@link Resource}, if it is not null. - * - * @param resource {@link Resource} whoose attributes will be copied - * @return this Builder - */ - public Builder putAll(@Nullable Resource resource) { - if (resource != null) { - attributesBuilder.putAll(resource.getAttributes()); - } - return this; - } - - public Resource build() { - return new AutoValue_Resource(attributesBuilder.build()); - } - } } diff --git a/sdk/common/src/main/java/io/opentelemetry/sdk/resources/ResourceBuilder.java b/sdk/common/src/main/java/io/opentelemetry/sdk/resources/ResourceBuilder.java new file mode 100644 index 00000000000..7c178739a42 --- /dev/null +++ b/sdk/common/src/main/java/io/opentelemetry/sdk/resources/ResourceBuilder.java @@ -0,0 +1,173 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.sdk.resources; + +import io.opentelemetry.api.common.AttributeKey; +import io.opentelemetry.api.common.Attributes; +import io.opentelemetry.api.common.AttributesBuilder; + +@SuppressWarnings("AutoValueSubclassLeaked") +public class ResourceBuilder { + + private final AttributesBuilder attributesBuilder = Attributes.builder(); + + /** + * Puts a String attribute into this. + * + *

Note: It is strongly recommended to use {@link #put(AttributeKey, Object)}, and pre-allocate + * your keys, if possible. + * + * @return this Builder + */ + public ResourceBuilder put(String key, String value) { + if (key != null && value != null) { + attributesBuilder.put(key, value); + } + return this; + } + + /** + * Puts a long attribute into this. + * + *

Note: It is strongly recommended to use {@link #put(AttributeKey, Object)}, and pre-allocate + * your keys, if possible. + * + * @return this Builder + */ + public ResourceBuilder put(String key, long value) { + if (key != null) { + attributesBuilder.put(key, value); + } + return this; + } + + /** + * Puts a double attribute into this. + * + *

Note: It is strongly recommended to use {@link #put(AttributeKey, Object)}, and pre-allocate + * your keys, if possible. + * + * @return this Builder + */ + public ResourceBuilder put(String key, double value) { + if (key != null) { + attributesBuilder.put(key, value); + } + return this; + } + + /** + * Puts a boolean attribute into this. + * + *

Note: It is strongly recommended to use {@link #put(AttributeKey, Object)}, and pre-allocate + * your keys, if possible. + * + * @return this Builder + */ + public ResourceBuilder put(String key, boolean value) { + if (key != null) { + attributesBuilder.put(key, value); + } + return this; + } + + /** + * Puts a String array attribute into this. + * + *

Note: It is strongly recommended to use {@link #put(AttributeKey, Object)}, and pre-allocate + * your keys, if possible. + * + * @return this Builder + */ + public ResourceBuilder put(String key, String... values) { + if (key != null && values != null) { + attributesBuilder.put(key, values); + } + return this; + } + + /** + * Puts a Long array attribute into this. + * + *

Note: It is strongly recommended to use {@link #put(AttributeKey, Object)}, and pre-allocate + * your keys, if possible. + * + * @return this Builder + */ + public ResourceBuilder put(String key, long... values) { + if (key != null && values != null) { + attributesBuilder.put(key, values); + } + return this; + } + + /** + * Puts a Double array attribute into this. + * + *

Note: It is strongly recommended to use {@link #put(AttributeKey, Object)}, and pre-allocate + * your keys, if possible. + * + * @return this Builder + */ + public ResourceBuilder put(String key, double... values) { + if (key != null && values != null) { + attributesBuilder.put(key, values); + } + return this; + } + + /** + * Puts a Boolean array attribute into this. + * + *

Note: It is strongly recommended to use {@link #put(AttributeKey, Object)}, and pre-allocate + * your keys, if possible. + * + * @return this Builder + */ + public ResourceBuilder put(String key, boolean... values) { + if (key != null && values != null) { + attributesBuilder.put(key, values); + } + return this; + } + + /** Puts a {@link AttributeKey} with associated value into this. */ + public ResourceBuilder put(AttributeKey key, T value) { + if (key != null && key.getKey() != null && key.getKey().length() > 0 && value != null) { + attributesBuilder.put(key, value); + } + return this; + } + + /** Puts a {@link AttributeKey} with associated value into this. */ + public ResourceBuilder put(AttributeKey key, int value) { + if (key != null && key.getKey() != null) { + attributesBuilder.put(key, value); + } + return this; + } + + /** Puts all {@link Attributes} into this. */ + public ResourceBuilder putAll(Attributes attributes) { + if (attributes != null) { + attributesBuilder.putAll(attributes); + } + return this; + } + + /** Puts all attributes from {@link Resource} into this. */ + public ResourceBuilder putAll(Resource resource) { + if (resource != null) { + attributesBuilder.putAll(resource.getAttributes()); + } + return this; + } + + /** Create the {@link Resource} from this. */ + public Resource build() { + return new AutoValue_Resource(attributesBuilder.build()); + } +} diff --git a/sdk/common/src/test/java/io/opentelemetry/sdk/resources/ResourceTest.java b/sdk/common/src/test/java/io/opentelemetry/sdk/resources/ResourceTest.java index f8d7ae67f39..bfdbae2da76 100644 --- a/sdk/common/src/test/java/io/opentelemetry/sdk/resources/ResourceTest.java +++ b/sdk/common/src/test/java/io/opentelemetry/sdk/resources/ResourceTest.java @@ -197,7 +197,7 @@ void testDefaultResources() { @Test void shouldBuilderNotFailWithNullResource() { // given - Resource.Builder builder = Resource.getDefault().toBuilder(); + ResourceBuilder builder = Resource.getDefault().toBuilder(); // when builder.putAll((Resource) null); @@ -211,15 +211,58 @@ void shouldBuilderNotFailWithNullResource() { @Test void shouldBuilderCopyResource() { // given - Resource.Builder builder = Resource.getDefault().toBuilder(); + ResourceBuilder builder = Resource.getDefault().toBuilder(); // when builder.put("dog says what?", "woof"); // then Resource resource = builder.build(); - // yes, it's supposed to be the reference check - assertThat(resource != Resource.getDefault()).isTrue(); + assertThat(resource).isNotSameAs(Resource.getDefault()); assertThat(resource.getAttributes().get(stringKey("dog says what?"))).isEqualTo("woof"); } + + @Test + void shouldBuilderHelperMethodsBuildResource() { + // given + ResourceBuilder builder = Resource.getDefault().toBuilder(); + Attributes sourceAttributes = Attributes.of(stringKey("hello"), "world"); + Resource source = Resource.create(sourceAttributes); + Attributes sourceAttributes2 = Attributes.of(stringKey("OpenTelemetry"), "Java"); + + // when + Resource resource = + builder + .put("long", 42L) + .put("double", Math.E) + .put("boolean", true) + .put("string", "abc") + .put("long array", 1L, 2L, 3L) + .put("double array", Math.E, Math.PI) + .put("boolean array", true, false) + .put("string array", "first", "second") + .put(longKey("long key"), 4242L) + .put(longKey("int in disguise"), 21) + .putAll(source) + .putAll(sourceAttributes2) + .build(); + + // then + Attributes attributes = resource.getAttributes(); + assertThat(attributes.get(longKey("long"))).isEqualTo(42L); + assertThat(attributes.get(doubleKey("double"))).isEqualTo(Math.E); + assertThat(attributes.get(booleanKey("boolean"))).isEqualTo(true); + assertThat(attributes.get(stringKey("string"))).isEqualTo("abc"); + assertThat(attributes.get(longArrayKey("long array"))).isEqualTo(Arrays.asList(1L, 2L, 3L)); + assertThat(attributes.get(doubleArrayKey("double array"))) + .isEqualTo(Arrays.asList(Math.E, Math.PI)); + assertThat(attributes.get(booleanArrayKey("boolean array"))) + .isEqualTo(Arrays.asList(true, false)); + assertThat(attributes.get(stringArrayKey("string array"))) + .isEqualTo(Arrays.asList("first", "second")); + assertThat(attributes.get(longKey("long key"))).isEqualTo(4242L); + assertThat(attributes.get(longKey("int in disguise"))).isEqualTo(21); + assertThat(attributes.get(stringKey("hello"))).isEqualTo("world"); + assertThat(attributes.get(stringKey("OpenTelemetry"))).isEqualTo("Java"); + } } From be9abc097ce92f4f023f2117f21faa88f98418ef Mon Sep 17 00:00:00 2001 From: Piotr Glazar Date: Tue, 30 Mar 2021 09:19:29 +0200 Subject: [PATCH 6/7] Adding Javadoc --- .../main/java/io/opentelemetry/sdk/resources/Resource.java | 5 +++++ .../java/io/opentelemetry/sdk/resources/ResourceBuilder.java | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/sdk/common/src/main/java/io/opentelemetry/sdk/resources/Resource.java b/sdk/common/src/main/java/io/opentelemetry/sdk/resources/Resource.java index 32cfc6e8fb7..98dbe5558fc 100644 --- a/sdk/common/src/main/java/io/opentelemetry/sdk/resources/Resource.java +++ b/sdk/common/src/main/java/io/opentelemetry/sdk/resources/Resource.java @@ -169,10 +169,15 @@ private static boolean isValidAndNotEmpty(AttributeKey name) { return !name.getKey().isEmpty() && isValid(name.getKey()); } + /** Returns a new {@link ResourceBuilder} instance for creating arbitrary {@link Resource}. */ public static ResourceBuilder builder() { return new ResourceBuilder(); } + /** + * Returns a new {@link ResourceBuilder} instance populated with the data of this {@link + * Resource}. + */ public ResourceBuilder toBuilder() { return builder().putAll(this); } diff --git a/sdk/common/src/main/java/io/opentelemetry/sdk/resources/ResourceBuilder.java b/sdk/common/src/main/java/io/opentelemetry/sdk/resources/ResourceBuilder.java index 7c178739a42..781dd3f3056 100644 --- a/sdk/common/src/main/java/io/opentelemetry/sdk/resources/ResourceBuilder.java +++ b/sdk/common/src/main/java/io/opentelemetry/sdk/resources/ResourceBuilder.java @@ -9,6 +9,10 @@ import io.opentelemetry.api.common.Attributes; import io.opentelemetry.api.common.AttributesBuilder; +/** + * A builder of {@link Resource} that allows to add key-value pairs and copy attributes from other + * {@link Attributes} or {@link Resource}. + */ @SuppressWarnings("AutoValueSubclassLeaked") public class ResourceBuilder { From f82b7efa614f005c661722b577de810af18c1e9b Mon Sep 17 00:00:00 2001 From: Piotr Glazar Date: Wed, 31 Mar 2021 08:37:34 +0200 Subject: [PATCH 7/7] Call Resource.create instead of AutoValue --- .../java/io/opentelemetry/sdk/resources/ResourceBuilder.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sdk/common/src/main/java/io/opentelemetry/sdk/resources/ResourceBuilder.java b/sdk/common/src/main/java/io/opentelemetry/sdk/resources/ResourceBuilder.java index 781dd3f3056..aa4254915a3 100644 --- a/sdk/common/src/main/java/io/opentelemetry/sdk/resources/ResourceBuilder.java +++ b/sdk/common/src/main/java/io/opentelemetry/sdk/resources/ResourceBuilder.java @@ -13,7 +13,6 @@ * A builder of {@link Resource} that allows to add key-value pairs and copy attributes from other * {@link Attributes} or {@link Resource}. */ -@SuppressWarnings("AutoValueSubclassLeaked") public class ResourceBuilder { private final AttributesBuilder attributesBuilder = Attributes.builder(); @@ -172,6 +171,6 @@ public ResourceBuilder putAll(Resource resource) { /** Create the {@link Resource} from this. */ public Resource build() { - return new AutoValue_Resource(attributesBuilder.build()); + return Resource.create(attributesBuilder.build()); } }