Skip to content

Commit c193b52

Browse files
committed
fix
1 parent 59098a3 commit c193b52

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

instrumentation/mongo/mongo-3.1/library/src/main/java/io/opentelemetry/instrumentation/mongo/v3_1/MongoAttributesExtractor.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
package io.opentelemetry.instrumentation.mongo.v3_1;
77

8+
import static io.opentelemetry.instrumentation.api.internal.SemconvStability.emitStableDatabaseSemconv;
89
import static java.util.Arrays.asList;
910

1011
import com.mongodb.event.CommandStartedEvent;
@@ -19,6 +20,8 @@
1920

2021
class MongoAttributesExtractor implements AttributesExtractor<CommandStartedEvent, Void> {
2122
// copied from DbIncubatingAttributes
23+
private static final AttributeKey<String> DB_COLLECTION_NAME =
24+
AttributeKey.stringKey("db.collection.name");
2225
private static final AttributeKey<String> DB_MONGODB_COLLECTION =
2326
AttributeKey.stringKey("db.mongodb.collection");
2427

@@ -27,7 +30,11 @@ public void onStart(
2730
AttributesBuilder attributes, Context parentContext, CommandStartedEvent event) {
2831
String collectionName = collectionName(event);
2932
if (collectionName != null) {
30-
attributes.put(DB_MONGODB_COLLECTION, collectionName);
33+
if (emitStableDatabaseSemconv()) {
34+
attributes.put(DB_COLLECTION_NAME, collectionName);
35+
} else {
36+
attributes.put(DB_MONGODB_COLLECTION, collectionName);
37+
}
3138
}
3239
}
3340

instrumentation/r2dbc-1.0/testing/src/main/java/io/opentelemetry/instrumentation/r2dbc/v1_0/AbstractR2dbcStatementTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,9 @@ void testQueries(Parameter parameter) {
170170
.hasAttributesSatisfyingExactly(
171171
equalTo(
172172
DB_CONNECTION_STRING,
173-
parameter.system + "://localhost:" + port),
173+
emitStableDatabaseSemconv()
174+
? null
175+
: parameter.system + "://localhost:" + port),
174176
equalTo(DB_SYSTEM, parameter.system),
175177
equalTo(maybeStable(DB_NAME), DB),
176178
equalTo(DB_USER, emitStableDatabaseSemconv() ? null : USER_DB),

0 commit comments

Comments
 (0)