Skip to content

Commit daf1811

Browse files
authored
Merge branch 'main' into r2dbc-db-system
2 parents bff4c30 + a6b1096 commit daf1811

138 files changed

Lines changed: 1755 additions & 859 deletions

File tree

Some content is hidden

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

.fossa.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -928,9 +928,6 @@ targets:
928928
- type: gradle
929929
path: ./
930930
target: ':instrumentation:rxjava:rxjava-2.0:library'
931-
- type: gradle
932-
path: ./
933-
target: ':instrumentation:rxjava:rxjava-3-common:library'
934931
- type: gradle
935932
path: ./
936933
target: ':instrumentation:rxjava:rxjava-3.0:javaagent'
@@ -943,6 +940,9 @@ targets:
943940
- type: gradle
944941
path: ./
945942
target: ':instrumentation:rxjava:rxjava-3.1.1:library'
943+
- type: gradle
944+
path: ./
945+
target: ':instrumentation:rxjava:rxjava-common-3.0:library'
946946
- type: gradle
947947
path: ./
948948
target: ':instrumentation:servlet:servlet-2.2:javaagent'

.github/scripts/check-package-names.sh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@ for dir in $(find instrumentation -name "*.java" | grep library/src/main/java |
2525
if [[ "$module_name" == "graphql-java-common" ]]; then
2626
continue
2727
fi
28-
if [[ "$module_name" == "rxjava-3-common" ]]; then
29-
continue
30-
fi
3128
if [[ "$module_name" == "servlet-javax-common" ]]; then
3229
continue
3330
fi

.github/workflows/build-common.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ jobs:
248248
- 21
249249
- 25 # renovate(java-version)
250250
- 25-deny-unsafe
251+
- 26-ea
251252
vm:
252253
- hotspot
253254
- openj9
@@ -263,6 +264,8 @@ jobs:
263264
- vm: ${{ inputs.skip-openj9-tests && 'openj9' || '' }}
264265
- test-java-version: 25-deny-unsafe
265266
vm: openj9
267+
- test-java-version: 26-ea
268+
vm: openj9
266269
fail-fast: false
267270
steps:
268271
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

.github/workflows/metadata-update.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ jobs:
8383
8484
- name: Commit and push changes
8585
if: steps.diffcheck.outputs.has_diff == 'true'
86+
env:
87+
GH_TOKEN: ${{ steps.otelbot-token.outputs.token }}
8688
run: |
8789
BRANCH_NAME="${{ steps.findbranch.outputs.branch }}"
8890
git commit -m "chore: update instrumentation list [automated]" || echo "No changes to commit."

conventions/src/main/kotlin/io/opentelemetry/instrumentation/gradle/StaticImportFormatter.kt

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,9 @@ class StaticImportFormatter : FormatterFunc, Serializable {
9191
content
9292
.lines()
9393
.mapNotNull { line -> semconvImportRegex.find(line.trim()) }
94-
.filter { it.groupValues[2] != "SchemaUrls" }
94+
.filter { it.groupValues[2] != "SchemaUrls" && it.groupValues[3].isEmpty() }
9595
.map { m ->
96-
// If there is a nested class (group 3), use the nested class as the className so that
97-
// references like `DbSystemNameIncubatingValues.COUCHBASE` are rewritten correctly.
98-
val className = if (m.groupValues[3].isNotEmpty()) m.groupValues[3] else m.groupValues[2]
99-
Triple(className, m.groupValues[1], "[A-Z][A-Z_0-9]*")
96+
Triple(m.groupValues[2], m.groupValues[1], "[A-Z][A-Z_0-9]*")
10097
}
10198
for ((className, pkg, memberPattern) in semconvRules) {
10299
val regex = Regex("\\b${className}\\.(${memberPattern})\\b")
@@ -118,6 +115,37 @@ class StaticImportFormatter : FormatterFunc, Serializable {
118115
content = lines.joinToString("\n")
119116
}
120117

118+
// Handle nested value class references through the outer class, e.g.
119+
// DbIncubatingAttributes.DbSystemNameIncubatingValues.CASSANDRA when only
120+
// DbIncubatingAttributes is imported (not the nested class directly).
121+
// Rewrites to NestedClass.CONSTANT and adds a regular import of the nested class.
122+
val outerOnlySemconvImports =
123+
content
124+
.lines()
125+
.mapNotNull { line -> semconvImportRegex.find(line.trim()) }
126+
.filter { it.groupValues[2] != "SchemaUrls" && it.groupValues[3].isEmpty() }
127+
.map { m -> Pair(m.groupValues[2], m.groupValues[1]) }
128+
for ((outerClassName, outerPkg) in outerOnlySemconvImports) {
129+
val regex =
130+
Regex("\\b${outerClassName}\\.([A-Z][a-zA-Z0-9]*[a-z][a-zA-Z0-9]*)\\.([A-Z][A-Z_0-9]+)\\b")
131+
val lines = content.lines().toMutableList()
132+
var inBlockComment = false
133+
for (i in lines.indices) {
134+
val trimmed = lines[i].trimStart()
135+
if (trimmed.startsWith("/*")) inBlockComment = true
136+
if (inBlockComment) {
137+
if (trimmed.contains("*/")) inBlockComment = false
138+
continue
139+
}
140+
if (trimmed.startsWith("import ")) continue
141+
for (match in regex.findAll(lines[i])) {
142+
importsToAdd.add("import ${outerPkg}.${match.groupValues[1]};")
143+
}
144+
lines[i] = regex.replace(lines[i], "$1.$2")
145+
}
146+
content = lines.joinToString("\n")
147+
}
148+
121149
if (importsToAdd.isNotEmpty()) {
122150
val lines = content.lines().toMutableList()
123151
val firstImportIndex = lines.indexOfFirst { it.trimStart().startsWith("import ") }

custom-checks/src/main/java/io/opentelemetry/javaagent/customchecks/OtelUnnecessarilyFullyQualified.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import static com.google.errorprone.util.ASTHelpers.getGeneratedBy;
2828
import static com.google.errorprone.util.ASTHelpers.getSymbol;
2929
import static com.google.errorprone.util.ASTHelpers.getType;
30+
import static com.google.errorprone.util.ASTHelpers.hasExplicitSource;
3031
import static com.google.errorprone.util.ASTHelpers.isGeneratedConstructor;
3132
import static com.google.errorprone.util.FindIdentifiers.findIdent;
3233
import static com.sun.tools.javac.code.Kinds.KindSelector.VAL_TYP;
@@ -64,7 +65,6 @@
6465
import com.sun.tools.javac.code.Symbol.PackageSymbol;
6566
import com.sun.tools.javac.code.Symbol.TypeSymbol;
6667
import com.sun.tools.javac.code.Type;
67-
import com.sun.tools.javac.util.Position;
6868
import java.util.ArrayList;
6969
import java.util.HashSet;
7070
import java.util.List;
@@ -235,7 +235,7 @@ private void handle(TreePath path) {
235235
if (isDeprecatedForRemoval(symbol)) {
236236
return;
237237
}
238-
if (state.getEndPosition(tree) == Position.NOPOS) {
238+
if (!hasExplicitSource(tree, state)) {
239239
return;
240240
}
241241
List<TreePath> treePaths = table.get(tree.getIdentifier(), symbol.type.tsym);

custom-checks/src/test/java/io/opentelemetry/javaagent/customchecks/OtelDeprecatedApiUsageTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,9 @@ void positiveCases_externalDeprecatedApi() {
161161
"ExternalDeprecated.java",
162162
"package test;",
163163
"public class ExternalDeprecated {",
164-
" void method(Thread t) {",
164+
" void method() {",
165165
" // BUG: Diagnostic contains: Use of deprecated API",
166-
" t.stop();",
166+
" new Boolean(false);",
167167
" }",
168168
"}")
169169
.doTest();

docs/instrumentation-list.yaml

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2403,14 +2403,6 @@ libraries:
24032403
spans:
24042404
- span_kind: CLIENT
24052405
attributes:
2406-
- name: db.namespace
2407-
type: STRING
2408-
- name: db.query.summary
2409-
type: STRING
2410-
- name: db.query.text
2411-
type: STRING
2412-
- name: db.system.name
2413-
type: STRING
24142406
- name: http.request.method
24152407
type: STRING
24162408
- name: http.response.status_code
@@ -5441,12 +5433,24 @@ libraries:
54415433
library_link: https://javalin.io/
54425434
features:
54435435
- HTTP_ROUTE
5444-
source_path: instrumentation/javalin-5.0
5436+
source_path: instrumentation/javalin/javalin-5.0
54455437
minimum_java_version: 11
54465438
scope:
54475439
name: io.opentelemetry.javalin-5.0
54485440
javaagent_target_versions:
5449-
- io.javalin:javalin:[5.0.0,)
5441+
- io.javalin:javalin:[5.0.0,7.0.0)
5442+
- name: javalin-7.0
5443+
description: This instrumentation enriches existing HTTP server spans with route
5444+
information, it does not emit any telemetry on its own.
5445+
library_link: https://javalin.io/
5446+
features:
5447+
- HTTP_ROUTE
5448+
source_path: instrumentation/javalin/javalin-7.0
5449+
minimum_java_version: 17
5450+
scope:
5451+
name: io.opentelemetry.javalin-7.0
5452+
javaagent_target_versions:
5453+
- io.javalin:javalin:[7.0.0,)
54505454
jaxrs:
54515455
- name: jaxrs-1.0
54525456
display_name: JAX-RS 1.x
@@ -8177,6 +8181,8 @@ libraries:
81778181
spans:
81788182
- span_kind: CLIENT
81798183
attributes:
8184+
- name: db.operation
8185+
type: STRING
81808186
- name: db.statement
81818187
type: STRING
81828188
- name: db.system
@@ -8200,6 +8206,8 @@ libraries:
82008206
type: HISTOGRAM
82018207
unit: s
82028208
attributes:
8209+
- name: db.operation.name
8210+
type: STRING
82038211
- name: db.system.name
82048212
type: STRING
82058213
- name: network.peer.address
@@ -8213,11 +8221,13 @@ libraries:
82138221
spans:
82148222
- span_kind: CLIENT
82158223
attributes:
8224+
- name: db.operation.name
8225+
type: STRING
82168226
- name: db.query.text
82178227
type: STRING
82188228
- name: db.system.name
82198229
type: STRING
8220-
- name: error
8230+
- name: error.type
82218231
type: STRING
82228232
- name: network.peer.address
82238233
type: STRING

instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesExtractor.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import static io.opentelemetry.semconv.DbAttributes.DB_OPERATION_NAME;
1313
import static io.opentelemetry.semconv.DbAttributes.DB_QUERY_SUMMARY;
1414
import static io.opentelemetry.semconv.DbAttributes.DB_QUERY_TEXT;
15-
import static io.opentelemetry.semconv.DbAttributes.DB_RESPONSE_STATUS_CODE;
1615
import static io.opentelemetry.semconv.DbAttributes.DB_SYSTEM_NAME;
1716
import static io.opentelemetry.semconv.ErrorAttributes.ERROR_TYPE;
1817

@@ -136,21 +135,22 @@ public void onEnd(
136135
@Nullable RESPONSE response,
137136
@Nullable Throwable error) {
138137
internalNetworkExtractor.onEnd(attributes, request, response);
139-
onEndCommon(attributes, getter, response, error);
138+
onEndCommon(attributes, getter, request, response, error);
140139
}
141140

142141
static <REQUEST, RESPONSE> void onEndCommon(
143142
AttributesBuilder attributes,
144143
DbClientAttributesGetter<REQUEST, RESPONSE> getter,
144+
REQUEST request,
145145
@Nullable RESPONSE response,
146146
@Nullable Throwable error) {
147147
if (emitStableDatabaseSemconv()) {
148-
if (error != null) {
149-
attributes.put(ERROR_TYPE, error.getClass().getName());
150-
}
151-
if (error != null || response != null) {
152-
attributes.put(DB_RESPONSE_STATUS_CODE, getter.getDbResponseStatusCode(response, error));
148+
String errorType = getter.getErrorType(request, response, error);
149+
// fall back to exception class name
150+
if (errorType == null && error != null) {
151+
errorType = error.getClass().getName();
153152
}
153+
attributes.put(ERROR_TYPE, errorType);
154154
}
155155
}
156156

instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesGetter.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ default String getConnectionString(REQUEST request) {
7979

8080
// TODO: make this required to implement
8181
@Nullable
82+
@Deprecated
8283
default String getDbResponseStatusCode(@Nullable RESPONSE response, @Nullable Throwable error) {
8384
return null;
8485
}
@@ -93,4 +94,20 @@ default Long getDbOperationBatchSize(REQUEST request) {
9394
default Map<String, String> getDbQueryParameters(REQUEST request) {
9495
return emptyMap();
9596
}
97+
98+
/**
99+
* Returns a description of a class of error the operation ended with.
100+
*
101+
* <p>If this method returns {@code null}, the exception class name (if any) will be used as error
102+
* type.
103+
*
104+
* <p>The cardinality of the error type should be low. The instrumentations implementing this
105+
* method are recommended to document the custom values they support.
106+
*/
107+
@Nullable
108+
// TODO remove the default implementation and make this required to implement
109+
default String getErrorType(
110+
REQUEST request, @Nullable RESPONSE response, @Nullable Throwable error) {
111+
return null;
112+
}
96113
}

0 commit comments

Comments
 (0)