Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Add plugin name to server execution metrics #39413

Open
wants to merge 4 commits into
base: release
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 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
@@ -1,5 +1,6 @@
package com.appsmith.server.dtos;

import com.appsmith.server.domains.Plugin;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
Expand All @@ -14,4 +15,5 @@ public class ExecuteActionMetaDTO {
String environmentId;
HttpHeaders headers;
boolean operateWithoutPermission = false;
Plugin plugin;
}
Original file line number Diff line number Diff line change
Expand Up @@ -292,11 +292,22 @@ public Mono<ActionExecutionResult> executeAction(
.operateWithoutPermission(operateWithoutPermission)
.environmentId(environmentId)
.build();
Mono<ExecuteActionDTO> executeActionDTOMono = createExecuteActionDTO(partFlux);
return executeActionDTOMono
.flatMap(executeActionDTO -> populateAndExecuteAction(executeActionDTO, executeActionMetaDTO))
.name(ACTION_EXECUTION_SERVER_EXECUTION)
.tap(Micrometer.observation(observationRegistry));
Mono<ExecuteActionDTO> executeActionDTOMono =
createExecuteActionDTO(partFlux).cache();
Mono<Plugin> pluginMono = executeActionDTOMono.flatMap(executeActionDTO -> newActionService
.findById(executeActionDTO.getActionId())
.flatMap(newAction -> pluginService.findById(newAction.getPluginId()))
Copy link
Contributor

@NilanshBansal NilanshBansal Feb 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ApekshaBhosale can you please add a check if newAction.getPluginId() is not null?
You can also add error handling for switchIfEmpty() from both the findById() db calls

Copy link
Contributor

@NilanshBansal NilanshBansal Feb 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ApekshaBhosale can you check the case when executeAction() is called and pluginId is null. This usually happens in the case of JSObject Action.

Also, please handle the case if entire pluginMono is an empty mono here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got it. will check. if action id is not present i will throw an appsmith error with http code 400 but what about plugin id not present, i should not be throwing error right? but handle it @NilanshBansal

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes thats correct.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

js action doesn't get executed on backend at all @NilanshBansal

.cache());

return pluginMono.flatMap(plugin -> {
String pluginName = plugin.getName();
executeActionMetaDTO.setPlugin(plugin);
return executeActionDTOMono
.flatMap(executeActionDTO -> populateAndExecuteAction(executeActionDTO, executeActionMetaDTO))
.tag("plugin", pluginName)
.name(ACTION_EXECUTION_SERVER_EXECUTION)
.tap(Micrometer.observation(observationRegistry));
});
}

/**
Expand All @@ -322,7 +333,7 @@ public Mono<ActionExecutionResult> executeAction(

// 3. Instantiate the implementation class based on the query type
Mono<DatasourceStorage> datasourceStorageMono = getCachedDatasourceStorage(actionDTOMono, executeActionMetaDTO);
Mono<Plugin> pluginMono = getCachedPluginForActionExecution(datasourceStorageMono);
Mono<Plugin> pluginMono = Mono.just(executeActionMetaDTO.getPlugin());
Mono<PluginExecutor> pluginExecutorMono = pluginExecutorHelper.getPluginExecutor(pluginMono);

// 4. Execute the query
Expand Down
Loading