chore: spans added in ast service for RTS calls (#39823)

## Description
> Spans added in AST service for RTS calls, this is done to help us
debug SLO alerts for JS object update API


Fixes #39799   
_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.Datasource"

### 🔍 Cypress test results
<!-- This is an auto-generated comment: Cypress test results  -->
> [!TIP]
> 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
> Workflow run:
<https://github.com/appsmithorg/appsmith/actions/runs/13966111083>
> Commit: c695fd17ce12920d5a7634d0b350dd073178cfa2
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=13966111083&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.Datasource`
> Spec:
> <hr>Thu, 20 Mar 2025 10:16:02 UTC
<!-- end of auto-generated comment: Cypress test results  -->


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


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

## Summary by CodeRabbit

- **New Features**
- Improved monitoring has been integrated to better track performance
during dynamic operations, contributing to a more reliable system.
- **Refactor**
- Internal service processes have been streamlined to support enhanced
observability, ensuring smoother diagnostics and overall stability for a
better user experience.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Co-authored-by: “sneha122” <“sneha@appsmith.com”>
This commit is contained in:
sneha122 2025-03-20 17:32:52 +05:30 committed by GitHub
parent 5a1fd06ff2
commit 81c263a2d5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 25 additions and 4 deletions

View File

@ -16,4 +16,8 @@ public class OnLoadSpanCE {
APPSMITH_SPAN_PREFIX + "addExplicitUserSetOnLoadExecutablesToGraph";
public static final String GET_UNPUBLISHED_ON_LOAD_EXECUTABLES_EXPLICIT_SET_BY_USER_IN_CREATOR_CONTEXT =
APPSMITH_SPAN_PREFIX + "getUnpublishedOnLoadExecutablesExplicitSetByUserInCreatorContext";
public static final String GET_POSSIBLE_REFERENCES_FROM_DYNAMIC_BINDING =
APPSMITH_SPAN_PREFIX + "getPossibleReferencesFromDynamicBinding";
public static final String AST_SERVICE_CALLING_RTS_API =
APPSMITH_SPAN_PREFIX + "astService.getPossibleReferencesFromDynamicBinding";
}

View File

@ -58,6 +58,7 @@ import static com.appsmith.external.constants.spans.OnLoadSpan.EXECUTABLE_NAME_T
import static com.appsmith.external.constants.spans.OnLoadSpan.GET_ALL_EXECUTABLES_BY_CREATOR_ID;
import static com.appsmith.external.constants.spans.OnLoadSpan.GET_UNPUBLISHED_ON_LOAD_EXECUTABLES_EXPLICIT_SET_BY_USER_IN_CREATOR_CONTEXT;
import static com.appsmith.external.constants.spans.OnLoadSpan.UPDATE_EXECUTABLE_SELF_REFERENCING_PATHS;
import static com.appsmith.external.constants.spans.ce.OnLoadSpanCE.GET_POSSIBLE_REFERENCES_FROM_DYNAMIC_BINDING;
import static com.appsmith.external.helpers.MustacheHelper.EXECUTABLE_ENTITY_REFERENCES;
import static com.appsmith.external.helpers.MustacheHelper.WIDGET_ENTITY_REFERENCES;
import static com.appsmith.external.helpers.MustacheHelper.getPossibleParents;
@ -667,8 +668,10 @@ public class OnLoadExecutablesUtilCEImpl implements OnLoadExecutablesUtilCE {
*/
private Mono<Map<String, Set<EntityDependencyNode>>> getPossibleEntityParentsMap(
List<String> bindings, int types, int evalVersion) {
Flux<Tuple2<String, Set<String>>> findingToReferencesFlux =
astService.getPossibleReferencesFromDynamicBinding(bindings, evalVersion);
Flux<Tuple2<String, Set<String>>> findingToReferencesFlux = astService
.getPossibleReferencesFromDynamicBinding(bindings, evalVersion)
.name(GET_POSSIBLE_REFERENCES_FROM_DYNAMIC_BINDING)
.tap(Micrometer.observation(observationRegistry));
return MustacheHelper.getPossibleEntityParentsMap(findingToReferencesFlux, types);
}

View File

@ -4,6 +4,7 @@ import com.appsmith.external.services.RTSCaller;
import com.appsmith.server.configurations.CommonConfig;
import com.appsmith.server.configurations.InstanceConfig;
import com.appsmith.server.services.ce.AstServiceCEImpl;
import io.micrometer.observation.ObservationRegistry;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@ -11,7 +12,11 @@ import org.springframework.stereotype.Service;
@Service
public class AstServiceImpl extends AstServiceCEImpl implements AstService {
public AstServiceImpl(CommonConfig commonConfig, InstanceConfig instanceConfig, RTSCaller rtsCaller) {
super(commonConfig, instanceConfig, rtsCaller);
public AstServiceImpl(
CommonConfig commonConfig,
InstanceConfig instanceConfig,
RTSCaller rtsCaller,
ObservationRegistry observationRegistry) {
super(commonConfig, instanceConfig, rtsCaller, observationRegistry);
}
}

View File

@ -8,6 +8,7 @@ import com.appsmith.server.configurations.InstanceConfig;
import com.appsmith.server.exceptions.AppsmithError;
import com.appsmith.server.exceptions.AppsmithException;
import com.appsmith.util.WebClientUtils;
import io.micrometer.observation.ObservationRegistry;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
@ -17,6 +18,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.util.StringUtils;
import org.springframework.web.reactive.function.client.WebClient;
import reactor.core.observability.micrometer.Micrometer;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.netty.resources.ConnectionProvider;
@ -34,6 +36,8 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import static com.appsmith.external.constants.spans.ce.OnLoadSpanCE.AST_SERVICE_CALLING_RTS_API;
@Slf4j
@RequiredArgsConstructor
public class AstServiceCEImpl implements AstServiceCE {
@ -43,6 +47,7 @@ public class AstServiceCEImpl implements AstServiceCE {
private final InstanceConfig instanceConfig;
private final RTSCaller rtsCaller;
private final ObservationRegistry observationRegistry;
private final WebClient webClient = WebClientUtils.create(ConnectionProvider.builder("rts-provider")
.maxConnections(100)
@ -119,6 +124,10 @@ public class AstServiceCEImpl implements AstServiceCE {
}
return rtsCaller
.post("/rts-api/v1/ast/multiple-script-data", new GetIdentifiersRequestBulk(bindingValues, evalVersion))
.name(AST_SERVICE_CALLING_RTS_API)
.tap(Micrometer.observation(observationRegistry))
.tag("no_of_bindings", String.valueOf(bindingValues.size()))
.tag("eval_version", String.valueOf(evalVersion))
.flatMapMany(spec -> spec.retrieve()
.bodyToMono(GetIdentifiersResponseBulk.class)
.retryWhen(Retry.max(3))