Skip to content

Commit 518b137

Browse files
authored
Add display_name support to metadata (#14653)
1 parent f44456e commit 518b137

File tree

11 files changed

+244
-153
lines changed

11 files changed

+244
-153
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) {

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

Lines changed: 0 additions & 95 deletions
This file was deleted.
Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
/*
2+
* Copyright The OpenTelemetry Authors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package io.opentelemetry.instrumentation.docs.internal;
7+
8+
import static java.util.Collections.emptyList;
9+
10+
import com.fasterxml.jackson.annotation.JsonProperty;
11+
import com.google.errorprone.annotations.CanIgnoreReturnValue;
12+
import java.util.List;
13+
import java.util.Objects;
14+
import javax.annotation.Nonnull;
15+
import javax.annotation.Nullable;
16+
17+
/**
18+
* Represents the data in a metadata.yaml file. This class is internal and is hence not for public
19+
* use. Its APIs are unstable and can change at any time.
20+
*/
21+
public class InstrumentationMetadata {
22+
@Nullable private String description;
23+
24+
@JsonProperty("disabled_by_default")
25+
@Nullable
26+
private Boolean disabledByDefault;
27+
28+
private String classification;
29+
30+
@JsonProperty("library_link")
31+
@Nullable
32+
private String libraryLink;
33+
34+
@JsonProperty("display_name")
35+
@Nullable
36+
private String displayName;
37+
38+
private List<ConfigurationOption> configurations = emptyList();
39+
40+
public InstrumentationMetadata() {
41+
this.classification = InstrumentationClassification.LIBRARY.name();
42+
}
43+
44+
public InstrumentationMetadata(
45+
@Nullable String description,
46+
@Nullable Boolean disabledByDefault,
47+
String classification,
48+
@Nullable String libraryLink,
49+
@Nullable String displayName,
50+
@Nullable List<ConfigurationOption> configurations) {
51+
this.classification = classification;
52+
this.disabledByDefault = disabledByDefault;
53+
this.description = description;
54+
this.libraryLink = libraryLink;
55+
this.displayName = displayName;
56+
this.configurations = Objects.requireNonNullElse(configurations, emptyList());
57+
}
58+
59+
@Nullable
60+
public String getDescription() {
61+
return description;
62+
}
63+
64+
public void setDisplayName(@Nullable String displayName) {
65+
this.displayName = displayName;
66+
}
67+
68+
@Nullable
69+
public String getDisplayName() {
70+
return displayName;
71+
}
72+
73+
@Nonnull
74+
public InstrumentationClassification getClassification() {
75+
return Objects.requireNonNullElse(
76+
InstrumentationClassification.fromString(classification),
77+
InstrumentationClassification.LIBRARY);
78+
}
79+
80+
public Boolean getDisabledByDefault() {
81+
return Objects.requireNonNullElse(disabledByDefault, false);
82+
}
83+
84+
public void setDescription(@Nullable String description) {
85+
this.description = description;
86+
}
87+
88+
public void setClassification(String classification) {
89+
this.classification = classification;
90+
}
91+
92+
public void setDisabledByDefault(@Nullable Boolean disabledByDefault) {
93+
this.disabledByDefault = disabledByDefault;
94+
}
95+
96+
public List<ConfigurationOption> getConfigurations() {
97+
return configurations;
98+
}
99+
100+
public void setConfigurations(@Nullable List<ConfigurationOption> configurations) {
101+
this.configurations = Objects.requireNonNullElse(configurations, emptyList());
102+
}
103+
104+
@Nullable
105+
public String getLibraryLink() {
106+
return libraryLink;
107+
}
108+
109+
public void setLibraryLink(@Nullable String libraryLink) {
110+
this.libraryLink = libraryLink;
111+
}
112+
113+
/**
114+
* This class is internal and is hence not for public use. Its APIs are unstable and can change at
115+
* any time.
116+
*/
117+
public static class Builder {
118+
119+
@Nullable private String description;
120+
@Nullable private Boolean disabledByDefault;
121+
@Nullable private String classification;
122+
@Nullable private String libraryLink;
123+
@Nullable private String displayName;
124+
private List<ConfigurationOption> configurations = emptyList();
125+
126+
@CanIgnoreReturnValue
127+
public Builder description(@Nullable String description) {
128+
this.description = description;
129+
return this;
130+
}
131+
132+
@CanIgnoreReturnValue
133+
public Builder disabledByDefault(@Nullable Boolean disabledByDefault) {
134+
this.disabledByDefault = disabledByDefault;
135+
return this;
136+
}
137+
138+
@CanIgnoreReturnValue
139+
public Builder classification(@Nullable String classification) {
140+
this.classification = classification;
141+
return this;
142+
}
143+
144+
@CanIgnoreReturnValue
145+
public Builder libraryLink(@Nullable String libraryLink) {
146+
this.libraryLink = libraryLink;
147+
return this;
148+
}
149+
150+
@CanIgnoreReturnValue
151+
public Builder displayName(@Nullable String displayName) {
152+
this.displayName = displayName;
153+
return this;
154+
}
155+
156+
@CanIgnoreReturnValue
157+
public Builder configurations(@Nullable List<ConfigurationOption> configurations) {
158+
this.configurations = Objects.requireNonNullElse(configurations, emptyList());
159+
return this;
160+
}
161+
162+
public InstrumentationMetadata build() {
163+
return new InstrumentationMetadata(
164+
description,
165+
disabledByDefault,
166+
classification != null ? classification : InstrumentationClassification.LIBRARY.name(),
167+
libraryLink,
168+
displayName,
169+
configurations);
170+
}
171+
}
172+
}

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
}

0 commit comments

Comments
 (0)