chore: revert optimisations related execute flow (#39800)

**Reverted** the following optimisations:
- Pushed out the sendExecuteAnalyticsEvent from the critical path of
returning action's exection result
- Improved the critical Path sendExecuteAnalyticsEvent by running the
application mono concurrent to other events

## Description
> [!TIP]  
> _Add a TL;DR when the description is longer than 500 words or
extremely technical (helps the content, marketing, and DevRel team)._
>
> _Please also include relevant motivation and context. List any
dependencies that are required for this change. Add links to Notion,
Figma or any other documents that might be relevant to the PR._


Fixes #`Issue Number`  
_or_  
Fixes `Issue URL`
> [!WARNING]  
> _If no issue exists, please create an issue first, and check with the
maintainers if the issue is valid._

## Automation

/ok-to-test tags="@tag.All"

### 🔍 Cypress test results
<!-- This is an auto-generated comment: Cypress test results  -->
> [!CAUTION]
> 🔴 🔴 🔴 Some tests have failed.
> Workflow run:
<https://github.com/appsmithorg/appsmith/actions/runs/13947295811>
> Commit: fda9eafe6d03be4021f9f7a83aaf6d1c92fb7490
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=13947295811&attempt=6&selectiontype=test&testsstatus=failed&specsstatus=fail"
target="_blank">Cypress dashboard</a>.
> Tags: @tag.All
> Spec: 
> The following are new failures, please fix them before merging the PR:
<ol>
>
<li>cypress/e2e/Regression/ClientSide/BugTests/DS_Bug26941_Spec.ts</ol>
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/identified-flaky-tests-65890b3c81d7400d08fa9ee3?branch=master"
target="_blank">List of identified flaky tests</a>.
> <hr>Wed, 19 Mar 2025 15:43:49 UTC
<!-- end of auto-generated comment: Cypress test results  -->


## Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [ ] No


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **Refactor**
- Streamlined the processing of analytics events to enhance overall
system performance and maintainability, ensuring a more stable and
responsive experience for end users.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
Vemparala Surya Vamsi 2025-03-20 10:09:26 +05:30 committed by GitHub
parent 86bc40bf00
commit c21381ba04
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -68,8 +68,6 @@ import org.springframework.util.StringUtils;
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 @@ public class ActionExecutionSolutionCEImpl implements ActionExecutionSolutionCE
.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 @@ public class ActionExecutionSolutionCEImpl implements ActionExecutionSolutionCE
request.setProperties(stringProperties);
}
Mono<Application> 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();