Skip to content

Commit 4168cf9

Browse files
authored
Merge branch 'main' into remove-declarative-config-bridge-from-agent
2 parents 2c3a9f7 + bea3bd7 commit 4168cf9

File tree

134 files changed

+1103
-518
lines changed

Some content is hidden

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

134 files changed

+1103
-518
lines changed

.fossa.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -892,6 +892,15 @@ targets:
892892
- type: gradle
893893
path: ./
894894
target: ':instrumentation:restlet:restlet-2.0:library'
895+
- type: gradle
896+
path: ./
897+
target: ':instrumentation:rocketmq:rocketmq-client-4.8:javaagent'
898+
- type: gradle
899+
path: ./
900+
target: ':instrumentation:rocketmq:rocketmq-client-4.8:library'
901+
- type: gradle
902+
path: ./
903+
target: ':instrumentation:rocketmq:rocketmq-client-5.0:javaagent'
895904
- type: gradle
896905
path: ./
897906
target: ':instrumentation:runtime-telemetry:runtime-telemetry-java17:javaagent'
@@ -1132,15 +1141,6 @@ targets:
11321141
- type: gradle
11331142
path: ./
11341143
target: ':instrumentation:reactor:reactor-netty:reactor-netty-1.0:javaagent'
1135-
- type: gradle
1136-
path: ./
1137-
target: ':instrumentation:rocketmq:rocketmq-client:rocketmq-client-4.8:javaagent'
1138-
- type: gradle
1139-
path: ./
1140-
target: ':instrumentation:rocketmq:rocketmq-client:rocketmq-client-4.8:library'
1141-
- type: gradle
1142-
path: ./
1143-
target: ':instrumentation:rocketmq:rocketmq-client:rocketmq-client-5.0:javaagent'
11441144
- type: gradle
11451145
path: ./
11461146
target: ':instrumentation:spring:spring-cloud-gateway:spring-cloud-gateway-2.0:javaagent'

docs/instrumentation-list.yaml

Lines changed: 148 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11358,21 +11358,167 @@ libraries:
1135811358
- Java 8+
1135911359
rocketmq:
1136011360
- name: rocketmq-client-4.8
11361-
source_path: instrumentation/rocketmq/rocketmq-client/rocketmq-client-4.8
11361+
display_name: Apache RocketMQ Client - Remoting Protocol
11362+
description: |
11363+
This instrumentation enables messaging spans for Apache RocketMQ message producers and consumers using the Remoting Protocol.
11364+
semantic_conventions:
11365+
- MESSAGING_SPANS
11366+
library_link: https://rocketmq.apache.org/
11367+
source_path: instrumentation/rocketmq/rocketmq-client-4.8
1136211368
scope:
1136311369
name: io.opentelemetry.rocketmq-client-4.8
1136411370
target_versions:
1136511371
javaagent:
1136611372
- org.apache.rocketmq:rocketmq-client:[4.0.0,)
1136711373
library:
1136811374
- org.apache.rocketmq:rocketmq-client:4.8.0
11375+
configurations:
11376+
- name: otel.instrumentation.messaging.experimental.capture-headers
11377+
description: |
11378+
Enables capturing messaging headers as span attributes. Provide a comma-separated list of header names to capture.
11379+
type: list
11380+
default: ''
11381+
- name: otel.instrumentation.rocketmq-client.experimental-span-attributes
11382+
description: |
11383+
Enables capturing experimental span attributes `messaging.rocketmq.message.tag`, `messaging.rocketmq.broker_address`, `messaging.rocketmq.send_result`, `messaging.rocketmq.queue_id`, and `messaging.rocketmq.queue_offset`.
11384+
type: boolean
11385+
default: false
11386+
telemetry:
11387+
- when: default
11388+
spans:
11389+
- span_kind: CONSUMER
11390+
attributes:
11391+
- name: messaging.destination.name
11392+
type: STRING
11393+
- name: messaging.message.body.size
11394+
type: LONG
11395+
- name: messaging.message.id
11396+
type: STRING
11397+
- name: messaging.operation
11398+
type: STRING
11399+
- name: messaging.system
11400+
type: STRING
11401+
- span_kind: PRODUCER
11402+
attributes:
11403+
- name: messaging.destination.name
11404+
type: STRING
11405+
- name: messaging.message.id
11406+
type: STRING
11407+
- name: messaging.operation
11408+
type: STRING
11409+
- name: messaging.system
11410+
type: STRING
11411+
- when: otel.instrumentation.rocketmq-client.experimental-span-attributes=true
11412+
spans:
11413+
- span_kind: CONSUMER
11414+
attributes:
11415+
- name: messaging.destination.name
11416+
type: STRING
11417+
- name: messaging.message.body.size
11418+
type: LONG
11419+
- name: messaging.message.id
11420+
type: STRING
11421+
- name: messaging.operation
11422+
type: STRING
11423+
- name: messaging.rocketmq.broker_address
11424+
type: STRING
11425+
- name: messaging.rocketmq.message.tag
11426+
type: STRING
11427+
- name: messaging.rocketmq.queue_id
11428+
type: LONG
11429+
- name: messaging.rocketmq.queue_offset
11430+
type: LONG
11431+
- name: messaging.system
11432+
type: STRING
11433+
- span_kind: PRODUCER
11434+
attributes:
11435+
- name: messaging.destination.name
11436+
type: STRING
11437+
- name: messaging.message.id
11438+
type: STRING
11439+
- name: messaging.operation
11440+
type: STRING
11441+
- name: messaging.rocketmq.broker_address
11442+
type: STRING
11443+
- name: messaging.rocketmq.message.tag
11444+
type: STRING
11445+
- name: messaging.rocketmq.send_result
11446+
type: STRING
11447+
- name: messaging.system
11448+
type: STRING
1136911449
- name: rocketmq-client-5.0
11370-
source_path: instrumentation/rocketmq/rocketmq-client/rocketmq-client-5.0
11450+
display_name: Apache RocketMQ Client - gRPC Protocol
11451+
description: |
11452+
This instrumentation enables messaging spans for Apache RocketMQ message producers and consumers using the gRPC/Protobuf Protocol.
11453+
semantic_conventions:
11454+
- MESSAGING_SPANS
11455+
library_link: https://rocketmq.apache.org/
11456+
source_path: instrumentation/rocketmq/rocketmq-client-5.0
1137111457
scope:
1137211458
name: io.opentelemetry.rocketmq-client-5.0
1137311459
target_versions:
1137411460
javaagent:
1137511461
- org.apache.rocketmq:rocketmq-client-java:[5.0.0,)
11462+
configurations:
11463+
- name: otel.instrumentation.messaging.experimental.receive-telemetry.enabled
11464+
description: |
11465+
Enables experimental receive telemetry, which will cause consumers to start a new trace, with only a span link connecting it to the producer trace.
11466+
type: boolean
11467+
default: false
11468+
- name: otel.instrumentation.messaging.experimental.capture-headers
11469+
description: |
11470+
Enables capturing messaging headers as span attributes. Provide a comma-separated list of header names to capture.
11471+
type: list
11472+
default: ''
11473+
telemetry:
11474+
- when: default
11475+
spans:
11476+
- span_kind: CONSUMER
11477+
attributes:
11478+
- name: messaging.batch.message_count
11479+
type: LONG
11480+
- name: messaging.destination.name
11481+
type: STRING
11482+
- name: messaging.message.body.size
11483+
type: LONG
11484+
- name: messaging.message.id
11485+
type: STRING
11486+
- name: messaging.operation
11487+
type: STRING
11488+
- name: messaging.rocketmq.client_group
11489+
type: STRING
11490+
- name: messaging.rocketmq.message.delivery_timestamp
11491+
type: LONG
11492+
- name: messaging.rocketmq.message.group
11493+
type: STRING
11494+
- name: messaging.rocketmq.message.keys
11495+
type: STRING_ARRAY
11496+
- name: messaging.rocketmq.message.tag
11497+
type: STRING
11498+
- name: messaging.system
11499+
type: STRING
11500+
- span_kind: PRODUCER
11501+
attributes:
11502+
- name: messaging.destination.name
11503+
type: STRING
11504+
- name: messaging.message.body.size
11505+
type: LONG
11506+
- name: messaging.message.id
11507+
type: STRING
11508+
- name: messaging.operation
11509+
type: STRING
11510+
- name: messaging.rocketmq.message.delivery_timestamp
11511+
type: LONG
11512+
- name: messaging.rocketmq.message.group
11513+
type: STRING
11514+
- name: messaging.rocketmq.message.keys
11515+
type: STRING_ARRAY
11516+
- name: messaging.rocketmq.message.tag
11517+
type: STRING
11518+
- name: messaging.rocketmq.message.type
11519+
type: STRING
11520+
- name: messaging.system
11521+
type: STRING
1137611522
runtime:
1137711523
- name: runtime-telemetry-java17
1137811524
source_path: instrumentation/runtime-telemetry/runtime-telemetry-java17

docs/supported-libraries.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ These are the supported libraries and frameworks:
4242
| [Apache Pekko HTTP](https://pekko.apache.org/) | 1.0+ | N/A | [HTTP Client Spans], [HTTP Client Metrics], [HTTP Server Spans], [HTTP Server Metrics], Provides `http.route` [2] |
4343
| [Apache Pulsar](https://pulsar.apache.org/) | 2.8+ | N/A | [Messaging Spans] |
4444
| [Apache RocketMQ gRPC/Protobuf-based Client](https://rocketmq.apache.org/) | 5.0+ | N/A | [Messaging Spans] |
45-
| [Apache RocketMQ Remoting-based Client](https://rocketmq.apache.org/) | 4.8+ | [opentelemetry-rocketmq-client-4.8](../instrumentation/rocketmq/rocketmq-client/rocketmq-client-4.8/library) | [Messaging Spans] |
45+
| [Apache RocketMQ Remoting-based Client](https://rocketmq.apache.org/) | 4.8+ | [opentelemetry-rocketmq-client-4.8](../instrumentation/rocketmq/rocketmq-client-4.8/library) | [Messaging Spans] |
4646
| [Apache Struts](https://github.com/apache/struts) | 2.3+ | N/A | Provides `http.route` [2], Controller Spans [3] |
4747
| [Apache Tapestry](https://tapestry.apache.org/) | 5.4+ | N/A | Provides `http.route` [2], Controller Spans [3] |
4848
| [Apache Wicket](https://wicket.apache.org/) | 8.0+ | N/A | Provides `http.route` [2] |

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

Lines changed: 77 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,70 @@ protected String computeSpanName(
6161
return spanName.toString();
6262
}
6363

64+
/**
65+
* Computes the span name following stable semconv fallback order.
66+
*
67+
* <p>Fallback order:
68+
*
69+
* <ol>
70+
* <li>{db.operation.name} {target} if operation is available
71+
* <li>{target} if only target is available
72+
* <li>{db.system.name} if nothing else is available
73+
* </ol>
74+
*
75+
* <p>Target fallback order:
76+
*
77+
* <ol>
78+
* <li>{db.collection.name}
79+
* <li>{db.stored_procedure.name}
80+
* <li>{db.namespace}
81+
* <li>{server.address:server.port}
82+
* </ol>
83+
*/
84+
protected String computeSpanNameStable(
85+
DbClientAttributesGetter<REQUEST, ?> getter,
86+
REQUEST request,
87+
@Nullable String operation,
88+
@Nullable String collectionName,
89+
@Nullable String storedProcedureName) {
90+
91+
String target = collectionName;
92+
if (target == null) {
93+
target = storedProcedureName;
94+
}
95+
if (target == null) {
96+
target = getter.getDbNamespace(request);
97+
}
98+
if (target == null) {
99+
String serverAddress = getter.getServerAddress(request);
100+
if (serverAddress != null) {
101+
Integer serverPort = getter.getServerPort(request);
102+
if (serverPort != null) {
103+
target = serverAddress + ":" + serverPort;
104+
} else {
105+
target = serverAddress;
106+
}
107+
}
108+
}
109+
110+
// Build span name
111+
if (operation != null) {
112+
if (target != null) {
113+
return operation + " " + target;
114+
}
115+
return operation;
116+
}
117+
118+
// No operation - use target alone
119+
if (target != null) {
120+
return target;
121+
}
122+
123+
// Final fallback to db.system.name (required attribute per spec)
124+
String dbSystem = getter.getDbSystemName(request);
125+
return dbSystem != null ? dbSystem : DEFAULT_SPAN_NAME;
126+
}
127+
64128
private static final class GenericDbClientSpanNameExtractor<REQUEST>
65129
extends DbClientSpanNameExtractor<REQUEST> {
66130

@@ -74,6 +138,9 @@ private GenericDbClientSpanNameExtractor(DbClientAttributesGetter<REQUEST, ?> ge
74138
public String extract(REQUEST request) {
75139
String namespace = getter.getDbNamespace(request);
76140
String operationName = getter.getDbOperationName(request);
141+
if (SemconvStability.emitStableDatabaseSemconv()) {
142+
return computeSpanNameStable(getter, request, operationName, null, null);
143+
}
77144
return computeSpanName(namespace, operationName, null, null);
78145
}
79146
}
@@ -93,6 +160,9 @@ public String extract(REQUEST request) {
93160
Collection<String> rawQueryTexts = getter.getRawQueryTexts(request);
94161

95162
if (rawQueryTexts.isEmpty()) {
163+
if (SemconvStability.emitStableDatabaseSemconv()) {
164+
return computeSpanNameStable(getter, request, null, null, null);
165+
}
96166
return computeSpanName(namespace, null, null, null);
97167
}
98168

@@ -117,19 +187,19 @@ public String extract(REQUEST request) {
117187
if (isBatch(request)) {
118188
operationName = "BATCH " + operationName;
119189
}
120-
return computeSpanName(
121-
namespace,
190+
return computeSpanNameStable(
191+
getter,
192+
request,
122193
operationName,
123194
sanitizedStatement.getCollectionName(),
124195
sanitizedStatement.getStoredProcedureName());
125196
}
126197

127198
MultiQuery multiQuery = MultiQuery.analyze(rawQueryTexts, false);
128-
return computeSpanName(
129-
namespace,
130-
multiQuery.getOperationName() != null
131-
? "BATCH " + multiQuery.getOperationName()
132-
: "BATCH",
199+
return computeSpanNameStable(
200+
getter,
201+
request,
202+
multiQuery.getOperationName(),
133203
multiQuery.getCollectionName(),
134204
multiQuery.getStoredProcedureName());
135205
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,11 @@ static MultiQuery analyze(
4646
statementSanitizationEnabled ? sanitizedStatement.getQueryText() : rawQueryText);
4747
}
4848

49+
String operationName = uniqueOperationName.getValue();
4950
return new MultiQuery(
5051
uniqueCollectionName.getValue(),
5152
uniqueStoredProcedureName.getValue(),
52-
uniqueOperationName.getValue(),
53+
operationName == null ? "BATCH" : "BATCH " + operationName,
5354
uniqueQueryTexts);
5455
}
5556

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,7 @@ public void onStart(AttributesBuilder attributes, Context parentContext, REQUEST
124124
MultiQuery multiQuery =
125125
MultiQuery.analyze(getter.getRawQueryTexts(request), statementSanitizationEnabled);
126126
internalSet(attributes, DB_QUERY_TEXT, join("; ", multiQuery.getQueryTexts()));
127-
128-
String operationName =
129-
multiQuery.getOperationName() != null
130-
? "BATCH " + multiQuery.getOperationName()
131-
: "BATCH";
132-
internalSet(attributes, DB_OPERATION_NAME, operationName);
127+
internalSet(attributes, DB_OPERATION_NAME, multiQuery.getOperationName());
133128
internalSet(attributes, DB_COLLECTION_NAME, multiQuery.getCollectionName());
134129
internalSet(attributes, DB_STORED_PROCEDURE_NAME, multiQuery.getStoredProcedureName());
135130
}

instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientSpanNameExtractorTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
package io.opentelemetry.instrumentation.api.incubator.semconv.db;
77

8+
import static io.opentelemetry.instrumentation.api.internal.SemconvStability.emitStableDatabaseSemconv;
89
import static java.util.Collections.singleton;
910
import static org.junit.jupiter.api.Assertions.assertEquals;
1011
import static org.mockito.Mockito.when;
@@ -37,7 +38,7 @@ void shouldExtractFullSpanName() {
3738
String spanName = underTest.extract(dbRequest);
3839

3940
// then
40-
assertEquals("SELECT database.table", spanName);
41+
assertEquals(emitStableDatabaseSemconv() ? "SELECT table" : "SELECT database.table", spanName);
4142
}
4243

4344
@Test
@@ -154,8 +155,7 @@ void shouldExtractFullSpanNameForBatch() {
154155

155156
// then
156157
assertEquals(
157-
SemconvStability.emitStableDatabaseSemconv() ? "BATCH INSERT database.table" : "database",
158-
spanName);
158+
SemconvStability.emitStableDatabaseSemconv() ? "BATCH INSERT table" : "database", spanName);
159159
}
160160

161161
@Test
@@ -178,7 +178,7 @@ void shouldExtractFullSpanNameForSingleQueryBatch() {
178178
// then
179179
assertEquals(
180180
SemconvStability.emitStableDatabaseSemconv()
181-
? "BATCH INSERT database.table"
181+
? "BATCH INSERT table"
182182
: "INSERT database.table",
183183
spanName);
184184
}

0 commit comments

Comments
 (0)