Skip to content

Commit b7c260f

Browse files
committed
Merge branch 'main' into otelbot/update-opentelemetry-sdk-to-1.48.0
2 parents b4bb6ca + dd071d2 commit b7c260f

File tree

63 files changed

+2173
-257
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+2173
-257
lines changed

.github/workflows/codeql.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050
cache-read-only: ${{ github.event_name == 'pull_request' }}
5151

5252
- name: Initialize CodeQL
53-
uses: github/codeql-action/init@b56ba49b26e50535fa1e7f7db0f4f7b4bf65d80d # v3.28.10
53+
uses: github/codeql-action/init@6bb031afdd8eb862ea3fc1848194185e076637e5 # v3.28.11
5454
with:
5555
languages: java, actions
5656
# using "latest" helps to keep up with the latest Kotlin support
@@ -65,4 +65,4 @@ jobs:
6565
run: ./gradlew assemble -x javadoc -x :instrumentation:quarkus-resteasy-reactive:quarkus3-testing:quarkusGenerateCodeDev -x :instrumentation:quarkus-resteasy-reactive:quarkus2-testing:quarkusGenerateCodeDev --no-build-cache --no-daemon
6666

6767
- name: Perform CodeQL analysis
68-
uses: github/codeql-action/analyze@b56ba49b26e50535fa1e7f7db0f4f7b4bf65d80d # v3.28.10
68+
uses: github/codeql-action/analyze@6bb031afdd8eb862ea3fc1848194185e076637e5 # v3.28.11

.github/workflows/ossf-scorecard.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,6 @@ jobs:
4242
# Upload the results to GitHub's code scanning dashboard (optional).
4343
# Commenting out will disable upload of results to your repo's Code Scanning dashboard
4444
- name: "Upload to code-scanning"
45-
uses: github/codeql-action/upload-sarif@b56ba49b26e50535fa1e7f7db0f4f7b4bf65d80d # v3.28.10
45+
uses: github/codeql-action/upload-sarif@6bb031afdd8eb862ea3fc1848194185e076637e5 # v3.28.11
4646
with:
4747
sarif_file: results.sarif

.github/workflows/reusable-native-tests.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
2222
- id: read-java
2323
run: echo "version=$(cat .java-version)" >> "$GITHUB_OUTPUT"
24-
- uses: graalvm/setup-graalvm@b0cb26a8da53cb3e97cdc0c827d8e3071240e730 # v1.3.1.1
24+
- uses: graalvm/setup-graalvm@01ed653ac833fe80569f1ef9f25585ba2811baab # v1.3.3.1
2525
with:
2626
version: "latest"
2727
java-version: "${{ steps.read-java.outputs.version }}"

docs/contributing/writing-instrumentation.md

+16-38
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ instrumentation ->
5858
build.gradle.kts
5959
testing
6060
build.gradle.kts
61+
metadata.yaml
6162
```
6263

6364
The top level `settings.gradle.kts` file would contain the following (please add in alphabetical order):
@@ -68,6 +69,15 @@ include("instrumentation:yarpc-1.0:library")
6869
include("instrumentation:yarpc-1.0:testing")
6970
```
7071

72+
### Instrumentation metadata.yaml (Experimental)
73+
74+
Each module can contain a `metadata.yaml` file that describes the instrumentation. This information
75+
is then used when generating the [instrumentation-list.yaml](../instrumentation-list.yaml) file.
76+
The schema for `metadata.yaml` is still in development and may change in the future. See the
77+
[instrumentation-docs readme](../../instrumentation-docs/readme.md) for more information and the
78+
latest schema.
79+
80+
7181
### Instrumentation Submodules
7282

7383
When writing instrumentation that requires submodules for different versions, the name of each
@@ -215,10 +225,10 @@ library instrumentation test, there will be code calling into the instrumentatio
215225
javaagent instrumentation test it will generally use the underlying library API as is and just rely
216226
on the javaagent to apply all the necessary bytecode changes automatically.
217227

218-
You can use either JUnit 5 (recommended) or Spock to test the instrumentation. Start by creating an
219-
abstract class with an abstract method, for example `configure()`, that returns the instrumented
220-
object, such as a client, server, or the main class of the instrumented library. Then, depending on
221-
the chosen test library, go to the [JUnit](#junit) or [Spock](#spock) section.
228+
You can use JUnit 5 to test the instrumentation. Start by creating an abstract class with an
229+
abstract method, for example `configure()`, that returns the instrumented object, such as a client,
230+
server, or the main class of the instrumented library. See the [JUnit](#junit) section for more
231+
information.
222232

223233
After writing some tests, return to the `library` package and make sure it has
224234
a `testImplementation` dependency on the `testing` submodule. Then, create a test class that extends
@@ -281,37 +291,6 @@ You can use the `@RegisterExtension` annotation to make sure that the instrument
281291
picked up by JUnit. Then, return the same extension instance in the `testing()` method
282292
implementation so that it's used in all test scenarios implemented in the abstract class.
283293

284-
### Spock
285-
286-
The `testing-common` module contains some utilities that facilitate writing Spock instrumentation
287-
tests, such as the `InstrumentationSpecification` base class and the `LibraryTestTrait`
288-
and `AgentTestTrait` traits.
289-
290-
Consider the following abstract test class extending `InstrumentationSpecification`:
291-
292-
```groovy
293-
abstract class AbstractYarpcTest extends InstrumentationSpecification {
294-
295-
abstract Yarpc configure(Yarpc yarpc);
296-
297-
def "test something"() {
298-
// ...
299-
}
300-
}
301-
```
302-
303-
The `InstrumentationSpecification` class contains abstract methods that are implemented by one of
304-
our test traits in the actual test class. For example:
305-
306-
```groovy
307-
class LibraryYarpcTest extends AbstractYarpcTest implements LibraryTestTrait {
308-
309-
@Override
310-
Yarpc configure(Yarpc yarpc) {
311-
// register interceptor/listener etc
312-
}
313-
}
314-
```
315294

316295
## Writing Java agent instrumentation
317296

@@ -352,9 +331,8 @@ without the user knowing about the instrumentation.
352331

353332
Create a test that extends the base class you wrote earlier but does nothing in the `configure()`
354333
method. Unlike the library instrumentation, the javaagent instrumentation is supposed to work
355-
without any explicit user code modification. Depending on the testing framework, either use
356-
the `AgentInstrumentationExtension` or implement the `AgentTestingTrait`, and try running tests in
357-
this class. All tests should pass.
334+
without any explicit user code modification. Add an `AgentInstrumentationExtension` and try running
335+
tests in this class. All tests should pass.
358336

359337
Note that all the tests inside the `javaagent` module are run using the `agent-for-testing`
360338
javaagent, with the instrumentation being loaded as an extension. This is done to perform the same

docs/instrumentation-list.yaml

+18-12
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ apache:
5858
srcPath: instrumentation/apache-httpclient/apache-httpclient-4.3
5959
target_versions:
6060
library:
61-
- org.apache.httpcomponents:httpclient:4.3
61+
- org.apache.httpcomponents:httpclient:[4.3,4.+)
6262
- name: apache-httpclient-4.0
6363
srcPath: instrumentation/apache-httpclient/apache-httpclient-4.0
6464
target_versions:
@@ -137,7 +137,7 @@ aws:
137137
- com.amazonaws:aws-java-sdk-sqs:[1.10.33,)
138138
- com.amazonaws:aws-java-sdk-core:[1.10.33,)
139139
library:
140-
- com.amazonaws:aws-java-sdk-sqs:1.11.106
140+
- com.amazonaws:aws-java-sdk-sqs:[1.11.106,1.12.583)
141141
- com.amazonaws:aws-java-sdk-core:1.11.0
142142
- name: aws-sdk-2.2
143143
srcPath: instrumentation/aws-sdk/aws-sdk-2.2
@@ -204,10 +204,13 @@ cassandra:
204204
- name: cassandra-3.0
205205
srcPath: instrumentation/cassandra/cassandra-3.0
206206
target_versions:
207-
javaagent: []
207+
javaagent:
208+
- com.datastax.cassandra:cassandra-driver-core:[3.0,4.0)
208209
clickhouse:
209210
instrumentations:
210211
- name: clickhouse-client-0.5
212+
description: Instruments the V1 ClickHouseClient, providing database client spans
213+
and metrics.
211214
srcPath: instrumentation/clickhouse-client-0.5
212215
target_versions:
213216
javaagent:
@@ -352,7 +355,7 @@ graphql:
352355
javaagent:
353356
- com.graphql-java:graphql-java:[12,20)
354357
library:
355-
- com.graphql-java:graphql-java:12.0
358+
- com.graphql-java:graphql-java:[12.0,19.+)
356359
- name: graphql-java-20.0
357360
srcPath: instrumentation/graphql-java/graphql-java-20.0
358361
target_versions:
@@ -651,7 +654,7 @@ jetty:
651654
javaagent:
652655
- org.eclipse.jetty:jetty-client:[9.2,10)
653656
library:
654-
- org.eclipse.jetty:jetty-client:9.2.0.v20140526
657+
- org.eclipse.jetty:jetty-client:[9.2.0.v20140526,9.+)
655658
- name: jetty-11.0
656659
srcPath: instrumentation/jetty/jetty-11.0
657660
target_versions:
@@ -765,8 +768,8 @@ ktor:
765768
- io.ktor:ktor-client-core:[2.0.0,3.0.0)
766769
- io.ktor:ktor-server-core:[2.0.0,3.0.0)
767770
library:
768-
- io.ktor:ktor-server-core:2.0.0
769-
- io.ktor:ktor-client-core:2.0.0
771+
- io.ktor:ktor-client-core:[2.0.0,2.+)
772+
- io.ktor:ktor-server-core:[2.0.0,2.+)
770773
- name: ktor-3.0
771774
srcPath: instrumentation/ktor/ktor-3.0
772775
target_versions:
@@ -780,7 +783,7 @@ ktor:
780783
srcPath: instrumentation/ktor/ktor-1.0
781784
target_versions:
782785
library:
783-
- io.ktor:ktor-server-core:1.0.0
786+
- io.ktor:ktor-server-core:[1.0.0,1.+)
784787
kubernetes:
785788
instrumentations:
786789
- name: kubernetes-client-7.0
@@ -1049,7 +1052,7 @@ oshi:
10491052
javaagent:
10501053
- com.github.oshi:oshi-core:[5.3.1,)
10511054
library:
1052-
- com.github.oshi:oshi-core:$oshiVersion
1055+
- com.github.oshi:oshi-core:5.3.1
10531056
payara:
10541057
instrumentations:
10551058
- name: payara
@@ -1069,8 +1072,11 @@ pekko:
10691072
srcPath: instrumentation/pekko/pekko-http-1.0
10701073
target_versions:
10711074
javaagent:
1075+
- com.softwaremill.sttp.tapir:tapir-pekko-http-server_3:[1.7,)
1076+
- com.softwaremill.sttp.tapir:tapir-pekko-http-server_2.12:[1.7,)
10721077
- org.apache.pekko:pekko-http_2.12:[1.0,)
10731078
- org.apache.pekko:pekko-http_3:[1.0,)
1079+
- com.softwaremill.sttp.tapir:tapir-pekko-http-server_2.13:[1.7,)
10741080
- org.apache.pekko:pekko-http_2.13:[1.0,)
10751081
play:
10761082
instrumentations:
@@ -1233,7 +1239,7 @@ restlet:
12331239
javaagent:
12341240
- org.restlet:org.restlet:[1.1.0, 1.2-M1)
12351241
library:
1236-
- org.restlet:org.restlet:1.1.5
1242+
- org.restlet:org.restlet:[1.1.5,1.+)
12371243
- com.noelios.restlet:com.noelios.restlet:1.1.5
12381244
- name: restlet-2.0
12391245
srcPath: instrumentation/restlet/restlet-2.0
@@ -1301,7 +1307,7 @@ rxjava:
13011307
javaagent:
13021308
- io.reactivex.rxjava3:rxjava:[3.0.0,3.1.0]
13031309
library:
1304-
- io.reactivex.rxjava3:rxjava:3.0.12
1310+
- io.reactivex.rxjava3:rxjava:[3.0.12,3.1.0)
13051311
scala:
13061312
instrumentations:
13071313
- name: scala-fork-join-2.8
@@ -1446,7 +1452,7 @@ spring:
14461452
javaagent:
14471453
- org.springframework.integration:spring-integration-core:[4.1.0.RELEASE,)
14481454
library:
1449-
- org.springframework.integration:spring-integration-core:4.1.0.RELEASE
1455+
- org.springframework.integration:spring-integration-core:[4.1.0.RELEASE,5.+)
14501456
- name: spring-jms-2.0
14511457
srcPath: instrumentation/spring/spring-jms/spring-jms-2.0
14521458
target_versions:

instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/genai/GenAiAttributesGetter.java

-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ public interface GenAiAttributesGetter<REQUEST, RESPONSE> {
5050
@Nullable
5151
Double getRequestTopP(REQUEST request);
5252

53-
@Nullable
5453
List<String> getResponseFinishReasons(REQUEST request, RESPONSE response);
5554

5655
@Nullable

instrumentation-docs/readme.md

+21-11
Original file line numberDiff line numberDiff line change
@@ -39,25 +39,35 @@ public class SpringWebInstrumentationModule extends InstrumentationModule
3939
}
4040
```
4141

42-
## Instrumentation meta-data
42+
## Instrumentation metadata
4343

4444
* name
4545
* Identifier for instrumentation module, used to enable/disable
4646
* Configured in `InstrumentationModule` code for each module
47-
* versions
48-
* List of supported versions by the module
49-
* type
50-
* List of instrumentation types, options of either `library` or `javaagent`
47+
* srcPath
48+
* Path to the source code of the instrumentation module
49+
* description
50+
* Short description of what the instrumentation does
51+
* target_versions
52+
* List of supported versions by the module, broken down by `library` or `javaagent` support
5153

5254
## Methodology
5355

54-
### Versions targeted
56+
### metadata.yaml file
57+
58+
Within each instrumentation source directory, a `metadata.yaml` file can be created to provide
59+
additional information about the instrumentation module.
5560

56-
Javaagent versions are determined by the `muzzle` plugin, so we can attempt to parse the gradle files
61+
As of now, the following fields are supported:
5762

58-
Library versions are determined by the library versions used in the gradle files.
63+
```yaml
64+
description: "Description of what the instrumentation does."
65+
```
66+
67+
### Versions targeted
5968

60-
### TODO / Notes
69+
We parse gradle files in order to determine the target versions.
6170

62-
- Is the `library` dependency actually the target version? Is there a better way to present the information?
63-
- How to handle oshi target version with a conditional?
71+
- Javaagent versions are determined by the `muzzle` plugin configurations
72+
- Library versions are determined by the library dependency versions
73+
- when available, latestDepTestLibrary is used to determine the latest supported version

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

+42-13
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,23 @@
1313
import java.util.regex.Pattern;
1414

1515
class GradleParser {
16-
private static final Pattern passBlockPattern =
17-
Pattern.compile("pass\\s*\\{(.*?)}", Pattern.DOTALL);
18-
19-
private static final Pattern libraryPattern =
20-
Pattern.compile("library\\(\"([^\"]+:[^\"]+:[^\"]+)\"\\)");
2116

2217
private static final Pattern variablePattern =
2318
Pattern.compile("val\\s+(\\w+)\\s*=\\s*\"([^\"]+)\"");
2419

20+
private static final Pattern muzzlePassBlockPattern =
21+
Pattern.compile("pass\\s*\\{(.*?)}", Pattern.DOTALL);
22+
23+
private static final Pattern libraryPattern =
24+
Pattern.compile("library\\(\"([^\"]+:[^\"]+):([^\"]+)\"\\)");
25+
2526
private static final Pattern compileOnlyPattern =
2627
Pattern.compile(
27-
"compileOnly\\(\"([^\"]+)\"\\)\\s*\\{\\s*version\\s*\\{(?:\\s*//.*\\n)*\\s*strictly\\(\"([^\"]+)\"\\)\\s*}\\s*}");
28+
"compileOnly\\(\"([^\"]+:[^\"]+)(?::[^\"]+)?\"\\)\\s*\\{\\s*version\\s*\\{.*?strictly\\(\"([^\"]+)\"\\).*?}\\s*",
29+
Pattern.DOTALL);
30+
31+
private static final Pattern latestDepTestLibraryPattern =
32+
Pattern.compile("latestDepTestLibrary\\(\"([^\"]+:[^\"]+):([^\"]+)\"\\)");
2833

2934
/**
3035
* Parses gradle files for muzzle and dependency information
@@ -55,7 +60,7 @@ public static Set<String> parseGradleFile(String gradleFileContents, Instrumenta
5560
*/
5661
private static Set<String> parseMuzzle(String gradleFileContents, Map<String, String> variables) {
5762
Set<String> results = new HashSet<>();
58-
Matcher passBlockMatcher = passBlockPattern.matcher(gradleFileContents);
63+
Matcher passBlockMatcher = muzzlePassBlockPattern.matcher(gradleFileContents);
5964

6065
while (passBlockMatcher.find()) {
6166
String passBlock = passBlockMatcher.group(1);
@@ -74,26 +79,50 @@ private static Set<String> parseMuzzle(String gradleFileContents, Map<String, St
7479

7580
/**
7681
* Parses the "dependencies" block from the given Gradle file content and extracts information
77-
* about what library versions are supported.
82+
* about what library versions are supported. Looks for library() and compileOnly() blocks for
83+
* lower bounds, and latestDepTestLibrary() for upper bounds.
7884
*
7985
* @param gradleFileContents Contents of a Gradle build file as a String
8086
* @param variables Map of variable names to their values
8187
* @return A set of strings summarizing the group, module, and versions
8288
*/
8389
private static Set<String> parseLibraryDependencies(
8490
String gradleFileContents, Map<String, String> variables) {
85-
Set<String> results = new HashSet<>();
91+
Map<String, String> versions = new HashMap<>();
92+
8693
Matcher libraryMatcher = libraryPattern.matcher(gradleFileContents);
94+
8795
while (libraryMatcher.find()) {
88-
String dependency = libraryMatcher.group(1);
89-
results.add(interpolate(dependency, variables));
96+
String groupAndArtifact = libraryMatcher.group(1);
97+
String version = libraryMatcher.group(2);
98+
versions.put(groupAndArtifact, version);
9099
}
91100

92101
Matcher compileOnlyMatcher = compileOnlyPattern.matcher(gradleFileContents);
93102
while (compileOnlyMatcher.find()) {
94-
String dependency = compileOnlyMatcher.group(1) + ":" + compileOnlyMatcher.group(2);
95-
results.add(interpolate(dependency, variables));
103+
String groupAndArtifact = compileOnlyMatcher.group(1);
104+
String version = compileOnlyMatcher.group(2);
105+
versions.put(groupAndArtifact, version);
96106
}
107+
108+
Matcher latestDepTestLibraryMatcher = latestDepTestLibraryPattern.matcher(gradleFileContents);
109+
while (latestDepTestLibraryMatcher.find()) {
110+
String groupAndArtifact = latestDepTestLibraryMatcher.group(1);
111+
String version = latestDepTestLibraryMatcher.group(2);
112+
if (versions.containsKey(groupAndArtifact)) {
113+
versions.put(groupAndArtifact, versions.get(groupAndArtifact) + "," + version);
114+
}
115+
}
116+
117+
Set<String> results = new HashSet<>();
118+
for (Map.Entry<String, String> entry : versions.entrySet()) {
119+
if (entry.getValue().contains(",")) {
120+
results.add(interpolate(entry.getKey() + ":[" + entry.getValue() + ")", variables));
121+
} else {
122+
results.add(interpolate(entry.getKey() + ":" + entry.getValue(), variables));
123+
}
124+
}
125+
97126
return results;
98127
}
99128

0 commit comments

Comments
 (0)