Skip to content

Commit 74d1d11

Browse files
committed
enable semconv metadata
1 parent 4595a3a commit 74d1d11

File tree

18 files changed

+202
-0
lines changed

18 files changed

+202
-0
lines changed

docs/contributing/documenting-instrumentation.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ Example:
8484

8585
```yaml
8686
description: "This instrumentation enables..."
87+
semantic_conventions:
88+
- HTTP_CLIENT_SPANS
89+
- DATABASE_CLIENT_SPANS
90+
- JVM_RUNTIME_METRICS
8791
disabled_by_default: true
8892
classification: library
8993
library_link: https://github.com/...
@@ -128,6 +132,32 @@ Some notes when writing descriptions:
128132
* It is not usually necessary to include specific library or framework version numbers in the
129133
description, unless that context is significant in some way.
130134

135+
136+
### Semantic Conventions
137+
138+
If the instrumentation adheres to one or more specific semantic conventions, include a
139+
`semantic_conventions` field with a list of the relevant semantic convention categories.
140+
141+
List of possible options:
142+
143+
* HTTP_CLIENT_SPANS
144+
* HTTP_CLIENT_METRICS
145+
* HTTP_SERVER_SPANS
146+
* HTTP_SERVER_METRICS
147+
* RPC_CLIENT_SPANS
148+
* RPC_CLIENT_METRICS
149+
* RPC_SERVER_SPANS
150+
* RPC_SERVER_METRICS
151+
* MESSAGING_SPANS
152+
* DATABASE_CLIENT_SPANS
153+
* DATABASE_CLIENT_METRICS
154+
* DATABASE_POOL_METRICS
155+
* JVM_RUNTIME_METRICS
156+
* GRAPHQL_SERVER_SPANS
157+
* FAAS_SERVER_SPANS
158+
* GENAI_CLIENT_SPANS
159+
* GENAI_CLIENT_METRIC
160+
131161
### Library Link
132162

133163
For library instrumentations, include a `library_link` field with a URL to the library or framework's

docs/instrumentation-list.yaml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ libraries:
88
display_name: ActiveJ
99
description: This instrumentation enables HTTP server spans and HTTP server metrics
1010
for the ActiveJ HTTP server.
11+
semantic_conventions:
12+
- HTTP_SERVER_SPANS
13+
- HTTP_SERVER_METRICS
1114
library_link: https://activej.io/
1215
source_path: instrumentation/activej-http-6.0
1316
minimum_java_version: 17
@@ -90,6 +93,11 @@ libraries:
9093
display_name: Akka HTTP
9194
description: |
9295
This instrumentation enables HTTP client spans and metrics for the Akka HTTP client, and HTTP server spans and metrics for the Akka HTTP server.
96+
semantic_conventions:
97+
- HTTP_CLIENT_SPANS
98+
- HTTP_CLIENT_METRICS
99+
- HTTP_SERVER_SPANS
100+
- HTTP_SERVER_METRICS
93101
library_link: https://doc.akka.io/docs/akka-http/current/index.html
94102
source_path: instrumentation/akka/akka-http-10.0
95103
scope:
@@ -179,6 +187,8 @@ libraries:
179187
- name: alibaba-druid-1.0
180188
description: |
181189
The Alibaba Druid instrumentation generates database connection pool metrics for druid data sources.
190+
semantic_conventions:
191+
- DATABASE_POOL_METRICS
182192
library_link: https://github.com/alibaba/druid
183193
source_path: instrumentation/alibaba-druid-1.0
184194
scope:
@@ -272,9 +282,12 @@ libraries:
272282
type: STRING
273283
apache:
274284
- name: apache-dbcp-2.0
285+
display_name: Apache DBCP
275286
description: |
276287
This instrumentation enables database connection pools metrics for Apache DBCP.
277288
The instrumentation uses `MBeanRegistration` methods for lifecycle detection, therefore it only activates if the `BasicDataSource` is registered to an `MBeanServer`. If using Spring Boot, this happens automatically as all Spring beans that support JMX registration are automatically registered by default.
289+
semantic_conventions:
290+
- DATABASE_POOL_METRICS
278291
library_link: https://commons.apache.org/proper/commons-dbcp/
279292
source_path: instrumentation/apache-dbcp-2.0
280293
scope:
@@ -352,10 +365,14 @@ libraries:
352365
- name: db.client.connection.pool.name
353366
type: STRING
354367
- name: apache-dubbo-2.7
368+
display_name: Apache Dubbo
355369
description: The Apache Dubbo instrumentation provides RPC client spans and RPC
356370
server spans for Apache Dubbo RPC calls. Each call produces a span named after
357371
the Dubbo method, enriched with standard RPC attributes (system, service, method),
358372
network attributes, and error details if an exception occurs.
373+
semantic_conventions:
374+
- RPC_CLIENT_SPANS
375+
- RPC_SERVER_SPANS
359376
library_link: https://github.com/apache/dubbo/
360377
source_path: instrumentation/apache-dubbo-2.7
361378
scope:
@@ -397,8 +414,12 @@ libraries:
397414
- name: rpc.system
398415
type: STRING
399416
- name: apache-httpasyncclient-4.1
417+
display_name: Apache HttpAsyncClient
400418
description: This instrumentation enables HTTP client spans and HTTP client metrics
401419
for the Apache HttpAsyncClient.
420+
semantic_conventions:
421+
- HTTP_CLIENT_SPANS
422+
- HTTP_CLIENT_METRICS
402423
library_link: https://hc.apache.org/index.html
403424
source_path: instrumentation/apache-httpasyncclient-4.1
404425
scope:
@@ -444,8 +465,12 @@ libraries:
444465
- name: url.full
445466
type: STRING
446467
- name: apache-httpclient-2.0
468+
display_name: Apache HttpClient
447469
description: This instrumentation enables HTTP client spans and HTTP client metrics
448470
for versions 2 and 3 of the Apache HttpClient.
471+
semantic_conventions:
472+
- HTTP_CLIENT_SPANS
473+
- HTTP_CLIENT_METRICS
449474
library_link: https://hc.apache.org/index.html
450475
source_path: instrumentation/apache-httpclient/apache-httpclient-2.0
451476
scope:
@@ -489,8 +514,12 @@ libraries:
489514
- name: url.full
490515
type: STRING
491516
- name: apache-httpclient-4.0
517+
display_name: Apache HttpClient
492518
description: This instrumentation enables HTTP client spans and HTTP client metrics
493519
for version 4 of the Apache HttpClient.
520+
semantic_conventions:
521+
- HTTP_CLIENT_SPANS
522+
- HTTP_CLIENT_METRICS
494523
library_link: https://hc.apache.org/index.html
495524
source_path: instrumentation/apache-httpclient/apache-httpclient-4.0
496525
scope:
@@ -537,8 +566,12 @@ libraries:
537566
- name: url.full
538567
type: STRING
539568
- name: apache-httpclient-4.3
569+
display_name: Apache HttpClient
540570
description: This instrumentation provides a library integration that enables
541571
HTTP client spans and HTTP client metrics for the Apache HttpClient.
572+
semantic_conventions:
573+
- HTTP_CLIENT_SPANS
574+
- HTTP_CLIENT_METRICS
542575
library_link: https://hc.apache.org/index.html
543576
source_path: instrumentation/apache-httpclient/apache-httpclient-4.3
544577
scope:
@@ -586,8 +619,12 @@ libraries:
586619
- name: url.full
587620
type: STRING
588621
- name: apache-httpclient-5.0
622+
display_name: Apache HttpClient
589623
description: This instrumentation enables HTTP client spans and HTTP client metrics
590624
for version 5 of the Apache HttpClient.
625+
semantic_conventions:
626+
- HTTP_CLIENT_SPANS
627+
- HTTP_CLIENT_METRICS
591628
library_link: https://hc.apache.org/index.html
592629
source_path: instrumentation/apache-httpclient/apache-httpclient-5.0
593630
scope:
@@ -633,8 +670,12 @@ libraries:
633670
- name: url.full
634671
type: STRING
635672
- name: apache-httpclient-5.2
673+
display_name: Apache HttpClient
636674
description: This instrumentation provides a library integration that enables
637675
HTTP client spans and HTTP client metrics for the Apache HttpClient.
676+
semantic_conventions:
677+
- HTTP_CLIENT_SPANS
678+
- HTTP_CLIENT_METRICS
638679
library_link: https://hc.apache.org/index.html
639680
source_path: instrumentation/apache-httpclient/apache-httpclient-5.2
640681
scope:

instrumentation-docs/readme.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,26 @@ public class SpringWebInstrumentationModule extends InstrumentationModule
114114
* name
115115
* Identifier for instrumentation module, used to enable/disable
116116
* Configured in `InstrumentationModule` code for each module
117+
* semantic_conventions
118+
* The semantic conventions that the instrumentation module adheres to
119+
* Options are:
120+
* HTTP_CLIENT_SPANS
121+
* HTTP_CLIENT_METRICS
122+
* HTTP_SERVER_SPANS
123+
* HTTP_SERVER_METRICS
124+
* RPC_CLIENT_SPANS
125+
* RPC_CLIENT_METRICS
126+
* RPC_SERVER_SPANS
127+
* RPC_SERVER_METRICS
128+
* MESSAGING_SPANS
129+
* DATABASE_CLIENT_SPANS
130+
* DATABASE_CLIENT_METRICS
131+
* DATABASE_POOL_METRICS
132+
* JVM_RUNTIME_METRICS
133+
* GRAPHQL_SERVER_SPANS
134+
* FAAS_SERVER_SPANS
135+
* GENAI_CLIENT_SPANS
136+
* GENAI_CLIENT_METRIC
117137
* library_link
118138
* URL to the library or framework's main website or documentation, or if those don't exist, the
119139
GitHub repository.
@@ -149,6 +169,10 @@ As of now, the following fields are supported, all of which are optional:
149169

150170
```yaml
151171
description: "This instrumentation enables..." # Description of the instrumentation module
172+
semantic_conventions: # List of semantic conventions the instrumentation adheres to
173+
- HTTP_CLIENT_SPANS
174+
- DATABASE_CLIENT_SPANS
175+
- JVM_RUNTIME_METRICS
152176
disabled_by_default: true # Defaults to `false`
153177
classification: internal # instrumentation classification: library | internal | custom
154178
library_link: https://... # URL to the library or framework's main website or documentation

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ public class InstrumentationMetadata {
3737

3838
private List<ConfigurationOption> configurations = emptyList();
3939

40+
@JsonProperty("semantic_conventions")
41+
private List<SemanticConvention> semanticConventions = emptyList();
42+
4043
public InstrumentationMetadata() {
4144
this.classification = InstrumentationClassification.LIBRARY.name();
4245
}
@@ -47,12 +50,15 @@ public InstrumentationMetadata(
4750
String classification,
4851
@Nullable String libraryLink,
4952
@Nullable String displayName,
53+
@Nullable List<SemanticConvention> semanticConventions,
5054
@Nullable List<ConfigurationOption> configurations) {
5155
this.classification = classification;
5256
this.disabledByDefault = disabledByDefault;
5357
this.description = description;
5458
this.libraryLink = libraryLink;
5559
this.displayName = displayName;
60+
this.semanticConventions = Objects.requireNonNullElse(semanticConventions, emptyList());
61+
;
5662
this.configurations = Objects.requireNonNullElse(configurations, emptyList());
5763
}
5864

@@ -101,6 +107,14 @@ public void setConfigurations(@Nullable List<ConfigurationOption> configurations
101107
this.configurations = Objects.requireNonNullElse(configurations, emptyList());
102108
}
103109

110+
public List<SemanticConvention> getSemanticConventions() {
111+
return semanticConventions;
112+
}
113+
114+
public void setSemanticConventions(@Nullable List<SemanticConvention> semanticConventions) {
115+
this.semanticConventions = Objects.requireNonNullElse(semanticConventions, emptyList());
116+
}
117+
104118
@Nullable
105119
public String getLibraryLink() {
106120
return libraryLink;
@@ -122,6 +136,7 @@ public static class Builder {
122136
@Nullable private String libraryLink;
123137
@Nullable private String displayName;
124138
private List<ConfigurationOption> configurations = emptyList();
139+
private List<SemanticConvention> semanticConventions = emptyList();
125140

126141
@CanIgnoreReturnValue
127142
public Builder description(@Nullable String description) {
@@ -159,13 +174,20 @@ public Builder configurations(@Nullable List<ConfigurationOption> configurations
159174
return this;
160175
}
161176

177+
@CanIgnoreReturnValue
178+
public Builder semanticConventions(@Nullable List<SemanticConvention> semanticConventions) {
179+
this.semanticConventions = Objects.requireNonNullElse(semanticConventions, emptyList());
180+
return this;
181+
}
182+
162183
public InstrumentationMetadata build() {
163184
return new InstrumentationMetadata(
164185
description,
165186
disabledByDefault,
166187
classification != null ? classification : InstrumentationClassification.LIBRARY.name(),
167188
libraryLink,
168189
displayName,
190+
semanticConventions,
169191
configurations);
170192
}
171193
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright The OpenTelemetry Authors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package io.opentelemetry.instrumentation.docs.internal;
7+
8+
/**
9+
* Represents the data in a metadata.yaml file. This class is internal and is hence not for public
10+
* use. Its APIs are unstable and can change at any time.
11+
*/
12+
public enum SemanticConvention {
13+
HTTP_CLIENT_SPANS,
14+
HTTP_CLIENT_METRICS,
15+
HTTP_SERVER_SPANS,
16+
HTTP_SERVER_METRICS,
17+
RPC_CLIENT_SPANS,
18+
RPC_CLIENT_METRICS,
19+
RPC_SERVER_SPANS,
20+
RPC_SERVER_METRICS,
21+
MESSAGING_SPANS,
22+
DATABASE_CLIENT_SPANS,
23+
DATABASE_CLIENT_METRICS,
24+
DATABASE_POOL_METRICS,
25+
JVM_RUNTIME_METRICS,
26+
GRAPHQL_SERVER_SPANS,
27+
FAAS_SERVER_SPANS,
28+
GENAI_CLIENT_SPANS,
29+
GENAI_CLIENT_METRICS
30+
}

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,14 @@ private static void addMetadataProperties(
201201
if (module.getMetadata().getDescription() != null) {
202202
moduleMap.put("description", module.getMetadata().getDescription());
203203
}
204+
if (module.getMetadata().getSemanticConventions() != null
205+
&& !module.getMetadata().getSemanticConventions().isEmpty()) {
206+
List<String> conventionNames =
207+
module.getMetadata().getSemanticConventions().stream()
208+
.map(Enum::name)
209+
.collect(Collectors.toList());
210+
moduleMap.put("semantic_conventions", conventionNames);
211+
}
204212
if (module.getMetadata().getLibraryLink() != null) {
205213
moduleMap.put("library_link", module.getMetadata().getLibraryLink());
206214
}

instrumentation-docs/src/test/java/io/opentelemetry/instrumentation/docs/utils/YamlHelperTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
package io.opentelemetry.instrumentation.docs.utils;
77

8+
import static io.opentelemetry.instrumentation.docs.internal.SemanticConvention.DATABASE_CLIENT_METRICS;
9+
import static io.opentelemetry.instrumentation.docs.internal.SemanticConvention.DATABASE_CLIENT_SPANS;
810
import static java.util.Collections.emptyList;
911
import static org.assertj.core.api.Assertions.assertThat;
1012

@@ -44,6 +46,7 @@ void testPrintInstrumentationList() throws Exception {
4446
.displayName("Spring Web")
4547
.classification(InstrumentationClassification.LIBRARY.name())
4648
.disabledByDefault(true)
49+
.semanticConventions(List.of(DATABASE_CLIENT_METRICS, DATABASE_CLIENT_SPANS))
4750
.build();
4851

4952
modules.add(
@@ -84,6 +87,9 @@ void testPrintInstrumentationList() throws Exception {
8487
- name: spring-web-6.0
8588
display_name: Spring Web
8689
description: Spring Web 6.0 instrumentation
90+
semantic_conventions:
91+
- DATABASE_CLIENT_METRICS
92+
- DATABASE_CLIENT_SPANS
8793
disabled_by_default: true
8894
source_path: instrumentation/spring/spring-web/spring-web-6.0
8995
minimum_java_version: 11
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
display_name: ActiveJ
22
description: This instrumentation enables HTTP server spans and HTTP server metrics for the ActiveJ HTTP server.
33
library_link: https://activej.io/
4+
semantic_conventions:
5+
- HTTP_SERVER_SPANS
6+
- HTTP_SERVER_METRICS

instrumentation/akka/akka-http-10.0/metadata.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,8 @@ description: >
33
This instrumentation enables HTTP client spans and metrics for the Akka HTTP client, and HTTP
44
server spans and metrics for the Akka HTTP server.
55
library_link: https://doc.akka.io/docs/akka-http/current/index.html
6+
semantic_conventions:
7+
- HTTP_CLIENT_SPANS
8+
- HTTP_CLIENT_METRICS
9+
- HTTP_SERVER_SPANS
10+
- HTTP_SERVER_METRICS

instrumentation/alibaba-druid-1.0/metadata.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@ description: >
22
The Alibaba Druid instrumentation generates database connection pool metrics for druid data
33
sources.
44
library_link: https://github.com/alibaba/druid
5+
semantic_conventions:
6+
- DATABASE_POOL_METRICS

0 commit comments

Comments
 (0)