Skip to content

Commit abb4920

Browse files
committed
update parsers
1 parent 92368c8 commit abb4920

File tree

11 files changed

+216
-14
lines changed

11 files changed

+216
-14
lines changed

docs/instrumentation-list.yaml

Lines changed: 82 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ libraries:
5959
type: STRING
6060
akka:
6161
- name: akka-actor-2.3
62+
description: This instrumentation provides context propagation for Akka actors,
63+
it does not emit any telemetry on its own.
6264
source_path: instrumentation/akka/akka-actor-2.3
6365
scope:
6466
name: io.opentelemetry.akka-actor-2.3
@@ -68,6 +70,8 @@ libraries:
6870
- com.typesafe.akka:akka-actor_2.12:[2.3,)
6971
- com.typesafe.akka:akka-actor_2.13:[2.3,)
7072
- name: akka-actor-fork-join-2.5
73+
description: This instrumentation provides context propagation for the Akka Fork-Join
74+
Pool, it does not emit any telemetry on its own.
7175
source_path: instrumentation/akka/akka-actor-fork-join-2.5
7276
scope:
7377
name: io.opentelemetry.akka-actor-fork-join-2.5
@@ -780,6 +784,37 @@ libraries:
780784
target_versions:
781785
javaagent:
782786
- com.linecorp.armeria:armeria-grpc:[1.14.0,)
787+
telemetry:
788+
- when: default
789+
spans:
790+
- span_kind: CLIENT
791+
attributes:
792+
- name: rpc.grpc.status_code
793+
type: LONG
794+
- name: rpc.method
795+
type: STRING
796+
- name: rpc.service
797+
type: STRING
798+
- name: rpc.system
799+
type: STRING
800+
- name: server.address
801+
type: STRING
802+
- name: server.port
803+
type: LONG
804+
- span_kind: SERVER
805+
attributes:
806+
- name: rpc.grpc.status_code
807+
type: LONG
808+
- name: rpc.method
809+
type: STRING
810+
- name: rpc.service
811+
type: STRING
812+
- name: rpc.system
813+
type: STRING
814+
- name: server.address
815+
type: STRING
816+
- name: server.port
817+
type: LONG
783818
async:
784819
- name: async-http-client-1.9
785820
description: This instrumentation enables CLIENT spans and metrics for version
@@ -887,7 +922,7 @@ libraries:
887922
aws:
888923
- name: aws-lambda-core-1.0
889924
description: |
890-
Provides lightweight instrumentation of the Lambda core library, supporting all versions. Use this package if you only use `RequestStreamHandler` or know you don't use any event classes from `aws-lambda-java-events`. This also includes when you are using `aws-serverless-java-container` to run e.g., a Spring Boot application on Lambda.
925+
Provides lightweight instrumentation of the Lambda core library, supporting all versions. It generates FaaS SERVER spans with the `faas.invocation_id` attribute. Use this package if you only use `RequestStreamHandler` or know you don't use any event classes from `aws-lambda-java-events`. This also includes when you are using `aws-serverless-java-container` to run e.g., a Spring Boot application on Lambda.
891926
source_path: instrumentation/aws-lambda/aws-lambda-core-1.0
892927
scope:
893928
name: io.opentelemetry.aws-lambda-core-1.0
@@ -901,6 +936,13 @@ libraries:
901936
description: Flush timeout in milliseconds.
902937
type: int
903938
default: 10000
939+
telemetry:
940+
- when: default
941+
spans:
942+
- span_kind: SERVER
943+
attributes:
944+
- name: faas.invocation_id
945+
type: STRING
904946
- name: aws-lambda-events-2.2
905947
description: |
906948
Provides full instrumentation of the Lambda library, including standard and custom event types, from `aws-lambda-java-events` 2.2+.
@@ -918,7 +960,32 @@ libraries:
918960
description: Flush timeout in milliseconds.
919961
type: int
920962
default: 10000
963+
telemetry:
964+
- when: default
965+
spans:
966+
- span_kind: CONSUMER
967+
attributes:
968+
- name: messaging.operation
969+
type: STRING
970+
- name: messaging.system
971+
type: STRING
972+
- span_kind: SERVER
973+
attributes:
974+
- name: faas.invocation_id
975+
type: STRING
976+
- name: faas.trigger
977+
type: STRING
978+
- name: http.request.method
979+
type: STRING
980+
- name: http.response.status_code
981+
type: LONG
982+
- name: url.full
983+
type: STRING
984+
- name: user_agent.original
985+
type: STRING
921986
- name: aws-sdk-1.11
987+
description: |
988+
This instrumentation covers the AWS SDK 1.11+ client library, enabling messaging and client spans and metrics for calls to AWS services including DynamoDB, EC2, Kinesis, Lambda, RDS, S3, secrets manager, SNS/SQS and step functions.
922989
source_path: instrumentation/aws-sdk/aws-sdk-1.11
923990
scope:
924991
name: io.opentelemetry.aws-sdk-1.11
@@ -931,7 +998,8 @@ libraries:
931998
- com.amazonaws:aws-java-sdk-core:1.11.0
932999
configurations:
9331000
- name: otel.instrumentation.aws-sdk.experimental-span-attributes
934-
description: Enables experimental span attributes for AWS SDK instrumentation.
1001+
description: |
1002+
Enables the experimental span attributes `aws.agent`, `aws.bucket.name`, `aws.queue.url`, `aws.queue.name`, `aws.stream.name`, `aws.table.name`, `aws.lambda.function.arn` and `aws.lambda.function.name` for AWS SDK instrumentation.
9351003
type: boolean
9361004
default: false
9371005
- name: otel.instrumentation.messaging.experimental.receive-telemetry.enabled
@@ -1143,6 +1211,8 @@ libraries:
11431211
- name: url.full
11441212
type: STRING
11451213
- name: aws-sdk-2.2
1214+
description: |
1215+
This instrumentation covers the AWS SDK 2.2+ client library, enabling messaging and client spans and metrics for calls to AWS services including DynamoDB, EC2, Kinesis, Lambda, RDS, S3, SNS/SQS and Bedrock.
11461216
source_path: instrumentation/aws-sdk/aws-sdk-2.2
11471217
scope:
11481218
name: io.opentelemetry.aws-sdk-2.2
@@ -1170,7 +1240,8 @@ libraries:
11701240
type: list
11711241
default: ''
11721242
- name: otel.instrumentation.aws-sdk.experimental-span-attributes
1173-
description: Enables experimental span attributes for AWS SDK instrumentation.
1243+
description: |
1244+
Enables experimental span attributes `aws.agent`, `aws.lambda.function.arn` and `aws.lambda.function.name` for AWS SDK instrumentation.
11741245
type: boolean
11751246
default: false
11761247
- name: otel.instrumentation.aws-sdk.experimental-use-propagator-for-messaging
@@ -1179,9 +1250,8 @@ libraries:
11791250
type: boolean
11801251
default: false
11811252
- name: otel.instrumentation.genai.capture-message-content
1182-
description: Determines whether Generative AI events include full content of
1183-
user and assistant messages. Note that full content can have data privacy
1184-
and size concerns and care should be taken when enabling this
1253+
description: |
1254+
Determines whether Generative AI events include full content of user and assistant messages. Note that full content can have data privacy and size concerns and care should be taken when enabling this
11851255
type: boolean
11861256
default: false
11871257
- name: otel.instrumentation.aws-sdk.experimental-record-individual-http-error
@@ -1499,20 +1569,26 @@ libraries:
14991569
type: STRING
15001570
azure:
15011571
- name: azure-core-1.14
1572+
description: This instrumentation enables context propagation for the Azure Core
1573+
library, it does not emit any telemetry on its own.
15021574
source_path: instrumentation/azure-core/azure-core-1.14
15031575
scope:
15041576
name: io.opentelemetry.azure-core-1.14
15051577
target_versions:
15061578
javaagent:
15071579
- com.azure:azure-core:[1.14.0,1.19.0)
15081580
- name: azure-core-1.19
1581+
description: This instrumentation enables context propagation for the Azure Core
1582+
library, it does not emit any telemetry on its own.
15091583
source_path: instrumentation/azure-core/azure-core-1.19
15101584
scope:
15111585
name: io.opentelemetry.azure-core-1.19
15121586
target_versions:
15131587
javaagent:
15141588
- com.azure:azure-core:[1.19.0,1.36.0)
15151589
- name: azure-core-1.36
1590+
description: This instrumentation enables context propagation for the Azure Core
1591+
library, it does not emit any telemetry on its own.
15161592
source_path: instrumentation/azure-core/azure-core-1.36
15171593
scope:
15181594
name: io.opentelemetry.azure-core-1.36

instrumentation-docs/instrumentations.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ readonly INSTRUMENTATIONS=(
114114
"spring:spring-webmvc:spring-webmvc-6.0:javaagent:test"
115115
"spring:spring-webmvc:spring-webmvc-6.0:javaagent:testExperimental"
116116
"openai:openai-java-1.1:javaagent:test"
117+
"aws-lambda:aws-lambda-core-1.0:javaagent:test"
118+
"aws-lambda:aws-lambda-events-2.2:javaagent:test"
119+
"azure-core:azure-core-1.19:javaagent:testAzure"
117120
)
118121

119122
# Some instrumentation test suites don't run ARM, so we use colima to run them in an x86_64

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ private void enrichModule(InstrumentationModule module) throws IOException {
6464
}
6565

6666
module.setTargetVersions(getVersionInformation(module));
67-
module.setMetrics(MetricParser.getMetrics(module, fileManager));
67+
module.setMetrics(MetricParser.get(module, fileManager));
6868
module.setSpans(SpanParser.getSpans(module, fileManager));
6969
}
7070

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/*
2+
* Copyright The OpenTelemetry Authors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package io.opentelemetry.instrumentation.docs.parsers;
7+
8+
abstract class EmittedParser {}

instrumentation-docs/src/main/java/io/opentelemetry/instrumentation/docs/parsers/MetricParser.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
* This class is responsible for parsing metric files from the `.telemetry` directory of an
2121
* instrumentation module and filtering them by scope.
2222
*/
23-
public class MetricParser {
23+
public class MetricParser extends TelemetryParser {
2424

2525
/**
2626
* Retrieves metrics for a given instrumentation module, filtered by scope.
@@ -29,7 +29,7 @@ public class MetricParser {
2929
* @param fileManager the file manager to use for file operations
3030
* @return a map where the key is the 'when' condition and the value is a list of metrics
3131
*/
32-
public static Map<String, List<EmittedMetrics.Metric>> getMetrics(
32+
public static Map<String, List<EmittedMetrics.Metric>> get(
3333
InstrumentationModule module, FileManager fileManager) {
3434
Map<String, EmittedMetrics> metrics =
3535
EmittedMetricsParser.getMetricsFromFiles(fileManager.rootDir(), module.getSrcPath());
@@ -109,7 +109,10 @@ public static Map<String, Map<String, AggregatedMetricInfo>> aggregateMetrics(
109109
aggregatedMetrics.computeIfAbsent(when, k -> new HashMap<>());
110110

111111
for (EmittedMetrics.MetricsByScope metricsByScope : metrics.getMetricsByScope()) {
112-
if (metricsByScope.getScope().equals(targetScopeName)) {
112+
if (metricsByScope.getScope().equals(targetScopeName)
113+
|| scopeAllowList
114+
.getOrDefault(targetScopeName, Set.of())
115+
.contains(metricsByScope.getScope())) {
113116
for (EmittedMetrics.Metric metric : metricsByScope.getMetrics()) {
114117
AggregatedMetricInfo aggInfo =
115118
metricKindMap.computeIfAbsent(

instrumentation-docs/src/main/java/io/opentelemetry/instrumentation/docs/parsers/SpanParser.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
* This class is responsible for parsing span files from the `.telemetry` directory of an
2222
* instrumentation module and filtering them by scope.
2323
*/
24-
public class SpanParser {
24+
public class SpanParser extends TelemetryParser {
2525

2626
// We want to ignore test related attributes
2727
private static final List<String> EXCLUDED_ATTRIBUTES =
@@ -87,7 +87,10 @@ public static Map<String, Map<String, Set<TelemetryAttribute>>> aggregateSpans(
8787
aggregatedAttributes.computeIfAbsent(when, k -> new HashMap<>());
8888

8989
for (EmittedSpans.SpansByScope spansByScope : spans.getSpansByScope()) {
90-
if (spansByScope.getScope().equals(targetScopeName)) {
90+
if (spansByScope.getScope().equals(targetScopeName)
91+
|| scopeAllowList
92+
.getOrDefault(targetScopeName, Set.of())
93+
.contains(spansByScope.getScope())) {
9194
processSpansForScope(spansByScope, spanKindMap);
9295
}
9396
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Copyright The OpenTelemetry Authors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package io.opentelemetry.instrumentation.docs.parsers;
7+
8+
import java.util.Map;
9+
import java.util.Set;
10+
11+
abstract class TelemetryParser {
12+
13+
// If an instrumentation module uses an instrumenter or telemetry class from another module, it
14+
// might report telemetry with a different scope name, resulting in us excluding it. There are
15+
// cases where we want to include this data, so we provide this way to override that exclusion
16+
// filter. The key is the scope of the module being analyzed, the value is a set of additional
17+
// allowed scopes.
18+
protected static final Map<String, Set<String>> scopeAllowList =
19+
Map.of("io.opentelemetry.armeria-grpc-1.14", Set.of("io.opentelemetry.grpc-1.6"));
20+
}

instrumentation-docs/src/test/java/io/opentelemetry/instrumentation/docs/parsers/MetricParserTest.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,31 @@ void testPreservesMetricMetadata() {
107107
assertThat(foundMetric.getUnit()).isEqualTo("unit");
108108
}
109109

110+
@Test
111+
void testScopeOverrideForGrpc() {
112+
String targetScopeName = "io.opentelemetry.armeria-grpc-1.14";
113+
114+
EmittedMetrics.Metric metric1 =
115+
createMetric("my.metric1", "description of my.metric1", "attr1");
116+
117+
EmittedMetrics.MetricsByScope targetMetricsByScope =
118+
new EmittedMetrics.MetricsByScope("io.opentelemetry.grpc-1.6", List.of(metric1));
119+
120+
EmittedMetrics emittedMetrics = new EmittedMetrics("default", List.of(targetMetricsByScope));
121+
122+
Map<String, Map<String, MetricParser.MetricAggregator.AggregatedMetricInfo>> metrics =
123+
MetricParser.MetricAggregator.aggregateMetrics("default", emittedMetrics, targetScopeName);
124+
125+
Map<String, List<EmittedMetrics.Metric>> result =
126+
MetricParser.MetricAggregator.buildFilteredMetrics(metrics);
127+
128+
EmittedMetrics.Metric foundMetric = result.get("default").get(0);
129+
assertThat(foundMetric.getName()).isEqualTo("my.metric1");
130+
assertThat(foundMetric.getDescription()).isEqualTo("description of my.metric1");
131+
assertThat(foundMetric.getType()).isEqualTo("gauge");
132+
assertThat(foundMetric.getUnit()).isEqualTo("unit");
133+
}
134+
110135
private static EmittedMetrics.Metric createMetric(
111136
String name, String description, String attrName) {
112137
return new EmittedMetrics.Metric(

instrumentation-docs/src/test/java/io/opentelemetry/instrumentation/docs/parsers/SpanParserTest.java

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,4 +195,70 @@ void testSpanAggregatorFiltersAndAggregatesCorrectly() {
195195
.extracting(TelemetryAttribute::getName)
196196
.containsExactly("my.operation");
197197
}
198+
199+
@Test
200+
void getSpansFromFilesIncludesAllowListedScopes(@TempDir Path tempDir) throws IOException {
201+
Path telemetryDir = Files.createDirectories(tempDir.resolve(".telemetry"));
202+
203+
String file1Content =
204+
"""
205+
when: default
206+
spans_by_scope:
207+
- scope: io.opentelemetry.grpc-1.6
208+
spans:
209+
- span_kind: CLIENT
210+
attributes:
211+
- name: rpc.system
212+
type: STRING
213+
- name: rpc.grpc.status_code
214+
type: LONG
215+
- name: server.port
216+
type: LONG
217+
- name: rpc.method
218+
type: STRING
219+
- name: rpc.service
220+
type: STRING
221+
- name: server.address
222+
type: STRING
223+
- span_kind: SERVER
224+
attributes:
225+
- name: rpc.system
226+
type: STRING
227+
- name: rpc.grpc.status_code
228+
type: LONG
229+
- name: server.port
230+
type: LONG
231+
- name: rpc.method
232+
type: STRING
233+
- name: rpc.service
234+
type: STRING
235+
- name: server.address
236+
type: STRING
237+
""";
238+
239+
Files.writeString(telemetryDir.resolve("spans-1.yaml"), file1Content);
240+
241+
try (MockedStatic<FileManager> fileManagerMock = mockStatic(FileManager.class)) {
242+
fileManagerMock
243+
.when(() -> FileManager.readFileToString(telemetryDir.resolve("spans-1.yaml").toString()))
244+
.thenReturn(file1Content);
245+
246+
Map<String, EmittedSpans> fileContents =
247+
EmittedSpanParser.getSpansByScopeFromFiles(tempDir.toString(), "");
248+
249+
EmittedSpans emittedSpans = fileContents.get("default");
250+
251+
// Aggregate spans - only target scope should be included
252+
Map<String, Map<String, Set<TelemetryAttribute>>> spans =
253+
SpanParser.SpanAggregator.aggregateSpans(
254+
"default", emittedSpans, "io.opentelemetry.armeria-grpc-1.14");
255+
256+
Map<String, List<EmittedSpans.Span>> result =
257+
SpanParser.SpanAggregator.buildFilteredSpans(spans);
258+
259+
assertThat(result.size()).isEqualTo(1);
260+
assertThat(result.get("default")).isNotNull();
261+
assertThat(result.get("default").size()).isEqualTo(2);
262+
}
263+
}
198264
}

instrumentation/aws-lambda/aws-lambda-core-1.0/javaagent/build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,4 @@ tasks.withType<Test>().configureEach {
2828
jvmArgs("-XX:+IgnoreUnrecognizedVMOptions")
2929

3030
systemProperty("collectMetadata", findProperty("collectMetadata")?.toString() ?: "false")
31-
systemProperty("collectSpans", true)
3231
}

0 commit comments

Comments
 (0)