Skip to content

Commit 4ca6265

Browse files
committed
PR feedback
1 parent fec5d3f commit 4ca6265

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

driver-core/src/main/com/mongodb/observability/micrometer/DefaultMongodbObservationConvention.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public KeyValues getLowCardinalityKeyValues(final MongodbObservationContext cont
5050
MongodbObservation observationType = context.getObservationType();
5151
if (observationType == null) {
5252
return KeyValues.empty();
53-
} else if (observationType == MongodbObservation.MONGODB_TRANSACTION) {
53+
} else if (observationType == MongodbObservation.MONGODB_TRANSACTION) {
5454
return KeyValues.of(MongodbObservation.TransactionLowCardinalityKeyNames.SYSTEM.withValue("mongodb"));
5555
} else if (observationType == MongodbObservation.MONGODB_OPERATION) {
5656
return getOperationLowCardinalityKeyValues(context);

driver-sync/src/main/com/mongodb/client/internal/MongoClusterImpl.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -427,10 +427,10 @@ public <T> T execute(final ReadOperation<T, ?> operation, final ReadPreference r
427427
ReadBinding binding = getReadBinding(readPreference, actualClientSession, implicitSession);
428428
Span span = operationContext.getTracingManager().createOperationSpan(
429429
actualClientSession.getTransactionSpan(), operationContext, operation.getCommandName(), operation.getNamespace());
430-
if (span != null) {
431-
span.openScope();
432-
}
433430
try {
431+
if (span != null) {
432+
span.openScope();
433+
}
434434
if (actualClientSession.hasActiveTransaction() && !binding.getReadPreference().equals(primary())) {
435435
throw new MongoClientException("Read preference in a transaction must be primary");
436436
}
@@ -465,10 +465,10 @@ public <T> T execute(final WriteOperation<T> operation, final ReadConcern readCo
465465
WriteBinding binding = getWriteBinding(actualClientSession, isImplicitSession(session));
466466
Span span = operationContext.getTracingManager().createOperationSpan(
467467
actualClientSession.getTransactionSpan(), operationContext, operation.getCommandName(), operation.getNamespace());
468-
if (span != null) {
469-
span.openScope();
470-
}
471468
try {
469+
if (span != null) {
470+
span.openScope();
471+
}
472472
return operation.execute(binding, operationContext);
473473
} catch (MongoException e) {
474474
MongoException exceptionToHandle = OperationHelper.unwrap(e);

0 commit comments

Comments
 (0)