Skip to content

Commit 51c5fe4

Browse files
authored
Instrumentation metadata - "features" (#14816)
1 parent 46087e9 commit 51c5fe4

File tree

13 files changed

+120
-81
lines changed

13 files changed

+120
-81
lines changed

docs/contributing/documenting-instrumentation.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ semantic_conventions:
8888
- HTTP_CLIENT_SPANS
8989
- DATABASE_CLIENT_SPANS
9090
- JVM_RUNTIME_METRICS
91+
features:
92+
- HTTP_ROUTE
93+
- CONTEXT_PROPAGATION
9194
disabled_by_default: true
9295
classification: library
9396
library_link: https://github.com/...
@@ -174,6 +177,20 @@ List of possible options:
174177
* [GENAI_CLIENT_SPANS](https://github.com/open-telemetry/semantic-conventions/blob/main/docs/gen-ai/gen-ai-spans.md)
175178
* [GENAI_CLIENT_METRICS](https://github.com/open-telemetry/semantic-conventions/blob/main/docs/gen-ai/gen-ai-metrics.md#generative-ai-client-metrics)
176179

180+
### Features (optional)
181+
182+
As a way to help further categorize instrumentations, you can add a `features` field with a list of
183+
the relevant functionality descriptions.
184+
185+
List of possible options:
186+
187+
* `HTTP_ROUTE`: Instrumentation that enriches HTTP spans with route information
188+
* `EXPERIMENTAL_ONLY`: Instrumentation that is experimental and may not be stable
189+
* `CONTEXT_PROPAGATION`: Instrumentation that provides context propagation capabilities
190+
* `AUTO_INSTRUMENTATION_SHIM`: Instrumentation that adapts or bridges instrumentation from upstream libraries or frameworks
191+
* `CONTROLLER_SPANS`: Instrumentation that generates controller-level spans
192+
* `VIEW_SPANS`: Instrumentation that generates view-level spans
193+
177194
### Library Link
178195

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

docs/instrumentation-list.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ libraries:
7070
description: This instrumentation provides context propagation for Akka actors,
7171
it does not emit any telemetry on its own.
7272
library_link: https://doc.akka.io/libraries/akka-core/current/typed/index.html
73+
features:
74+
- CONTEXT_PROPAGATION
7375
source_path: instrumentation/akka/akka-actor-2.3
7476
scope:
7577
name: io.opentelemetry.akka-actor-2.3
@@ -83,6 +85,8 @@ libraries:
8385
description: This instrumentation provides context propagation for the Akka Fork-Join
8486
Pool, it does not emit any telemetry on its own.
8587
library_link: https://doc.akka.io/libraries/akka-core/current/typed/index.html
88+
features:
89+
- CONTEXT_PROPAGATION
8690
source_path: instrumentation/akka/akka-actor-fork-join-2.5
8791
scope:
8892
name: io.opentelemetry.akka-actor-fork-join-2.5
@@ -101,6 +105,8 @@ libraries:
101105
- HTTP_SERVER_SPANS
102106
- HTTP_SERVER_METRICS
103107
library_link: https://doc.akka.io/docs/akka-http/current/index.html
108+
features:
109+
- HTTP_ROUTE
104110
source_path: instrumentation/akka/akka-http-10.0
105111
scope:
106112
name: io.opentelemetry.akka-http-10.0

instrumentation-docs/instrumentations.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,12 @@ readonly INSTRUMENTATIONS=(
1414
"apache-dbcp-2.0:javaagent:test"
1515
"apache-dbcp-2.0:javaagent:testStableSemconv"
1616
"apache-dubbo-2.7:javaagent:testDubbo"
17-
"apache-dubbo-2.7:javaagent:testDubbo"
1817
"apache-httpasyncclient-4.1:javaagent:test"
1918
"apache-httpclient:apache-httpclient-2.0:javaagent:test"
2019
"apache-httpclient:apache-httpclient-4.0:javaagent:test"
21-
# "apache-httpclient:apache-httpclient-4.3:library:test" # See https://github.com/open-telemetry/opentelemetry-java-instrumentation/issues/14771
20+
"apache-httpclient:apache-httpclient-4.3:library:test"
2221
"apache-httpclient:apache-httpclient-5.0:javaagent:test"
23-
# "apache-httpclient:apache-httpclient-5.2:library:test" # See https://github.com/open-telemetry/opentelemetry-java-instrumentation/issues/14771
22+
"apache-httpclient:apache-httpclient-5.2:library:test"
2423
"armeria:armeria-1.3:javaagent:test"
2524
"armeria:armeria-grpc-1.14:javaagent:test"
2625
"async-http-client:async-http-client-1.9:javaagent:test"

instrumentation-docs/readme.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,15 @@ public class SpringWebInstrumentationModule extends InstrumentationModule
134134
* FAAS_SERVER_SPANS
135135
* GENAI_CLIENT_SPANS
136136
* GENAI_CLIENT_METRIC
137+
* features
138+
* The specific functionality that the instrumentation provides
139+
* Options are:
140+
* HTTP_ROUTE
141+
* EXPERIMENTAL_ONLY
142+
* CONTEXT_PROPAGATION
143+
* AUTO_INSTRUMENTATION_SHIM
144+
* CONTROLLER_SPANS
145+
* VIEW_SPANS
137146
* library_link
138147
* URL to the library or framework's main website or documentation, or if those don't exist, the
139148
GitHub repository.
@@ -173,6 +182,9 @@ semantic_conventions: # List of semantic conventions
173182
- HTTP_CLIENT_SPANS
174183
- DATABASE_CLIENT_SPANS
175184
- JVM_RUNTIME_METRICS
185+
features: # List of features this instrumentation provides
186+
- HTTP_ROUTE
187+
- CONTEXT_PROPAGATION
176188
disabled_by_default: true # Defaults to `false`
177189
classification: internal # instrumentation classification: library | internal | custom
178190
library_link: https://... # URL to the library or framework's main website or documentation
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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 functionality of instrumentations. 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 InstrumentationFeature {
13+
HTTP_ROUTE,
14+
EXPERIMENTAL_ONLY,
15+
CONTEXT_PROPAGATION,
16+
AUTO_INSTRUMENTATION_SHIM,
17+
CONTROLLER_SPANS,
18+
VIEW_SPANS,
19+
}

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ public class InstrumentationMetadata {
4747
@Nullable
4848
private Boolean overrideTelemetry;
4949

50+
private List<InstrumentationFeature> features = emptyList();
51+
5052
public InstrumentationMetadata() {
5153
this.classification = InstrumentationClassification.LIBRARY.name();
5254
}
@@ -147,6 +149,14 @@ public void setOverrideTelemetry(@Nullable Boolean overrideTelemetry) {
147149
this.overrideTelemetry = overrideTelemetry;
148150
}
149151

152+
public List<InstrumentationFeature> getFeatures() {
153+
return features;
154+
}
155+
156+
public void setFeatures(@Nullable List<InstrumentationFeature> features) {
157+
this.features = Objects.requireNonNullElse(features, emptyList());
158+
}
159+
150160
/**
151161
* This class is internal and is hence not for public use. Its APIs are unstable and can change at
152162
* any time.
@@ -162,6 +172,7 @@ public static class Builder {
162172
private List<SemanticConvention> semanticConventions = emptyList();
163173
private List<ManualTelemetryEntry> additionalTelemetry = emptyList();
164174
@Nullable private Boolean overrideTelemetry;
175+
private List<InstrumentationFeature> features = emptyList();
165176

166177
@CanIgnoreReturnValue
167178
public Builder description(@Nullable String description) {
@@ -217,6 +228,12 @@ public Builder overrideTelemetry(@Nullable Boolean overrideTelemetry) {
217228
return this;
218229
}
219230

231+
@CanIgnoreReturnValue
232+
public Builder features(@Nullable List<InstrumentationFeature> features) {
233+
this.features = Objects.requireNonNullElse(features, emptyList());
234+
return this;
235+
}
236+
220237
public InstrumentationMetadata build() {
221238
InstrumentationMetadata metadata =
222239
new InstrumentationMetadata(
@@ -231,6 +248,7 @@ public InstrumentationMetadata build() {
231248
configurations);
232249
metadata.setAdditionalTelemetry(additionalTelemetry);
233250
metadata.setOverrideTelemetry(overrideTelemetry);
251+
metadata.setFeatures(features);
234252
return metadata;
235253
}
236254
}

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,13 @@ private static void addMetadataProperties(
215215
if (module.getMetadata().getDisabledByDefault()) {
216216
moduleMap.put("disabled_by_default", module.getMetadata().getDisabledByDefault());
217217
}
218+
if (!module.getMetadata().getFeatures().isEmpty()) {
219+
List<String> functionNames =
220+
module.getMetadata().getFeatures().stream()
221+
.map(Enum::name)
222+
.collect(Collectors.toList());
223+
moduleMap.put("features", functionNames);
224+
}
218225
}
219226
}
220227

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

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import io.opentelemetry.instrumentation.docs.internal.EmittedMetrics;
1717
import io.opentelemetry.instrumentation.docs.internal.EmittedSpans;
1818
import io.opentelemetry.instrumentation.docs.internal.InstrumentationClassification;
19+
import io.opentelemetry.instrumentation.docs.internal.InstrumentationFeature;
1920
import io.opentelemetry.instrumentation.docs.internal.InstrumentationMetadata;
2021
import io.opentelemetry.instrumentation.docs.internal.InstrumentationModule;
2122
import io.opentelemetry.instrumentation.docs.internal.InstrumentationType;
@@ -122,6 +123,10 @@ void testGenerateInstrumentationYamlSeparatesClassifications() throws Exception
122123
.description("Spring Web 6.0 instrumentation")
123124
.classification(InstrumentationClassification.LIBRARY.name())
124125
.disabledByDefault(false)
126+
.features(
127+
List.of(
128+
InstrumentationFeature.HTTP_ROUTE, InstrumentationFeature.CONTEXT_PROPAGATION))
129+
.semanticConventions(List.of(DATABASE_CLIENT_METRICS, DATABASE_CLIENT_SPANS))
125130
.configurations(
126131
List.of(
127132
new ConfigurationOption(
@@ -189,6 +194,12 @@ void testGenerateInstrumentationYamlSeparatesClassifications() throws Exception
189194
spring:
190195
- name: spring-web-6.0
191196
description: Spring Web 6.0 instrumentation
197+
semantic_conventions:
198+
- DATABASE_CLIENT_METRICS
199+
- DATABASE_CLIENT_SPANS
200+
features:
201+
- HTTP_ROUTE
202+
- CONTEXT_PROPAGATION
192203
source_path: instrumentation/spring/spring-web/spring-web-6.0
193204
minimum_java_version: 11
194205
scope:
@@ -227,6 +238,9 @@ void testMetadataParser() throws JsonProcessingException {
227238
classification: internal
228239
disabled_by_default: true
229240
library_link: https://example.com/test-library
241+
features:
242+
- HTTP_ROUTE
243+
- CONTROLLER_SPANS
230244
configurations:
231245
- name: otel.instrumentation.common.db-statement-sanitizer.enabled
232246
description: Enables statement sanitization for database queries.
@@ -243,6 +257,10 @@ void testMetadataParser() throws JsonProcessingException {
243257
.isEqualTo("Enables statement sanitization for database queries.");
244258
assertThat(config.defaultValue()).isEqualTo("true");
245259

260+
assertThat(metadata.getFeatures())
261+
.containsExactly(
262+
InstrumentationFeature.HTTP_ROUTE, InstrumentationFeature.CONTROLLER_SPANS);
263+
246264
assertThat(metadata.getClassification()).isEqualTo(InstrumentationClassification.INTERNAL);
247265
assertThat(metadata.getDescription()).isEqualTo("test description");
248266
assertThat(metadata.getDisabledByDefault()).isEqualTo(true);
@@ -315,6 +333,21 @@ void testMetadataParserWithOnlyConfigurations() throws JsonProcessingException {
315333
assertThat(config.type()).isEqualTo(ConfigurationType.BOOLEAN);
316334
}
317335

336+
@Test
337+
void testMetadataParserWithOnlyFeatures() throws JsonProcessingException {
338+
String input =
339+
"""
340+
features:
341+
- HTTP_ROUTE
342+
""";
343+
InstrumentationMetadata metadata = YamlHelper.metaDataParser(input);
344+
345+
assertThat(metadata.getClassification()).isEqualTo(InstrumentationClassification.LIBRARY);
346+
assertThat(metadata.getDescription()).isNull();
347+
assertThat(metadata.getDisabledByDefault()).isFalse();
348+
assertThat(metadata.getFeatures()).containsExactly(InstrumentationFeature.HTTP_ROUTE);
349+
}
350+
318351
@Test
319352
void testMetricsParsing() throws Exception {
320353
List<InstrumentationModule> modules = new ArrayList<>();
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
display_name: Akka Actors
22
description: This instrumentation provides context propagation for Akka actors, it does not emit any telemetry on its own.
33
library_link: https://doc.akka.io/libraries/akka-core/current/typed/index.html
4+
features:
5+
- CONTEXT_PROPAGATION
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
display_name: Akka Actors
22
description: This instrumentation provides context propagation for the Akka Fork-Join Pool, it does not emit any telemetry on its own.
33
library_link: https://doc.akka.io/libraries/akka-core/current/typed/index.html
4+
features:
5+
- CONTEXT_PROPAGATION

0 commit comments

Comments
 (0)