diff --git a/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/constants/spans/ce/ActionSpanCE.java b/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/constants/spans/ce/ActionSpanCE.java index 567a2296b76d..26b1091c60a0 100644 --- a/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/constants/spans/ce/ActionSpanCE.java +++ b/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/constants/spans/ce/ActionSpanCE.java @@ -19,6 +19,16 @@ public class ActionSpanCE { public static final String ACTION_EXECUTION_PLUGIN_EXECUTION = APPSMITH_SPAN_PREFIX + "total.plugin.execution"; public static final String ACTION_EXECUTION_SERVER_EXECUTION = APPSMITH_SPAN_PREFIX + "total.server.execution"; + public static final String GET_ENVIRONMENT_ID = APPSMITH_SPAN_PREFIX + "getEnvironmentId"; + public static final String POPULATED_EXECUTE_ACTION_DTO_MONO = + APPSMITH_SPAN_PREFIX + "populatedExecuteActionDTOMono"; + public static final String POPULATE_AND_EXECUTE_ACTION = APPSMITH_SPAN_PREFIX + "populateAndExecuteAction"; + public static final String GET_VALID_ACTION_FOR_EXECUTION = APPSMITH_SPAN_PREFIX + "getValidActionForExecution"; + public static final String GET_CACHED_PLUGIN_FOR_ACTION_EXECUTION = + APPSMITH_SPAN_PREFIX + "getCachedPluginForActionExecution"; + public static final String GET_PLUGIN_EXECUTOR = APPSMITH_SPAN_PREFIX + "getPluginExecutor"; + public static final String GET_ACTION_EXECUTION_RESULT = APPSMITH_SPAN_PREFIX + "getActionExecutionResult"; + public static final String EXECUTE_ACTION = APPSMITH_SPAN_PREFIX + "executeAction"; // Getter spans public static final String GET_UNPUBLISHED_ACTION = APPSMITH_SPAN_PREFIX + "get.action.unpublished"; public static final String GET_VIEW_MODE_ACTION = APPSMITH_SPAN_PREFIX + "get.action.viewmode"; 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 4558673fa523..b66b96958a1c 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 @@ -96,6 +96,7 @@ import static com.appsmith.external.constants.spans.ActionSpan.ACTION_EXECUTION_EDITOR_CONFIG; import static com.appsmith.external.constants.spans.ActionSpan.ACTION_EXECUTION_REQUEST_PARSING; import static com.appsmith.external.constants.spans.ActionSpan.ACTION_EXECUTION_SERVER_EXECUTION; +import static com.appsmith.external.constants.spans.ce.ActionSpanCE.*; import static com.appsmith.external.helpers.DataTypeStringUtils.getDisplayDataTypes; import static com.appsmith.server.constants.ce.FieldNameCE.NONE; import static com.appsmith.server.helpers.WidgetSuggestionHelper.getSuggestedWidgets; @@ -203,17 +204,24 @@ protected Mono populateAndExecuteAction( .findById(executeActionDTO.getActionId(), executePermission) .cache(); - Mono populatedExecuteActionDTOMono = - newActionMono.flatMap(newAction -> populateExecuteActionDTO(executeActionDTO, newAction)); - Mono environmentIdMono = newActionMono.flatMap( - newAction -> getTrueEnvironmentId(newAction, executeActionDTO, executeActionMetaDTO)); + Mono populatedExecuteActionDTOMono = newActionMono + .flatMap(newAction -> populateExecuteActionDTO(executeActionDTO, newAction)) + .name(POPULATED_EXECUTE_ACTION_DTO_MONO) + .tap(Micrometer.observation(observationRegistry)); + Mono environmentIdMono = newActionMono + .flatMap(newAction -> getTrueEnvironmentId(newAction, executeActionDTO, executeActionMetaDTO)) + .name(GET_ENVIRONMENT_ID) + .tap(Micrometer.observation(observationRegistry)); - return Mono.zip(populatedExecuteActionDTOMono, environmentIdMono).flatMap(pair -> { - ExecuteActionDTO populatedExecuteActionDTO = pair.getT1(); - String environmentId = pair.getT2(); - executeActionMetaDTO.setEnvironmentId(environmentId); - return executeAction(populatedExecuteActionDTO, executeActionMetaDTO); - }); + return Mono.zip(populatedExecuteActionDTOMono, environmentIdMono) + .flatMap(pair -> { + ExecuteActionDTO populatedExecuteActionDTO = pair.getT1(); + String environmentId = pair.getT2(); + executeActionMetaDTO.setEnvironmentId(environmentId); + return executeAction(populatedExecuteActionDTO, executeActionMetaDTO); + }) + .name(POPULATE_AND_EXECUTE_ACTION) + .tap(Micrometer.observation(observationRegistry)); } /** @@ -336,29 +344,38 @@ public Mono executeAction( // 1. Validate input parameters which are required for mustache replacements replaceNullWithQuotesForParamValues(executeActionDTO.getParams()); - String actionId = executeActionDTO.getActionId(); AtomicReference actionName = new AtomicReference<>(); actionName.set(""); // 2. Fetch the action from the DB and check if it can be executed Mono actionDTOMono = getValidActionForExecution(executeActionDTO, executeActionMetaDTO) + .name(GET_VALID_ACTION_FOR_EXECUTION) + .tap(Micrometer.observation(observationRegistry)) .cache(); // 3. Instantiate the implementation class based on the query type Mono datasourceStorageMono = getCachedDatasourceStorage(actionDTOMono, executeActionMetaDTO); + Mono pluginMono = executeActionMetaDTO.getPlugin() != null ? Mono.just(executeActionMetaDTO.getPlugin()) - : getCachedPluginForActionExecution(datasourceStorageMono); - Mono pluginExecutorMono = pluginExecutorHelper.getPluginExecutor(pluginMono); + : getCachedPluginForActionExecution(datasourceStorageMono) + .name(GET_CACHED_PLUGIN_FOR_ACTION_EXECUTION) + .tap(Micrometer.observation(observationRegistry)); + Mono pluginExecutorMono = pluginExecutorHelper + .getPluginExecutor(pluginMono) + .name(GET_PLUGIN_EXECUTOR) + .tap(Micrometer.observation(observationRegistry)); // 4. Execute the query Mono actionExecutionResultMono = getActionExecutionResult( - executeActionDTO, - actionDTOMono, - datasourceStorageMono, - pluginMono, - pluginExecutorMono, - executeActionMetaDTO.getHeaders()); + executeActionDTO, + actionDTOMono, + datasourceStorageMono, + pluginMono, + pluginExecutorMono, + executeActionMetaDTO.getHeaders()) + .name(GET_ACTION_EXECUTION_RESULT) + .tap(Micrometer.observation(observationRegistry)); Mono editorConfigLabelMapMono = getEditorConfigLabelMap(datasourceStorageMono); @@ -378,7 +395,9 @@ public Mono executeAction( result.setIsExecutionSuccess(false); result.setErrorInfo(error); return Mono.just(result); - }); + }) + .name(EXECUTE_ACTION) + .tap(Micrometer.observation(observationRegistry)); } /**