Skip to content

Commit fb74aa2

Browse files
committed
Merge branch 'main' of github.com:open-telemetry/opentelemetry-java-instrumentation into feat/jdbc-txn-instrumentation
2 parents 54fee2e + 12cbfe9 commit fb74aa2

File tree

22 files changed

+236
-122
lines changed

22 files changed

+236
-122
lines changed

.github/workflows/reusable-markdown-link-check.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
# excluding links to pull requests and issues is done for performance
1818
args: >
1919
--include-fragments
20-
--exclude "^https://github.com/open-telemetry/opentelemetry-java-instrumentation/(issue|pull)/\\d+$"
20+
--exclude "^https://github.com/open-telemetry/opentelemetry-java-instrumentation/(issues|pull)/\\d+$"
2121
--exclude "^http://code.google.com/p/concurrentlinkedhashmap$"
2222
--max-retries 6
2323
.

benchmark-overhead/Dockerfile.petclinic

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM eclipse-temurin:11.0.26_4-jdk@sha256:dbec31f15dc815b1094e4e646c8b33b1e45f1ba8e7b0866b6fb3bbf396217487 as app-build
1+
FROM eclipse-temurin:11.0.26_4-jdk@sha256:8079494e381af731e6abea6123696a5051a054dbb18e5f7f1f73867b3179837f as app-build
22

33
# This is the base image that will contain a built version of the spring-petclinic-rest
44
# application. Installing the dependencies and maven compiling the application is time
@@ -13,7 +13,7 @@ RUN git checkout 8aa4d49
1313
RUN ./mvnw package -Dmaven.test.skip=true
1414
RUN cp target/spring-petclinic-rest*.jar /app/spring-petclinic-rest.jar
1515

16-
FROM bellsoft/liberica-openjdk-alpine:21.0.6@sha256:5f23f8082baea518a1657b420dbe19c181483255209b70af836543d6068fed8c
16+
FROM bellsoft/liberica-openjdk-alpine:21.0.7@sha256:143e4c24da2872fad6803fcbde5d335bbbe47dddb8ebf20fd916c02bdc7f463b
1717
COPY --from=app-build /app/spring-petclinic-rest.jar /app/spring-petclinic-rest.jar
1818
WORKDIR /app
1919
EXPOSE 9966

conventions/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ dependencies {
6767
implementation("net.bytebuddy:byte-buddy-gradle-plugin:1.17.5")
6868
implementation("gradle.plugin.io.morethan.jmhreport:gradle-jmh-report:0.9.6")
6969
implementation("me.champeau.jmh:jmh-gradle-plugin:0.7.3")
70-
implementation("net.ltgt.gradle:gradle-errorprone-plugin:4.1.0")
70+
implementation("net.ltgt.gradle:gradle-errorprone-plugin:4.2.0")
7171
implementation("net.ltgt.gradle:gradle-nullaway-plugin:2.2.0")
7272
implementation("me.champeau.gradle:japicmp-gradle-plugin:0.4.6")
7373

conventions/src/main/kotlin/otel.errorprone-conventions.gradle.kts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ tasks {
6262
disable("UnnecessarilyFullyQualified")
6363

6464
// TODO (trask) use animal sniffer
65-
disable("Java7ApiChecker")
6665
disable("Java8ApiChecker")
6766
disable("AndroidJdkLibsChecker")
6867

@@ -124,8 +123,8 @@ tasks {
124123

125124
disable("NonFinalStaticField")
126125

127-
// We get this warning in modules that compile for old java versions
128-
disable("StringConcatToTextBlock")
126+
// Requires adding compile dependency to JSpecify
127+
disable("AddNullMarkedToPackageInfo")
129128

130129
if (testLatestDeps) {
131130
// Some latest dep tests are compiled for java 17 although the base version uses an older

dependencyManagement/build.gradle.kts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ val DEPENDENCY_BOMS = listOf(
3838

3939
val autoServiceVersion = "1.1.1"
4040
val autoValueVersion = "1.11.0"
41-
val errorProneVersion = "2.37.0"
41+
val errorProneVersion = "2.38.0"
4242
val byteBuddyVersion = "1.17.5"
4343
val asmVersion = "9.8"
4444
val jmhVersion = "1.37"
@@ -82,8 +82,8 @@ val CORE_DEPENDENCIES = listOf(
8282
// this top level to help consistently satisfy large numbers of transitive dependencies.
8383
val DEPENDENCIES = listOf(
8484
"org.junit.jupiter:junit-jupiter-api:5.12.2",
85-
"org.spockframework:spock-core:2.4-M5-groovy-4.0",
86-
"org.spockframework:spock-junit4:2.4-M5-groovy-4.0",
85+
"org.spockframework:spock-core:2.4-M6-groovy-4.0",
86+
"org.spockframework:spock-junit4:2.4-M6-groovy-4.0",
8787

8888
"io.r2dbc:r2dbc-proxy:1.1.5.RELEASE",
8989
"ch.qos.logback:logback-classic:1.3.15", // 1.4+ requires Java 11+

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

Lines changed: 68 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@ class GradleParserTest {
1616
@Test
1717
void testExtractMuzzleVersions_SinglePassBlock() {
1818
String gradleBuildFileContent =
19-
"muzzle {\n"
20-
+ " pass {\n"
21-
+ " group.set(\"org.elasticsearch.client\")\n"
22-
+ " module.set(\"rest\")\n"
23-
+ " versions.set(\"[5.0,6.4)\")\n"
24-
+ " }\n"
25-
+ "}";
19+
"""
20+
muzzle {
21+
pass {
22+
group.set("org.elasticsearch.client")
23+
module.set("rest")
24+
versions.set("[5.0,6.4)")
25+
}
26+
}""";
2627
DependencyInfo info =
2728
GradleParser.parseGradleFile(gradleBuildFileContent, InstrumentationType.JAVAAGENT);
2829
assertThat(info.versions().size()).isEqualTo(1);
@@ -33,7 +34,10 @@ void testExtractMuzzleVersions_SinglePassBlock() {
3334
@Test
3435
void testExtractLibraryVersion() {
3536
String gradleBuildFileContent =
36-
"dependencies {\n" + " library(\"org.apache.httpcomponents:httpclient:4.3\")\n" + "}";
37+
"""
38+
dependencies {
39+
library("org.apache.httpcomponents:httpclient:4.3")
40+
}""";
3741
DependencyInfo info =
3842
GradleParser.parseGradleFile(gradleBuildFileContent, InstrumentationType.LIBRARY);
3943
assertThat(info.versions().size()).isEqualTo(1);
@@ -44,11 +48,12 @@ void testExtractLibraryVersion() {
4448
@Test
4549
void testExtractLibraryUpperVersion() {
4650
String gradleBuildFileContent =
47-
"dependencies {\n"
48-
+ " library(\"org.apache.httpcomponents:httpclient:4.3\")\n"
49-
+ " testImplementation(project(\":instrumentation:apache-httpclient:apache-httpclient-4.3:testing\"))\n"
50-
+ " latestDepTestLibrary(\"org.apache.httpcomponents:httpclient:4.+\") // see apache-httpclient-5.0 module\n"
51-
+ "}";
51+
"""
52+
dependencies {
53+
library("org.apache.httpcomponents:httpclient:4.3")
54+
testImplementation(project(":instrumentation:apache-httpclient:apache-httpclient-4.3:testing"))
55+
latestDepTestLibrary("org.apache.httpcomponents:httpclient:4.+") // see apache-httpclient-5.0 module
56+
}""";
5257

5358
DependencyInfo info =
5459
GradleParser.parseGradleFile(gradleBuildFileContent, InstrumentationType.LIBRARY);
@@ -122,35 +127,37 @@ void testExtractMinimumJavaVersionIgnoredWithinIfCondition() {
122127
@Test
123128
void testExtractMuzzleVersions_MultiplePassBlocks() {
124129
String gradleBuildFileContent =
125-
"plugins {\n"
126-
+ " id(\"otel.javaagent-instrumentation\")\n"
127-
+ " id(\"otel.nullaway-conventions\")\n"
128-
+ " id(\"otel.scala-conventions\")\n"
129-
+ "}\n"
130-
+ "\n"
131-
+ "val zioVersion = \"2.0.0\"\n"
132-
+ "val scalaVersion = \"2.12\"\n"
133-
+ "\n"
134-
+ "muzzle {\n"
135-
+ " pass {\n"
136-
+ " group.set(\"dev.zio\")\n"
137-
+ " module.set(\"zio_2.12\")\n"
138-
+ " versions.set(\"[$zioVersion,)\")\n"
139-
+ " assertInverse.set(true)\n"
140-
+ " }\n"
141-
+ " pass {\n"
142-
+ " group.set(\"dev.zio\")\n"
143-
+ " module.set(\"zio_2.13\")\n"
144-
+ " versions.set(\"[$zioVersion,)\")\n"
145-
+ " assertInverse.set(true)\n"
146-
+ " }\n"
147-
+ " pass {\n"
148-
+ " group.set(\"dev.zio\")\n"
149-
+ " module.set(\"zio_3\")\n"
150-
+ " versions.set(\"[$zioVersion,)\")\n"
151-
+ " assertInverse.set(true)\n"
152-
+ " }\n"
153-
+ "}\n";
130+
"""
131+
plugins {
132+
id("otel.javaagent-instrumentation")
133+
id("otel.nullaway-conventions")
134+
id("otel.scala-conventions")
135+
}
136+
137+
val zioVersion = "2.0.0"
138+
val scalaVersion = "2.12"
139+
140+
muzzle {
141+
pass {
142+
group.set("dev.zio")
143+
module.set("zio_2.12")
144+
versions.set("[$zioVersion,)")
145+
assertInverse.set(true)
146+
}
147+
pass {
148+
group.set("dev.zio")
149+
module.set("zio_2.13")
150+
versions.set("[$zioVersion,)")
151+
assertInverse.set(true)
152+
}
153+
pass {
154+
group.set("dev.zio")
155+
module.set("zio_3")
156+
versions.set("[$zioVersion,)")
157+
assertInverse.set(true)
158+
}
159+
}
160+
""";
154161

155162
DependencyInfo info =
156163
GradleParser.parseGradleFile(gradleBuildFileContent, InstrumentationType.JAVAAGENT);
@@ -162,23 +169,25 @@ void testExtractMuzzleVersions_MultiplePassBlocks() {
162169
@Test
163170
void testExtractLogbackLibrary() {
164171
String gradleBuildFileContent =
165-
"compileOnly(\"ch.qos.logback:logback-classic\") {\n"
166-
+ " version {\n"
167-
+ " // compiling against newer version than the earliest supported version (1.0.0) to support\n"
168-
+ " // features added in 1.3.0\n"
169-
+ " strictly(\"1.3.0\")\n"
170-
+ " }\n"
171-
+ "}\n"
172-
+ "compileOnly(\"org.slf4j:slf4j-api\") {\n"
173-
+ " version {\n"
174-
+ " strictly(\"2.0.0\")\n"
175-
+ " }\n"
176-
+ "}\n"
177-
+ "compileOnly(\"net.logstash.logback:logstash-logback-encoder\") {\n"
178-
+ " version {\n"
179-
+ " strictly(\"3.0\")\n"
180-
+ " }\n"
181-
+ "}\n";
172+
"""
173+
compileOnly("ch.qos.logback:logback-classic") {
174+
version {
175+
// compiling against newer version than the earliest supported version (1.0.0) to support
176+
// features added in 1.3.0
177+
strictly("1.3.0")
178+
}
179+
}
180+
compileOnly("org.slf4j:slf4j-api") {
181+
version {
182+
strictly("2.0.0")
183+
}
184+
}
185+
compileOnly("net.logstash.logback:logstash-logback-encoder") {
186+
version {
187+
strictly("3.0")
188+
}
189+
}
190+
""";
182191

183192
DependencyInfo info =
184193
GradleParser.parseGradleFile(gradleBuildFileContent, InstrumentationType.LIBRARY);

instrumentation/http-url-connection/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/httpurlconnection/HttpUrlConnectionInstrumentation.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import static io.opentelemetry.javaagent.bootstrap.Java8BytecodeBridge.currentContext;
99
import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.extendsClass;
1010
import static io.opentelemetry.javaagent.instrumentation.httpurlconnection.HttpUrlConnectionSingletons.instrumenter;
11-
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
11+
import static net.bytebuddy.matcher.ElementMatchers.isProtected;
1212
import static net.bytebuddy.matcher.ElementMatchers.isPublic;
1313
import static net.bytebuddy.matcher.ElementMatchers.nameStartsWith;
1414
import static net.bytebuddy.matcher.ElementMatchers.named;
@@ -25,16 +25,15 @@
2525
import net.bytebuddy.asm.Advice;
2626
import net.bytebuddy.description.type.TypeDescription;
2727
import net.bytebuddy.matcher.ElementMatcher;
28-
import net.bytebuddy.matcher.ElementMatchers;
2928

3029
public class HttpUrlConnectionInstrumentation implements TypeInstrumentation {
3130
@Override
3231
public ElementMatcher<TypeDescription> typeMatcher() {
3332
return nameStartsWith("java.net.")
34-
.or(ElementMatchers.<TypeDescription>nameStartsWith("sun.net"))
33+
.or(nameStartsWith("sun.net"))
3534
// In WebLogic, URL.openConnection() returns its own internal implementation of
3635
// HttpURLConnection, which does not delegate the methods that have to be instrumented to
37-
// the JDK superclass. Therefore it needs to be instrumented directly.
36+
// the JDK superclass. Therefore, it needs to be instrumented directly.
3837
.or(named("weblogic.net.http.HttpURLConnection"))
3938
// This class is a simple delegator. Skip because it does not update its `connected`
4039
// field.
@@ -45,10 +44,13 @@ public ElementMatcher<TypeDescription> typeMatcher() {
4544
@Override
4645
public void transform(TypeTransformer transformer) {
4746
transformer.applyAdviceToMethod(
48-
isMethod().and(isPublic()).and(namedOneOf("connect", "getOutputStream", "getInputStream")),
47+
isPublic()
48+
.and(namedOneOf("connect", "getOutputStream", "getInputStream"))
49+
// ibm https url connection does not delegate connect, it calls plainConnect instead
50+
.or(isProtected().and(named("plainConnect"))),
4951
this.getClass().getName() + "$HttpUrlConnectionAdvice");
5052
transformer.applyAdviceToMethod(
51-
isMethod().and(isPublic()).and(named("getResponseCode")),
53+
isPublic().and(named("getResponseCode")),
5254
this.getClass().getName() + "$GetResponseCodeAdvice");
5355
}
5456

instrumentation/jmx-metrics/library/jvm.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Here is the list of metrics based on MBeans exposed by the JVM and that are defi
55
Those metrics are defined in the [JVM runtime metrics semantic conventions](https://opentelemetry.io/docs/specs/semconv/runtime/jvm-metrics/).
66

77
| Metric Name | semconv maturity | Type | Attributes | Description |
8-
|---------------------------------------------------------------------------------------------------------------------------------------|:-----------------|---------------|---------------------------------------|----------------------------------------------------|
8+
| ------------------------------------------------------------------------------------------------------------------------------------- | :--------------- | ------------- | ------------------------------------- | -------------------------------------------------- |
99
| [jvm.memory.used](https://opentelemetry.io/docs/specs/semconv/runtime/jvm-metrics/#metric-jvmmemoryused) | stable | UpDownCounter | jvm.memory.pool.name, jvm.memory.type | Used memory |
1010
| [jvm.memory.committed](https://opentelemetry.io/docs/specs/semconv/runtime/jvm-metrics/#metric-jvmmemorycommitted) | stable | UpDownCounter | jvm.memory.pool.name, jvm.memory.type | Committed memory |
1111
| [jvm.memory.limit](https://opentelemetry.io/docs/specs/semconv/runtime/jvm-metrics/#metric-jvmmemorylimit) | stable | UpDownCounter | jvm.memory.pool.name, jvm.memory.type | Max obtainable memory |
@@ -17,6 +17,7 @@ Those metrics are defined in the [JVM runtime metrics semantic conventions](http
1717
| [jvm.class.count](https://opentelemetry.io/docs/specs/semconv/runtime/jvm-metrics/#metric-jvmclasscount) | stable | UpDownCounter | | Classes currently loaded count |
1818
| [jvm.cpu.count](https://opentelemetry.io/docs/specs/semconv/runtime/jvm-metrics/#metric-jvmcpucount) | stable | UpDownCounter | | Number of CPUs available |
1919
| [jvm.cpu.recent_utilization](https://opentelemetry.io/docs/specs/semconv/runtime/jvm-metrics/#metric-jvmcpurecent_utilization) | stable | Gauge | | Recent CPU utilization for process reported by JVM |
20+
| [jvm.file_descriptor.count](https://opentelemetry.io/docs/specs/semconv/runtime/jvm-metrics/#metric-jvmfile_descriptorcount) | experimental | UpDownCounter | | Number of open file descriptors |
2021
| [jvm.system.cpu.load_1m](https://opentelemetry.io/docs/specs/semconv/runtime/jvm-metrics/#metric-jvmsystemcpuload_1m) | experimental | Gauge | | Average CPU load reported by JVM |
2122
| [jvm.system.cpu.recent_utilization](https://opentelemetry.io/docs/specs/semconv/runtime/jvm-metrics/#metric-jvmcpurecent_utilization) | experimental | Gauge | | Recent CPU utilization reported by JVM |
2223
| [jvm.buffer.memory.used](https://opentelemetry.io/docs/specs/semconv/runtime/jvm-metrics/#metric-jvmbuffermemoryused) | experimental | UpDownCounter | jvm.buffer.pool.name | Memory used by buffers |

instrumentation/jmx-metrics/library/src/main/resources/jmx/rules/jvm.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,12 @@ rules:
9696
type: gauge
9797
unit: '1'
9898
desc: Recent CPU utilization for the whole system as reported by the JVM.
99+
# jvm.file_descriptor.count (experimental)
100+
OpenFileDescriptorCount:
101+
metric: file_descriptor.count
102+
type: updowncounter
103+
unit: "{file_descriptor}"
104+
desc: Number of open file descriptors as reported by the JVM.
99105

100106
- bean: java.nio:name=*,type=BufferPool
101107
prefix: jvm.buffer.

instrumentation/jmx-metrics/library/src/test/java/io/opentelemetry/instrumentation/jmx/rules/JvmTargetSystemTest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,14 @@ void testJvmMetrics(String image) {
162162
.hasUnit("1")
163163
.isGauge()
164164
.hasDataPointsWithoutAttributes())
165+
.add(
166+
"jvm.file_descriptor.count",
167+
metric ->
168+
metric
169+
.hasDescription("Number of open file descriptors as reported by the JVM.")
170+
.hasUnit("{file_descriptor}")
171+
.isUpDownCounter()
172+
.hasDataPointsWithoutAttributes())
165173
.add(
166174
"jvm.system.cpu.load_1m",
167175
metric ->

0 commit comments

Comments
 (0)