Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
290 changes: 281 additions & 9 deletions docs/instrumentation-list.yaml

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions instrumentation-docs/instrumentations.sh
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,14 @@ readonly INSTRUMENTATIONS=(
"spring:spring-webmvc:spring-webmvc-6.0:javaagent:test"
"spring:spring-webmvc:spring-webmvc-6.0:javaagent:testExperimental"
"openai:openai-java-1.1:javaagent:test"
"aws-lambda:aws-lambda-core-1.0:javaagent:test"
"aws-lambda:aws-lambda-events-2.2:javaagent:test"
"cassandra:cassandra-3.0:javaagent:test"
"cassandra:cassandra-3.0:javaagent:testStableSemconv"
"cassandra:cassandra-4.0:javaagent:test"
"cassandra:cassandra-4.0:javaagent:testStableSemconv"
"cassandra:cassandra-4.4:javaagent:test"
"cassandra:cassandra-4.4:javaagent:testStableSemconv"
)

# Some instrumentation test suites don't run ARM, so we use colima to run them in an x86_64
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* This class is responsible for parsing metric files from the `.telemetry` directory of an
* instrumentation module and filtering them by scope.
*/
public class MetricParser {
public class MetricParser extends TelemetryParser {

/**
* Retrieves metrics for a given instrumentation module, filtered by scope.
Expand Down Expand Up @@ -109,7 +109,10 @@ public static Map<String, Map<String, AggregatedMetricInfo>> aggregateMetrics(
aggregatedMetrics.computeIfAbsent(when, k -> new HashMap<>());

for (EmittedMetrics.MetricsByScope metricsByScope : metrics.getMetricsByScope()) {
if (metricsByScope.getScope().equals(targetScopeName)) {
if (metricsByScope.getScope().equals(targetScopeName)
|| scopeAllowList
.getOrDefault(targetScopeName, Set.of())
.contains(metricsByScope.getScope())) {
for (EmittedMetrics.Metric metric : metricsByScope.getMetrics()) {
AggregatedMetricInfo aggInfo =
metricKindMap.computeIfAbsent(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* This class is responsible for parsing span files from the `.telemetry` directory of an
* instrumentation module and filtering them by scope.
*/
public class SpanParser {
public class SpanParser extends TelemetryParser {

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

for (EmittedSpans.SpansByScope spansByScope : spans.getSpansByScope()) {
if (spansByScope.getScope().equals(targetScopeName)) {
if (spansByScope.getScope().equals(targetScopeName)
|| scopeAllowList
.getOrDefault(targetScopeName, Set.of())
.contains(spansByScope.getScope())) {
processSpansForScope(spansByScope, spanKindMap);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.instrumentation.docs.parsers;

import java.util.Map;
import java.util.Set;

abstract class TelemetryParser {

// If an instrumentation module uses an instrumenter or telemetry class from another module, it
// might report telemetry with a different scope name, resulting in us excluding it. There are
// cases where we want to include this data, so we provide this way to override that exclusion
// filter. The key is the scope of the module being analyzed, the value is a set of additional
// allowed scopes.
protected static final Map<String, Set<String>> scopeAllowList =
Map.of("io.opentelemetry.armeria-grpc-1.14", Set.of("io.opentelemetry.grpc-1.6"));
}
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,31 @@ void testPreservesMetricMetadata() {
assertThat(foundMetric.getUnit()).isEqualTo("unit");
}

@Test
void testScopeOverrideForGrpc() {
String targetScopeName = "io.opentelemetry.armeria-grpc-1.14";

EmittedMetrics.Metric metric1 =
createMetric("my.metric1", "description of my.metric1", "attr1");

EmittedMetrics.MetricsByScope targetMetricsByScope =
new EmittedMetrics.MetricsByScope("io.opentelemetry.grpc-1.6", List.of(metric1));

EmittedMetrics emittedMetrics = new EmittedMetrics("default", List.of(targetMetricsByScope));

Map<String, Map<String, MetricParser.MetricAggregator.AggregatedMetricInfo>> metrics =
MetricParser.MetricAggregator.aggregateMetrics("default", emittedMetrics, targetScopeName);

Map<String, List<EmittedMetrics.Metric>> result =
MetricParser.MetricAggregator.buildFilteredMetrics(metrics);

EmittedMetrics.Metric foundMetric = result.get("default").get(0);
assertThat(foundMetric.getName()).isEqualTo("my.metric1");
assertThat(foundMetric.getDescription()).isEqualTo("description of my.metric1");
assertThat(foundMetric.getType()).isEqualTo("gauge");
assertThat(foundMetric.getUnit()).isEqualTo("unit");
}

private static EmittedMetrics.Metric createMetric(
String name, String description, String attrName) {
return new EmittedMetrics.Metric(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,4 +195,70 @@ void testSpanAggregatorFiltersAndAggregatesCorrectly() {
.extracting(TelemetryAttribute::getName)
.containsExactly("my.operation");
}

@Test
void getSpansFromFilesIncludesAllowListedScopes(@TempDir Path tempDir) throws IOException {
Path telemetryDir = Files.createDirectories(tempDir.resolve(".telemetry"));

String file1Content =
"""
when: default
spans_by_scope:
- scope: io.opentelemetry.grpc-1.6
spans:
- span_kind: CLIENT
attributes:
- name: rpc.system
type: STRING
- name: rpc.grpc.status_code
type: LONG
- name: server.port
type: LONG
- name: rpc.method
type: STRING
- name: rpc.service
type: STRING
- name: server.address
type: STRING
- span_kind: SERVER
attributes:
- name: rpc.system
type: STRING
- name: rpc.grpc.status_code
type: LONG
- name: server.port
type: LONG
- name: rpc.method
type: STRING
- name: rpc.service
type: STRING
- name: server.address
type: STRING
""";

Files.writeString(telemetryDir.resolve("spans-1.yaml"), file1Content);

try (MockedStatic<FileManager> fileManagerMock = mockStatic(FileManager.class)) {
fileManagerMock
.when(() -> FileManager.readFileToString(telemetryDir.resolve("spans-1.yaml").toString()))
.thenReturn(file1Content);

Map<String, EmittedSpans> fileContents =
EmittedSpanParser.getSpansByScopeFromFiles(tempDir.toString(), "");

EmittedSpans emittedSpans = fileContents.get("default");

// use armeria scope that doesn't match the scope in the file
Map<String, Map<String, Set<TelemetryAttribute>>> spans =
SpanParser.SpanAggregator.aggregateSpans(
"default", emittedSpans, "io.opentelemetry.armeria-grpc-1.14");

Map<String, List<EmittedSpans.Span>> result =
SpanParser.SpanAggregator.buildFilteredSpans(spans);

assertThat(result.size()).isEqualTo(1);
assertThat(result.get("default")).isNotNull();
assertThat(result.get("default").size()).isEqualTo(2);
}
}
}
1 change: 1 addition & 0 deletions instrumentation/akka/akka-actor-2.3/metadata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
description: This instrumentation provides context propagation for Akka actors, it does not emit any telemetry on its own.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
description: This instrumentation provides context propagation for the Akka Fork-Join Pool, it does not emit any telemetry on its own.
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,6 @@ tasks.withType<Test>().configureEach {
jvmArgs("--add-opens=java.base/java.lang=ALL-UNNAMED")
jvmArgs("--add-opens=java.base/java.util=ALL-UNNAMED")
jvmArgs("-XX:+IgnoreUnrecognizedVMOptions")

systemProperty("collectMetadata", findProperty("collectMetadata")?.toString() ?: "false")
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
description: >
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.
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.
configurations:
- name: otel.instrumentation.aws-lambda.flush-timeout
type: int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,9 @@ dependencies {
testImplementation(project(":instrumentation:aws-lambda:aws-lambda-events-2.2:testing"))
testInstrumentation(project(":instrumentation:aws-lambda:aws-lambda-core-1.0:javaagent"))
}

tasks {
test {
systemProperty("collectMetadata", findProperty("collectMetadata")?.toString() ?: "false")
}
}
9 changes: 8 additions & 1 deletion instrumentation/aws-sdk/aws-sdk-1.11/metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
description: >
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.
configurations:
- name: otel.instrumentation.aws-sdk.experimental-span-attributes
description: Enables experimental span attributes for AWS SDK instrumentation.
description: >
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.
type: boolean
default: false
- name: otel.instrumentation.messaging.experimental.receive-telemetry.enabled
Expand Down
12 changes: 10 additions & 2 deletions instrumentation/aws-sdk/aws-sdk-2.2/metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
description: >
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.
configurations:
- name: otel.instrumentation.messaging.experimental.receive-telemetry.enabled
description: >
Expand All @@ -10,15 +14,19 @@ configurations:
type: list
default: ''
- name: otel.instrumentation.aws-sdk.experimental-span-attributes
description: Enables experimental span attributes for AWS SDK instrumentation.
description: >
Enables experimental span attributes `aws.agent`, `aws.lambda.function.arn` and
`aws.lambda.function.name` for AWS SDK instrumentation.
type: boolean
default: false
- name: otel.instrumentation.aws-sdk.experimental-use-propagator-for-messaging
description: Determines whether the configured TextMapPropagator should be used to inject into supported messaging attributes (for SQS).
type: boolean
default: false
- name: otel.instrumentation.genai.capture-message-content
description: 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
description: >
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
type: boolean
default: false
- name: otel.instrumentation.aws-sdk.experimental-record-individual-http-error
Expand Down
1 change: 1 addition & 0 deletions instrumentation/azure-core/azure-core-1.14/metadata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
description: This instrumentation enables context propagation for the Azure Core library, it does not emit any telemetry on its own.
1 change: 1 addition & 0 deletions instrumentation/azure-core/azure-core-1.19/metadata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
description: This instrumentation enables context propagation for the Azure Core library, it does not emit any telemetry on its own.
1 change: 1 addition & 0 deletions instrumentation/azure-core/azure-core-1.36/metadata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
description: This instrumentation enables context propagation for the Azure Core library, it does not emit any telemetry on its own.
4 changes: 3 additions & 1 deletion instrumentation/camel-2.20/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ description: >
'camel-opentelemetry' component provided directly by the Camel project.
configurations:
- name: otel.instrumentation.camel.experimental-span-attributes
description: Enable the capture of experimental span attributes.
description: >
Enable the capture of experimental `camel.uri`, `camel.kafka.partitionKey`, `camel.kafka.key`
and `camel.kafka.offset` span attributes.
type: boolean
default: false
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,12 @@ configurations.testRuntimeClasspath.get().resolutionStrategy.force("com.google.g
tasks {
withType<Test>().configureEach {
usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service)
systemProperty("collectMetadata", findProperty("collectMetadata")?.toString() ?: "false")
}

val testStableSemconv by registering(Test::class) {
jvmArgs("-Dotel.semconv-stability.opt-in=database")
systemProperty("metaDataConfig", "otel.semconv-stability.opt-in=database")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: metadataConfig (can be in followup)

}

check {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ dependencies {
tasks {
withType<Test>().configureEach {
usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service)
systemProperty("collectMetadata", findProperty("collectMetadata")?.toString() ?: "false")
}

val testStableSemconv by registering(Test::class) {
jvmArgs("-Dotel.semconv-stability.opt-in=database")
systemProperty("metaDataConfig", "otel.semconv-stability.opt-in=database")
}

check {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ dependencies {
tasks {
withType<Test>().configureEach {
usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service)
systemProperty("collectMetadata", findProperty("collectMetadata")?.toString() ?: "false")
}

val testStableSemconv by registering(Test::class) {
jvmArgs("-Dotel.semconv-stability.opt-in=database")
systemProperty("metaDataConfig", "otel.semconv-stability.opt-in=database")
}

check {
Expand Down
2 changes: 1 addition & 1 deletion instrumentation/couchbase/couchbase-2.0/metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
configurations:
- name: otel.instrumentation.couchbase.experimental-span-attributes
description: Enables experimental span attributes couchbase.operation_id and couchbase.local.address
description: Enables experimental span attributes `couchbase.operation_id` and `couchbase.local.address`
type: boolean
default: false
Loading