diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/ActionExecutionSolutionCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/ActionExecutionSolutionCEImpl.java index 7f0dc2ecd3c3..5dd924133b4f 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/ActionExecutionSolutionCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/ActionExecutionSolutionCEImpl.java @@ -68,8 +68,6 @@ import reactor.core.observability.micrometer.Micrometer; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; -import reactor.core.scheduler.Schedulers; -import reactor.util.function.Tuple2; import java.io.IOException; import java.nio.charset.StandardCharsets; @@ -925,33 +923,26 @@ protected Mono getActionExecutionResult( .onErrorMap(executionExceptionMapper(actionDTO, timeoutDuration)) .onErrorResume(executionExceptionHandler(actionDTO)) .elapsed() - .map(tuple1 -> { + .flatMap(tuple1 -> { Long timeElapsed = tuple1.getT1(); + ActionExecutionResult result = tuple1.getT2(); + log.debug( "{}: Action {} with id {} execution time : {} ms", Thread.currentThread().getName(), actionDTO.getName(), actionDTO.getId(), timeElapsed); - return tuple1; - }) - .doOnSuccess(tuple2 -> { - Long timeElapsed = tuple2.getT1(); - ActionExecutionResult result = tuple2.getT2(); - // Runs the analytics in the separate thread and immediately return the execution result - sendExecuteAnalyticsEvent( + + return sendExecuteAnalyticsEvent( actionDTO, datasourceStorage, executeActionDTO, result, timeElapsed, finalRawActionConfiguration) - .name(SEND_EXECUTE_ANALYTICS_EVENT) - .tap(Micrometer.observation(observationRegistry)) - .subscribeOn(Schedulers.boundedElastic()) - .subscribe(); - }) - .map(Tuple2::getT2); + .thenReturn(result); + }); }); } @@ -1109,16 +1100,16 @@ private Mono sendExecuteAnalyticsEvent( request.setProperties(stringProperties); } - Mono applicationMono = Mono.justOrEmpty(actionDTO.getApplicationId()) + return Mono.justOrEmpty(actionDTO.getApplicationId()) .flatMap(applicationService::findById) - .defaultIfEmpty(new Application()); - return Mono.zip( - applicationMono, + .defaultIfEmpty(new Application()) + .flatMap(application -> Mono.zip( + Mono.just(application), sessionUserService.getCurrentUser(), newPageService.getNameByPageId(actionDTO.getPageId(), executeActionDto.getViewMode()), pluginService.getByIdWithoutPermissionCheck(actionDTO.getPluginId()), datasourceStorageService.getEnvironmentNameFromEnvironmentIdForAnalytics( - datasourceStorage.getEnvironmentId())) + datasourceStorage.getEnvironmentId()))) .flatMap(tuple -> { final Application application = tuple.getT1(); final User user = tuple.getT2();