Skip to content

Commit f9f8003

Browse files
committed
simplify
1 parent a3be8d9 commit f9f8003

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

instrumentation/mongo/mongo-common/testing/src/main/java/io/opentelemetry/instrumentation/mongo/testing/AbstractMongoClientTest.java

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ void testCreateCollection() throws InterruptedException {
128128
span -> span.hasName("parent").hasKind(SpanKind.INTERNAL).hasNoParent(),
129129
span ->
130130
mongoSpan(
131-
trace.element(1),
131+
span,
132132
"create",
133133
collectionName,
134134
dbName,
@@ -161,7 +161,7 @@ void testCreateCollectionNoDescription() throws InterruptedException {
161161
span -> span.hasName("parent").hasKind(SpanKind.INTERNAL).hasNoParent(),
162162
span ->
163163
mongoSpan(
164-
trace.element(1),
164+
span,
165165
"create",
166166
collectionName,
167167
dbName,
@@ -195,7 +195,7 @@ void testCreateCollectionCallingBuildTwice() throws InterruptedException {
195195
span -> span.hasName("parent").hasKind(SpanKind.INTERNAL).hasNoParent(),
196196
span ->
197197
mongoSpan(
198-
trace.element(1),
198+
span,
199199
"create",
200200
collectionName,
201201
dbName,
@@ -229,7 +229,7 @@ void testGetCollection() throws Exception {
229229
span -> span.hasName("parent").hasKind(SpanKind.INTERNAL).hasNoParent(),
230230
span ->
231231
mongoSpan(
232-
trace.element(1),
232+
span,
233233
"count",
234234
collectionName,
235235
dbName,
@@ -266,7 +266,7 @@ void testInsert() throws Exception {
266266
span -> span.hasName("parent").hasKind(SpanKind.INTERNAL).hasNoParent(),
267267
span ->
268268
mongoSpan(
269-
trace.element(1),
269+
span,
270270
"insert",
271271
collectionName,
272272
dbName,
@@ -283,7 +283,7 @@ void testInsert() throws Exception {
283283
+ "\",\"ordered\":\"?\",\"$db\":\"?\",\"lsid\":{\"id\":\"?\"},\"documents\":[{\"_id\":\"?\",\"password\":\"?\"}]}")),
284284
span ->
285285
mongoSpan(
286-
trace.element(2),
286+
span,
287287
"count",
288288
collectionName,
289289
dbName,
@@ -320,7 +320,7 @@ void testUpdate() throws Exception {
320320
span -> span.hasName("parent").hasKind(SpanKind.INTERNAL).hasNoParent(),
321321
span ->
322322
mongoSpan(
323-
trace.element(1),
323+
span,
324324
"update",
325325
collectionName,
326326
dbName,
@@ -337,7 +337,7 @@ void testUpdate() throws Exception {
337337
+ "\",\"ordered\":\"?\",\"$db\":\"?\",\"lsid\":{\"id\":\"?\"},\"updates\":[{\"q\":{\"password\":\"?\"},\"u\":{\"$set\":{\"password\":\"?\"}}}]}")),
338338
span ->
339339
mongoSpan(
340-
trace.element(2),
340+
span,
341341
"count",
342342
collectionName,
343343
dbName,
@@ -374,7 +374,7 @@ void testDelete() throws Exception {
374374
span -> span.hasName("parent").hasKind(SpanKind.INTERNAL).hasNoParent(),
375375
span ->
376376
mongoSpan(
377-
trace.element(1),
377+
span,
378378
"delete",
379379
collectionName,
380380
dbName,
@@ -391,7 +391,7 @@ void testDelete() throws Exception {
391391
+ "\",\"ordered\":\"?\",\"$db\":\"?\",\"lsid\":{\"id\":\"?\"},\"deletes\":[{\"q\":{\"password\":\"?\"},\"limit\":\"?\"}]}")),
392392
span ->
393393
mongoSpan(
394-
trace.element(2),
394+
span,
395395
"count",
396396
collectionName,
397397
dbName,
@@ -426,7 +426,7 @@ void testCollectionNameForGetMoreCommand() {
426426
span -> span.hasName("parent").hasKind(SpanKind.INTERNAL).hasNoParent(),
427427
span ->
428428
mongoSpan(
429-
trace.element(1),
429+
span,
430430
"find",
431431
collectionName,
432432
dbName,
@@ -446,7 +446,7 @@ void testCollectionNameForGetMoreCommand() {
446446
+ "\",\"filter\":{\"_id\":{\"$gte\":\"?\"}},\"batchSize\":\"?\",\"$db\":\"?\",\"lsid\":{\"id\":\"?\"}}")),
447447
span ->
448448
mongoSpan(
449-
trace.element(2),
449+
span,
450450
"getMore",
451451
collectionName,
452452
dbName,
@@ -483,7 +483,7 @@ void testCreateCollectionWithAlreadyBuiltClientOptions() {
483483
span -> span.hasName("parent").hasKind(SpanKind.INTERNAL).hasNoParent(),
484484
span ->
485485
mongoSpan(
486-
trace.element(1),
486+
span,
487487
"create",
488488
collectionName,
489489
dbName,
@@ -505,14 +505,13 @@ protected String createCollectionName() {
505505
@SuppressWarnings("deprecation")
506506
// TODO DbIncubatingAttributes.DB_CONNECTION_STRING deprecation
507507
void mongoSpan(
508-
SpanDataAssert spanData,
508+
SpanDataAssert span,
509509
String operation,
510510
String collection,
511511
String dbName,
512512
Object parentSpan,
513513
List<String> statements) {
514-
SpanDataAssert span =
515-
spanData.hasName(operation + " " + dbName + "." + collection).hasKind(CLIENT);
514+
span.hasName(operation + " " + dbName + "." + collection).hasKind(CLIENT);
516515
if (parentSpan == null) {
517516
span.hasNoParent();
518517
} else {

0 commit comments

Comments
 (0)