Skip to content

Commit a7f9d2e

Browse files
committed
Address comments
1 parent 4820887 commit a7f9d2e

File tree

1 file changed

+22
-35
lines changed

1 file changed

+22
-35
lines changed

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

Lines changed: 22 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -154,21 +154,14 @@ void shouldNotExtractTableIfAttributeIsNotSet() {
154154
underTest.onStart(attributes, context, request);
155155

156156
// then
157-
if (SemconvStability.emitOldDatabaseSemconv()) {
158-
assertThat(attributes.build())
159-
.containsOnly(
160-
entry(DbIncubatingAttributes.DB_STATEMENT, "SELECT *"),
161-
entry(DbIncubatingAttributes.DB_OPERATION, "SELECT"));
162-
} else {
163-
assertThat(attributes.build())
164-
.containsOnly(
165-
entry(
166-
SemconvStabilityUtil.getAttributeKey(DbIncubatingAttributes.DB_STATEMENT),
167-
"SELECT *"),
168-
entry(
169-
SemconvStabilityUtil.getAttributeKey(DbIncubatingAttributes.DB_OPERATION),
170-
"SELECT"));
171-
}
157+
assertThat(attributes.build())
158+
.containsOnly(
159+
entry(
160+
SemconvStabilityUtil.getAttributeKey(DbIncubatingAttributes.DB_STATEMENT),
161+
"SELECT *"),
162+
entry(
163+
SemconvStabilityUtil.getAttributeKey(DbIncubatingAttributes.DB_OPERATION),
164+
"SELECT"));
172165
}
173166

174167
@Test
@@ -177,7 +170,9 @@ void shouldExtractTableToSpecifiedKey() {
177170
Map<String, String> request = new HashMap<>();
178171
if (SemconvStability.emitOldDatabaseSemconv()) {
179172
request.put("db.statement", "SELECT * FROM table");
180-
} else {
173+
}
174+
175+
if (SemconvStability.emitStableDatabaseSemconv()) {
181176
request.put("db.query.text", "SELECT * FROM table");
182177
}
183178

@@ -194,25 +189,17 @@ void shouldExtractTableToSpecifiedKey() {
194189
underTest.onStart(attributes, context, request);
195190

196191
// then
197-
if (SemconvStability.emitOldDatabaseSemconv()) {
198-
assertThat(attributes.build())
199-
.containsOnly(
200-
entry(DbIncubatingAttributes.DB_STATEMENT, "SELECT * FROM table"),
201-
entry(DbIncubatingAttributes.DB_OPERATION, "SELECT"),
202-
entry(DbIncubatingAttributes.DB_CASSANDRA_TABLE, "table"));
203-
} else {
204-
assertThat(attributes.build())
205-
.containsOnly(
206-
entry(
207-
SemconvStabilityUtil.getAttributeKey(DbIncubatingAttributes.DB_STATEMENT),
208-
"SELECT * FROM table"),
209-
entry(
210-
SemconvStabilityUtil.getAttributeKey(DbIncubatingAttributes.DB_OPERATION),
211-
"SELECT"),
212-
entry(
213-
SemconvStabilityUtil.getAttributeKey(DbIncubatingAttributes.DB_CASSANDRA_TABLE),
214-
"table"));
215-
}
192+
assertThat(attributes.build())
193+
.containsOnly(
194+
entry(
195+
SemconvStabilityUtil.getAttributeKey(DbIncubatingAttributes.DB_STATEMENT),
196+
"SELECT * FROM table"),
197+
entry(
198+
SemconvStabilityUtil.getAttributeKey(DbIncubatingAttributes.DB_OPERATION),
199+
"SELECT"),
200+
entry(
201+
SemconvStabilityUtil.getAttributeKey(DbIncubatingAttributes.DB_CASSANDRA_TABLE),
202+
"table"));
216203
}
217204

218205
@Test

0 commit comments

Comments
 (0)