Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -203,17 +204,24 @@ protected Mono<ActionExecutionResult> populateAndExecuteAction(
.findById(executeActionDTO.getActionId(), executePermission)
.cache();

Mono<ExecuteActionDTO> populatedExecuteActionDTOMono =
newActionMono.flatMap(newAction -> populateExecuteActionDTO(executeActionDTO, newAction));
Mono<String> environmentIdMono = newActionMono.flatMap(
newAction -> getTrueEnvironmentId(newAction, executeActionDTO, executeActionMetaDTO));
Mono<ExecuteActionDTO> populatedExecuteActionDTOMono = newActionMono
.flatMap(newAction -> populateExecuteActionDTO(executeActionDTO, newAction))
.name(POPULATED_EXECUTE_ACTION_DTO_MONO)
.tap(Micrometer.observation(observationRegistry));
Mono<String> 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));
}

/**
Expand Down Expand Up @@ -336,29 +344,38 @@ public Mono<ActionExecutionResult> executeAction(
// 1. Validate input parameters which are required for mustache replacements
replaceNullWithQuotesForParamValues(executeActionDTO.getParams());

String actionId = executeActionDTO.getActionId();
AtomicReference<String> actionName = new AtomicReference<>();
actionName.set("");

// 2. Fetch the action from the DB and check if it can be executed
Mono<ActionDTO> 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<DatasourceStorage> datasourceStorageMono = getCachedDatasourceStorage(actionDTOMono, executeActionMetaDTO);

Mono<Plugin> pluginMono = executeActionMetaDTO.getPlugin() != null
? Mono.just(executeActionMetaDTO.getPlugin())
: getCachedPluginForActionExecution(datasourceStorageMono);
Mono<PluginExecutor> pluginExecutorMono = pluginExecutorHelper.getPluginExecutor(pluginMono);
: getCachedPluginForActionExecution(datasourceStorageMono)
.name(GET_CACHED_PLUGIN_FOR_ACTION_EXECUTION)
.tap(Micrometer.observation(observationRegistry));
Mono<PluginExecutor> pluginExecutorMono = pluginExecutorHelper
.getPluginExecutor(pluginMono)
.name(GET_PLUGIN_EXECUTOR)
.tap(Micrometer.observation(observationRegistry));

// 4. Execute the query
Mono<ActionExecutionResult> 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<Map> editorConfigLabelMapMono = getEditorConfigLabelMap(datasourceStorageMono);

Expand All @@ -378,7 +395,9 @@ public Mono<ActionExecutionResult> executeAction(
result.setIsExecutionSuccess(false);
result.setErrorInfo(error);
return Mono.just(result);
});
})
.name(EXECUTE_ACTION)
.tap(Micrometer.observation(observationRegistry));
}

/**
Expand Down
Loading