Skip to content

Commit ad0e6e3

Browse files
committed
Add display_name and builder
1 parent 2c3eabf commit ad0e6e3

File tree

10 files changed

+154
-62
lines changed

10 files changed

+154
-62
lines changed

docs/instrumentation-list.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
libraries:
66
activej:
77
- name: activej-http-6.0
8+
display_name: ActiveJ
89
description: This instrumentation enables HTTP server spans and HTTP server metrics
910
for the ActiveJ HTTP server.
1011
library_link: https://activej.io/
@@ -60,6 +61,7 @@ libraries:
6061
type: STRING
6162
akka:
6263
- name: akka-actor-2.3
64+
display_name: Akka Actors
6365
description: This instrumentation provides context propagation for Akka actors,
6466
it does not emit any telemetry on its own.
6567
library_link: https://doc.akka.io/libraries/akka-core/current/typed/index.html
@@ -72,6 +74,7 @@ libraries:
7274
- com.typesafe.akka:akka-actor_2.12:[2.3,)
7375
- com.typesafe.akka:akka-actor_2.13:[2.3,)
7476
- name: akka-actor-fork-join-2.5
77+
display_name: Akka Actors
7578
description: This instrumentation provides context propagation for the Akka Fork-Join
7679
Pool, it does not emit any telemetry on its own.
7780
library_link: https://doc.akka.io/libraries/akka-core/current/typed/index.html
@@ -84,6 +87,7 @@ libraries:
8487
- com.typesafe.akka:akka-actor_2.13:[2.5.23,2.6)
8588
- com.typesafe.akka:akka-actor_2.11:[2.5,)
8689
- name: akka-http-10.0
90+
display_name: Akka HTTP
8791
description: |
8892
This instrumentation enables HTTP client spans and metrics for the Akka HTTP client, and HTTP server spans and metrics for the Akka HTTP server.
8993
library_link: https://doc.akka.io/docs/akka-http/current/index.html

instrumentation-docs/src/main/java/io/opentelemetry/instrumentation/docs/InstrumentationAnalyzer.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import com.fasterxml.jackson.core.JsonProcessingException;
99
import com.fasterxml.jackson.databind.exc.MismatchedInputException;
1010
import com.fasterxml.jackson.databind.exc.ValueInstantiationException;
11-
import io.opentelemetry.instrumentation.docs.internal.InstrumentationMetaData;
11+
import io.opentelemetry.instrumentation.docs.internal.InstrumentationMetadata;
1212
import io.opentelemetry.instrumentation.docs.internal.InstrumentationModule;
1313
import io.opentelemetry.instrumentation.docs.internal.InstrumentationType;
1414
import io.opentelemetry.instrumentation.docs.parsers.GradleParser;
@@ -58,7 +58,7 @@ public List<InstrumentationModule> analyze() throws IOException {
5858
}
5959

6060
private void enrichModule(InstrumentationModule module) throws IOException {
61-
InstrumentationMetaData metaData = getMetadata(module);
61+
InstrumentationMetadata metaData = getMetadata(module);
6262
if (metaData != null) {
6363
module.setMetadata(metaData);
6464
}
@@ -69,7 +69,7 @@ private void enrichModule(InstrumentationModule module) throws IOException {
6969
}
7070

7171
@Nullable
72-
private InstrumentationMetaData getMetadata(InstrumentationModule module)
72+
private InstrumentationMetadata getMetadata(InstrumentationModule module)
7373
throws JsonProcessingException {
7474
String metadataFile = fileManager.getMetaDataFile(module.getSrcPath());
7575
if (metadataFile == null) {
Lines changed: 82 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
package io.opentelemetry.instrumentation.docs.internal;
77

88
import com.fasterxml.jackson.annotation.JsonProperty;
9+
import com.google.errorprone.annotations.CanIgnoreReturnValue;
910
import java.util.Collections;
1011
import java.util.List;
1112
import java.util.Objects;
@@ -16,7 +17,7 @@
1617
* Represents the data in a metadata.yaml file. This class is internal and is hence not for public
1718
* use. Its APIs are unstable and can change at any time.
1819
*/
19-
public class InstrumentationMetaData {
20+
public class InstrumentationMetadata {
2021
@Nullable private String description;
2122

2223
@JsonProperty("disabled_by_default")
@@ -29,22 +30,28 @@ public class InstrumentationMetaData {
2930
@Nullable
3031
private String libraryLink;
3132

33+
@JsonProperty("display_name")
34+
@Nullable
35+
private String displayName;
36+
3237
private List<ConfigurationOption> configurations = Collections.emptyList();
3338

34-
public InstrumentationMetaData() {
39+
public InstrumentationMetadata() {
3540
this.classification = InstrumentationClassification.LIBRARY.toString();
3641
}
3742

38-
public InstrumentationMetaData(
43+
public InstrumentationMetadata(
3944
@Nullable String description,
40-
String classification,
4145
@Nullable Boolean disabledByDefault,
46+
String classification,
4247
@Nullable String libraryLink,
48+
@Nullable String displayName,
4349
@Nullable List<ConfigurationOption> configurations) {
4450
this.classification = classification;
4551
this.disabledByDefault = disabledByDefault;
4652
this.description = description;
4753
this.libraryLink = libraryLink;
54+
this.displayName = displayName;
4855
this.configurations = Objects.requireNonNullElse(configurations, Collections.emptyList());
4956
}
5057

@@ -53,6 +60,15 @@ public String getDescription() {
5360
return description;
5461
}
5562

63+
public void setDisplayName(@Nullable String displayName) {
64+
this.displayName = displayName;
65+
}
66+
67+
@Nullable
68+
public String getDisplayName() {
69+
return displayName;
70+
}
71+
5672
@Nonnull
5773
public InstrumentationClassification getClassification() {
5874
return Objects.requireNonNullElse(
@@ -92,4 +108,66 @@ public String getLibraryLink() {
92108
public void setLibraryLink(@Nullable String libraryLink) {
93109
this.libraryLink = libraryLink;
94110
}
111+
112+
/**
113+
* This class is internal and is hence not for public use. Its APIs are unstable and can change at
114+
* any time.
115+
*/
116+
public static class Builder {
117+
118+
@Nullable private String description;
119+
@Nullable private Boolean disabledByDefault;
120+
@Nullable private String classification;
121+
@Nullable private String libraryLink;
122+
@Nullable private String displayName;
123+
private List<ConfigurationOption> configurations = Collections.emptyList();
124+
125+
@CanIgnoreReturnValue
126+
public Builder description(@Nullable String description) {
127+
this.description = description;
128+
return this;
129+
}
130+
131+
@CanIgnoreReturnValue
132+
public Builder disabledByDefault(@Nullable Boolean disabledByDefault) {
133+
this.disabledByDefault = disabledByDefault;
134+
return this;
135+
}
136+
137+
@CanIgnoreReturnValue
138+
public Builder classification(@Nullable String classification) {
139+
this.classification = classification;
140+
return this;
141+
}
142+
143+
@CanIgnoreReturnValue
144+
public Builder libraryLink(@Nullable String libraryLink) {
145+
this.libraryLink = libraryLink;
146+
return this;
147+
}
148+
149+
@CanIgnoreReturnValue
150+
public Builder displayName(@Nullable String displayName) {
151+
this.displayName = displayName;
152+
return this;
153+
}
154+
155+
@CanIgnoreReturnValue
156+
public Builder configurations(@Nullable List<ConfigurationOption> configurations) {
157+
this.configurations = Objects.requireNonNullElse(configurations, Collections.emptyList());
158+
return this;
159+
}
160+
161+
public InstrumentationMetadata build() {
162+
return new InstrumentationMetadata(
163+
description,
164+
disabledByDefault,
165+
classification != null
166+
? classification
167+
: InstrumentationClassification.LIBRARY.toString(),
168+
libraryLink,
169+
displayName,
170+
configurations);
171+
}
172+
}
95173
}

instrumentation-docs/src/main/java/io/opentelemetry/instrumentation/docs/internal/InstrumentationModule.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public class InstrumentationModule {
3535

3636
@Nullable private Integer minJavaVersion;
3737

38-
@Nullable private InstrumentationMetaData metadata;
38+
@Nullable private InstrumentationMetadata metadata;
3939

4040
/**
4141
* This class is internal and is hence not for public use. Its APIs are unstable and can change at
@@ -79,9 +79,9 @@ public InstrumentationScopeInfo getScopeInfo() {
7979
return scopeInfo;
8080
}
8181

82-
public InstrumentationMetaData getMetadata() {
82+
public InstrumentationMetadata getMetadata() {
8383
if (metadata == null) {
84-
metadata = new InstrumentationMetaData();
84+
metadata = new InstrumentationMetadata();
8585
}
8686

8787
return metadata;
@@ -109,7 +109,7 @@ public void setTargetVersions(Map<InstrumentationType, Set<String>> targetVersio
109109
this.targetVersions = targetVersions;
110110
}
111111

112-
public void setMetadata(InstrumentationMetaData metadata) {
112+
public void setMetadata(InstrumentationMetadata metadata) {
113113
this.metadata = metadata;
114114
}
115115

@@ -135,7 +135,7 @@ public static class Builder {
135135
@Nullable private String namespace;
136136
@Nullable private String group;
137137
@Nullable private Integer minJavaVersion;
138-
@Nullable private InstrumentationMetaData metadata;
138+
@Nullable private InstrumentationMetadata metadata;
139139
@Nullable private Map<InstrumentationType, Set<String>> targetVersions;
140140
@Nullable private Map<String, List<EmittedMetrics.Metric>> metrics;
141141
@Nullable private Map<String, List<EmittedSpans.Span>> spans;
@@ -171,7 +171,7 @@ public Builder group(String group) {
171171
}
172172

173173
@CanIgnoreReturnValue
174-
public Builder metadata(InstrumentationMetaData metadata) {
174+
public Builder metadata(InstrumentationMetadata metadata) {
175175
this.metadata = metadata;
176176
return this;
177177
}

instrumentation-docs/src/main/java/io/opentelemetry/instrumentation/docs/utils/YamlHelper.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import io.opentelemetry.instrumentation.docs.internal.EmittedMetrics;
1414
import io.opentelemetry.instrumentation.docs.internal.EmittedSpans;
1515
import io.opentelemetry.instrumentation.docs.internal.InstrumentationClassification;
16-
import io.opentelemetry.instrumentation.docs.internal.InstrumentationMetaData;
16+
import io.opentelemetry.instrumentation.docs.internal.InstrumentationMetadata;
1717
import io.opentelemetry.instrumentation.docs.internal.InstrumentationModule;
1818
import io.opentelemetry.instrumentation.docs.internal.TelemetryAttribute;
1919
import java.io.BufferedWriter;
@@ -195,6 +195,9 @@ private static Map<String, Object> baseProperties(InstrumentationModule module)
195195
private static void addMetadataProperties(
196196
InstrumentationModule module, Map<String, Object> moduleMap) {
197197
if (module.getMetadata() != null) {
198+
if (module.getMetadata().getDisplayName() != null) {
199+
moduleMap.put("display_name", module.getMetadata().getDisplayName());
200+
}
198201
if (module.getMetadata().getDescription() != null) {
199202
moduleMap.put("description", module.getMetadata().getDescription());
200203
}
@@ -290,9 +293,9 @@ private static Map<String, Object> getSpanMap(EmittedSpans.Span span) {
290293
return innerMetricMap;
291294
}
292295

293-
public static InstrumentationMetaData metaDataParser(String input)
296+
public static InstrumentationMetadata metaDataParser(String input)
294297
throws JsonProcessingException {
295-
return mapper.readValue(input, InstrumentationMetaData.class);
298+
return mapper.readValue(input, InstrumentationMetadata.class);
296299
}
297300

298301
public static EmittedMetrics emittedMetricsParser(String input) throws JsonProcessingException {

0 commit comments

Comments
 (0)