Skip to content

Commit 8b4f48f

Browse files
committed
Fix comments from code review.
1 parent 0ed5fe2 commit 8b4f48f

File tree

8 files changed

+83
-47
lines changed

8 files changed

+83
-47
lines changed
Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,63 @@
11
Comparing source compatibility of opentelemetry-sdk-common-1.45.0-SNAPSHOT.jar against opentelemetry-sdk-common-1.44.1.jar
2-
No changes.
2+
+++ NEW CLASS: PUBLIC(+) FINAL(+) io.opentelemetry.sdk.resources.detectors.ServiceDetector (not serializable)
3+
+++ CLASS FILE FORMAT VERSION: 52.0 <- n.a.
4+
+++ NEW INTERFACE: io.opentelemetry.sdk.resources.EntityDetector
5+
+++ NEW SUPERCLASS: java.lang.Object
6+
+++ NEW FIELD: PUBLIC(+) STATIC(+) FINAL(+) io.opentelemetry.sdk.resources.EntityDetector INSTANCE
7+
+++ NEW METHOD: PUBLIC(+) java.util.List<io.opentelemetry.sdk.resources.Entity> detectEntities()
8+
+++ NEW CLASS: PUBLIC(+) FINAL(+) io.opentelemetry.sdk.resources.detectors.ServiceInstanceDetector (not serializable)
9+
+++ CLASS FILE FORMAT VERSION: 52.0 <- n.a.
10+
+++ NEW INTERFACE: io.opentelemetry.sdk.resources.EntityDetector
11+
+++ NEW SUPERCLASS: java.lang.Object
12+
+++ NEW FIELD: PUBLIC(+) STATIC(+) FINAL(+) io.opentelemetry.sdk.resources.EntityDetector INSTANCE
13+
+++ NEW METHOD: PUBLIC(+) java.util.List<io.opentelemetry.sdk.resources.Entity> detectEntities()
14+
+++ NEW CLASS: PUBLIC(+) FINAL(+) io.opentelemetry.sdk.resources.detectors.TelemetrySdkDetector (not serializable)
15+
+++ CLASS FILE FORMAT VERSION: 52.0 <- n.a.
16+
+++ NEW INTERFACE: io.opentelemetry.sdk.resources.EntityDetector
17+
+++ NEW SUPERCLASS: java.lang.Object
18+
+++ NEW FIELD: PUBLIC(+) STATIC(+) FINAL(+) io.opentelemetry.sdk.resources.detectors.TelemetrySdkDetector INSTANCE
19+
+++ NEW METHOD: PUBLIC(+) java.util.List<io.opentelemetry.sdk.resources.Entity> detectEntities()
20+
+++ NEW CLASS: PUBLIC(+) ABSTRACT(+) io.opentelemetry.sdk.resources.Entity (not serializable)
21+
+++ CLASS FILE FORMAT VERSION: 52.0 <- n.a.
22+
+++ NEW SUPERCLASS: java.lang.Object
23+
+++ NEW CONSTRUCTOR: PUBLIC(+) Entity()
24+
+++ NEW METHOD: PUBLIC(+) STATIC(+) FINAL(+) io.opentelemetry.sdk.resources.EntityBuilder builder(java.lang.String)
25+
+++ NEW METHOD: PUBLIC(+) ABSTRACT(+) io.opentelemetry.api.common.Attributes getAttributes()
26+
+++ NEW METHOD: PUBLIC(+) ABSTRACT(+) io.opentelemetry.api.common.Attributes getIdentifyingAttributes()
27+
+++ NEW METHOD: PUBLIC(+) ABSTRACT(+) java.lang.String getSchemaUrl()
28+
+++ NEW ANNOTATION: javax.annotation.Nullable
29+
+++ NEW METHOD: PUBLIC(+) ABSTRACT(+) java.lang.String getType()
30+
+++ NEW METHOD: PUBLIC(+) FINAL(+) io.opentelemetry.sdk.resources.EntityBuilder toBuilder()
31+
+++ NEW CLASS: PUBLIC(+) io.opentelemetry.sdk.resources.EntityBuilder (not serializable)
32+
+++ CLASS FILE FORMAT VERSION: 52.0 <- n.a.
33+
+++ NEW SUPERCLASS: java.lang.Object
34+
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.sdk.resources.Entity build()
35+
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.sdk.resources.EntityBuilder setSchemaUrl(java.lang.String)
36+
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.sdk.resources.EntityBuilder withDescriptive(java.util.function.Consumer<io.opentelemetry.api.common.AttributesBuilder>)
37+
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.sdk.resources.EntityBuilder withIdentifying(java.util.function.Consumer<io.opentelemetry.api.common.AttributesBuilder>)
38+
+++ NEW INTERFACE: PUBLIC(+) ABSTRACT(+) io.opentelemetry.sdk.resources.EntityDetector (not serializable)
39+
+++ CLASS FILE FORMAT VERSION: 52.0 <- n.a.
40+
+++ NEW SUPERCLASS: java.lang.Object
41+
+++ NEW METHOD: PUBLIC(+) ABSTRACT(+) java.util.List<io.opentelemetry.sdk.resources.Entity> detectEntities()
42+
**** MODIFIED CLASS: PUBLIC ABSTRACT io.opentelemetry.sdk.resources.Resource (not serializable)
43+
=== CLASS FILE FORMAT VERSION: 52.0 <- 52.0
44+
+++ NEW METHOD: PUBLIC(+) STATIC(+) io.opentelemetry.sdk.resources.Resource create(io.opentelemetry.api.common.Attributes, java.lang.String, java.util.Collection<io.opentelemetry.sdk.resources.Entity>)
45+
*** MODIFIED METHOD: PUBLIC NON_ABSTRACT (<- ABSTRACT) io.opentelemetry.api.common.Attributes getAttributes()
46+
+++* NEW METHOD: PUBLIC(+) ABSTRACT(+) java.util.Collection<io.opentelemetry.sdk.resources.Entity> getEntities()
47+
*** MODIFIED CLASS: PUBLIC io.opentelemetry.sdk.resources.ResourceBuilder (not serializable)
48+
=== CLASS FILE FORMAT VERSION: 52.0 <- 52.0
49+
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.sdk.resources.ResourceBuilder add(io.opentelemetry.sdk.resources.Entity)
50+
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.sdk.resources.ResourceBuilder addAll(java.util.Collection<io.opentelemetry.sdk.resources.Entity>)
51+
+++ NEW CLASS: PUBLIC(+) FINAL(+) io.opentelemetry.sdk.resources.ResourceProvider (not serializable)
52+
+++ CLASS FILE FORMAT VERSION: 52.0 <- n.a.
53+
+++ NEW SUPERCLASS: java.lang.Object
54+
+++ NEW METHOD: PUBLIC(+) STATIC(+) io.opentelemetry.sdk.resources.ResourceProviderBuilder builder()
55+
+++ NEW METHOD: PUBLIC(+) FINAL(+) io.opentelemetry.sdk.resources.Resource getResource()
56+
+++ NEW CLASS: PUBLIC(+) FINAL(+) io.opentelemetry.sdk.resources.ResourceProviderBuilder (not serializable)
57+
+++ CLASS FILE FORMAT VERSION: 52.0 <- n.a.
58+
+++ NEW SUPERCLASS: java.lang.Object
59+
+++ NEW CONSTRUCTOR: PUBLIC(+) ResourceProviderBuilder()
60+
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.sdk.resources.ResourceProviderBuilder addDetectedResource(io.opentelemetry.sdk.resources.Resource)
61+
+++ NEW ANNOTATION: java.lang.Deprecated
62+
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.sdk.resources.ResourceProviderBuilder addEntityDetector(io.opentelemetry.sdk.resources.EntityDetector)
63+
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.sdk.resources.ResourceProvider build()

exporters/otlp/common/src/test/java/io/opentelemetry/exporter/internal/otlp/ResourceEntityTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,8 @@ void toJsonResourceWithEntity() throws Exception {
1919
Resource resource =
2020
Resource.builder()
2121
.add(
22-
Entity.builder()
22+
Entity.builder("test")
2323
.setSchemaUrl("http://example.com/1.0")
24-
.setEntityType("test")
2524
.withIdentifying(attr -> attr.put("test.id", 1))
2625
.withDescriptive(attr -> attr.put("test.name", "one"))
2726
.build())

sdk/common/src/main/java/io/opentelemetry/sdk/resources/Entity.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ public abstract class Entity {
4848
public abstract Attributes getAttributes();
4949

5050
/**
51-
* Returns the URL of the OpenTelemetry schema used by this resource. May be null.
51+
* Returns the URL of the OpenTelemetry schema used by this resource. May be null if this entity
52+
* does not abide by schema conventions (i.e. is custom).
5253
*
5354
* @return An OpenTelemetry schema URL.
5455
* @since 1.4.0
@@ -68,7 +69,7 @@ public final EntityBuilder toBuilder() {
6869
return new EntityBuilder(this);
6970
}
7071

71-
public static final EntityBuilder builder() {
72-
return new EntityBuilder();
72+
public static final EntityBuilder builder(String entityType) {
73+
return new EntityBuilder(entityType);
7374
}
7475
}

sdk/common/src/main/java/io/opentelemetry/sdk/resources/EntityBuilder.java

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
import io.opentelemetry.api.common.Attributes;
99
import io.opentelemetry.api.common.AttributesBuilder;
10-
import java.util.Objects;
1110
import java.util.function.Consumer;
1211
import javax.annotation.Nullable;
1312

@@ -16,12 +15,13 @@
1615
* well as type and schema_url.
1716
*/
1817
public class EntityBuilder {
19-
@Nullable private String entityType;
18+
private final String entityType;
2019
private final AttributesBuilder attributesBuilder;
2120
private final AttributesBuilder identifyingBuilder;
2221
@Nullable private String schemaUrl;
2322

24-
EntityBuilder() {
23+
EntityBuilder(String entityType) {
24+
this.entityType = entityType;
2525
this.attributesBuilder = Attributes.builder();
2626
this.identifyingBuilder = Attributes.builder();
2727
}
@@ -44,17 +44,6 @@ public EntityBuilder setSchemaUrl(String schemaUrl) {
4444
return this;
4545
}
4646

47-
/**
48-
* Assign an Entity type to the resulting Entity.
49-
*
50-
* @param entityType The type name of the entity.
51-
* @return this
52-
*/
53-
public EntityBuilder setEntityType(String entityType) {
54-
this.entityType = entityType;
55-
return this;
56-
}
57-
5847
/**
5948
* Modify the descriptive attributes of this Entity.
6049
*
@@ -80,7 +69,6 @@ public EntityBuilder withIdentifying(Consumer<AttributesBuilder> f) {
8069
/** Create the {@link Entity} from this. */
8170
public Entity build() {
8271
// TODO - Better Checks.
83-
Objects.requireNonNull(this.entityType);
8472
return Entity.create(
8573
entityType, identifyingBuilder.build(), attributesBuilder.build(), schemaUrl);
8674
}

sdk/common/src/main/java/io/opentelemetry/sdk/resources/detectors/ServiceDetector.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ private static String getServiceName() {
4444
@Override
4545
public List<Entity> detectEntities() {
4646
return Collections.singletonList(
47-
Entity.builder()
48-
.setEntityType(ENTITY_TYPE)
47+
Entity.builder(ENTITY_TYPE)
4948
.setSchemaUrl(SCHEMA_URL)
5049
.withIdentifying(
5150
builder -> {

sdk/common/src/main/java/io/opentelemetry/sdk/resources/detectors/ServiceInstanceDetector.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ private static String getInstanceId() {
2828
@Override
2929
public List<Entity> detectEntities() {
3030
return Collections.singletonList(
31-
Entity.builder()
32-
.setEntityType(ENTITY_TYPE)
31+
Entity.builder(ENTITY_TYPE)
3332
.setSchemaUrl(SCHEMA_URL)
3433
.withIdentifying(
3534
builder -> {

sdk/common/src/main/java/io/opentelemetry/sdk/resources/detectors/TelemetrySdkDetector.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ public final class TelemetrySdkDetector implements EntityDetector {
2626

2727
static {
2828
TELEMETRY_SDK =
29-
Entity.builder()
30-
.setEntityType(ENTITY_TYPE)
29+
Entity.builder(ENTITY_TYPE)
3130
.setSchemaUrl(SCHEMA_URL)
3231
.withIdentifying(
3332
attributes -> {

sdk/common/src/test/java/io/opentelemetry/sdk/resources/ResourceTest.java

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,7 @@ void testMergeResources_entities_separate_types() {
241241
Resource resource1 =
242242
Resource.builder()
243243
.add(
244-
Entity.builder()
245-
.setEntityType("a")
244+
Entity.builder("a")
246245
.setSchemaUrl("one")
247246
.withIdentifying(
248247
builder -> {
@@ -253,8 +252,7 @@ void testMergeResources_entities_separate_types() {
253252
Resource resource2 =
254253
Resource.builder()
255254
.add(
256-
Entity.builder()
257-
.setEntityType("b")
255+
Entity.builder("b")
258256
.setSchemaUrl("one")
259257
.withIdentifying(
260258
builder -> {
@@ -274,8 +272,7 @@ void testMergeResources_entities_separate_types_and_schema() {
274272
Resource resource1 =
275273
Resource.builder()
276274
.add(
277-
Entity.builder()
278-
.setEntityType("a")
275+
Entity.builder("a")
279276
.setSchemaUrl("one")
280277
.withIdentifying(
281278
builder -> {
@@ -286,8 +283,7 @@ void testMergeResources_entities_separate_types_and_schema() {
286283
Resource resource2 =
287284
Resource.builder()
288285
.add(
289-
Entity.builder()
290-
.setEntityType("b")
286+
Entity.builder("b")
291287
.setSchemaUrl("two")
292288
.withIdentifying(
293289
builder -> {
@@ -307,8 +303,7 @@ void testMergeResources_entities_same_types_and_id() {
307303
Resource resource1 =
308304
Resource.builder()
309305
.add(
310-
Entity.builder()
311-
.setEntityType("a")
306+
Entity.builder("a")
312307
.setSchemaUrl("one")
313308
.withIdentifying(
314309
builder -> {
@@ -323,8 +318,7 @@ void testMergeResources_entities_same_types_and_id() {
323318
Resource resource2 =
324319
Resource.builder()
325320
.add(
326-
Entity.builder()
327-
.setEntityType("a")
321+
Entity.builder("a")
328322
.setSchemaUrl("one")
329323
.withIdentifying(
330324
builder -> {
@@ -349,8 +343,7 @@ void testMergeResources_entity_vs_raw_attribute() {
349343
Resource resource1 =
350344
Resource.builder()
351345
.add(
352-
Entity.builder()
353-
.setEntityType("a")
346+
Entity.builder("a")
354347
.setSchemaUrl("one")
355348
.withIdentifying(
356349
builder -> {
@@ -376,8 +369,7 @@ void testMergeResources_entities_same_types_different_id() {
376369
Resource resource1 =
377370
Resource.builder()
378371
.add(
379-
Entity.builder()
380-
.setEntityType("a")
372+
Entity.builder("a")
381373
.setSchemaUrl("one")
382374
.withIdentifying(
383375
builder -> {
@@ -392,8 +384,7 @@ void testMergeResources_entities_same_types_different_id() {
392384
Resource resource2 =
393385
Resource.builder()
394386
.add(
395-
Entity.builder()
396-
.setEntityType("a")
387+
Entity.builder("a")
397388
.setSchemaUrl("one")
398389
.withIdentifying(
399390
builder -> {
@@ -514,9 +505,8 @@ public void build_withEntities() {
514505
Resource resource =
515506
Resource.builder()
516507
.add(
517-
Entity.builder()
508+
Entity.builder("a")
518509
.setSchemaUrl("http://example.com")
519-
.setEntityType("a")
520510
.withIdentifying(id -> id.put("a", "b"))
521511
.build())
522512
.build();

0 commit comments

Comments
 (0)