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 metrics to newRelic for update JSobject Collection #35947

Merged
merged 10 commits into from
Sep 5, 2024
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.appsmith.external.constants.spans;

import com.appsmith.external.constants.spans.ce.ActionCollectionSpanCE;

public class ActionCollectionSpan extends ActionCollectionSpanCE {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.appsmith.external.constants.spans;

import com.appsmith.external.constants.spans.ce.LayoutSpanCE;

public class LayoutSpan extends LayoutSpanCE {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.appsmith.external.constants.spans.ce;

import static com.appsmith.external.constants.spans.BaseSpan.APPSMITH_SPAN_PREFIX;

/**
* Please make sure that all span names start with `appsmith.` because span with any other naming format would get
* dropped / ignored as defined in TracingConfig.java
*/
public class ActionCollectionSpanCE {
// Action Collection spans
public static final String ACTION_COLLECTION_UPDATE = APPSMITH_SPAN_PREFIX + "update.actionCollection";
public static final String GENERATE_ACTION_COLLECTION_BY_VIEW_MODE =
APPSMITH_SPAN_PREFIX + "generate.actionCollectionByViewMode";
public static final String POPULATE_ACTION_COLLECTION_BY_VIEW_MODE =
APPSMITH_SPAN_PREFIX + "populate.actionCollectionByViewMode";
public static final String SAVE_ACTION_COLLECTION_LAST_EDIT_INFO =
APPSMITH_SPAN_PREFIX + "save.actionCollectionLastEditInfo";

// Getter spans
public static final String GET_ACTION_COLLECTION_BY_ID = APPSMITH_SPAN_PREFIX + "get.actionCollectionById";
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,12 @@ public class ActionSpanCE {
public static final String VIEW_MODE_SET_PLUGIN_ID_AND_TYPE_ACTION = ACTIONS_VIEW_MODE_PREFIX + "set_action";
public static final String VIEW_MODE_FETCH_PLUGIN_FROM_DB = ACTIONS_VIEW_MODE_PREFIX + "plugindb";
public static final String VIEW_MODE_FETCH_ACTIONS_FROM_DB = ACTIONS_VIEW_MODE_PREFIX + "fetchactions";
public static final String GET_ACTION_BY_ID = APPSMITH_SPAN_PREFIX + "get.actionById";

// Action creation, update and delete spans
public static final String UPDATE_SINGLE_ACTION = APPSMITH_SPAN_PREFIX + "update.single.action";
public static final String UPDATE_ACTION_BASED_ON_CONTEXT = APPSMITH_SPAN_PREFIX + "update.action.context";
public static final String CREATE_ACTION = APPSMITH_SPAN_PREFIX + "create.action";
public static final String UPDATE_ACTION = APPSMITH_SPAN_PREFIX + "update.action";
public static final String DELETE_ACTION = APPSMITH_SPAN_PREFIX + "delete.action";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.appsmith.external.constants.spans.ce;

import static com.appsmith.external.constants.spans.BaseSpan.APPSMITH_SPAN_PREFIX;

public class LayoutSpanCE {
public static final String UPDATE_LAYOUT = "updateLayout.";
public static final String UPDATE_PAGE_LAYOUT_BY_PAGE_ID = APPSMITH_SPAN_PREFIX + UPDATE_LAYOUT + "pageId";
public static final String UPDATE_LAYOUT_METHOD = APPSMITH_SPAN_PREFIX + UPDATE_LAYOUT + "method";
public static final String UPDATE_LAYOUT_DSL_METHOD = APPSMITH_SPAN_PREFIX + UPDATE_LAYOUT + "dsl.method";
public static final String UPDATE_LAYOUT_BASED_ON_CONTEXT = APPSMITH_SPAN_PREFIX + UPDATE_LAYOUT + "context";

public static final String FIND_ALL_ON_LOAD_EXECUTABLES =
APPSMITH_SPAN_PREFIX + "onLoadExecutablesUtil.findAllOnLoadExecutables";
public static final String UPDATE_EXECUTABLES_EXECUTE_ONLOAD =
APPSMITH_SPAN_PREFIX + "onLoadExecutablesUtil.updateExecutablesExecuteOnLoad";
public static final String FIND_AND_UPDATE_LAYOUT =
APPSMITH_SPAN_PREFIX + "onLoadExecutablesUtil.findAndUpdateLayout";
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.appsmith.external.constants.spans.ce;

import static com.appsmith.external.constants.spans.BaseSpan.APPSMITH_SPAN_PREFIX;

public class PageSpanCE {
public static final String PAGES = "pages.";
public static final String GET_PAGE = PAGES + "getpage";
Expand All @@ -11,4 +13,6 @@ public class PageSpanCE {
public static final String MARK_RECENTLY_ACCESSED_RESOURCES_PAGES = PAGES + "update_recently_accessed_pages";
public static final String PREPARE_APPLICATION_PAGES_DTO_FROM_PAGES = PAGES + "generate_app_pages_dto";
public static final String MIGRATE_DSL = PAGES + "migrate_dsl";

public static final String GET_PAGE_BY_ID = APPSMITH_SPAN_PREFIX + "get.page.unpublished";
rishabhrathod01 marked this conversation as resolved.
Show resolved Hide resolved
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.appsmith.server.services.BaseService;
import com.appsmith.server.solutions.ActionPermission;
import com.appsmith.server.solutions.ApplicationPermission;
import io.micrometer.observation.ObservationRegistry;
import jakarta.validation.Validator;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
Expand All @@ -28,6 +29,7 @@
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.util.StringUtils;
import reactor.core.observability.micrometer.Micrometer;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

Expand All @@ -41,6 +43,7 @@
import java.util.Set;
import java.util.UUID;

import static com.appsmith.external.constants.spans.ActionCollectionSpan.GET_ACTION_COLLECTION_BY_ID;
import static com.appsmith.external.helpers.AppsmithBeanUtils.copyNewFieldValuesIntoOldObject;
import static java.lang.Boolean.TRUE;

Expand All @@ -53,6 +56,7 @@ public class ActionCollectionServiceCEImpl extends BaseService<ActionCollectionR
private final ApplicationService applicationService;
private final ApplicationPermission applicationPermission;
private final ActionPermission actionPermission;
private final ObservationRegistry observationRegistry;

@Autowired
public ActionCollectionServiceCEImpl(
Expand All @@ -63,14 +67,16 @@ public ActionCollectionServiceCEImpl(
PolicyGenerator policyGenerator,
ApplicationService applicationService,
ApplicationPermission applicationPermission,
ActionPermission actionPermission) {
ActionPermission actionPermission,
ObservationRegistry observationRegistry) {

super(validator, repository, analyticsService);
this.newActionService = newActionService;
this.policyGenerator = policyGenerator;
this.applicationService = applicationService;
this.applicationPermission = applicationPermission;
this.actionPermission = actionPermission;
this.observationRegistry = observationRegistry;
}

@Override
Expand Down Expand Up @@ -372,7 +378,10 @@ public Mono<ActionCollectionDTO> generateActionCollectionByViewMode(

@Override
public Mono<ActionCollection> findById(String id, AclPermission aclPermission) {
return repository.findById(id, aclPermission);
return repository
.findById(id, aclPermission)
.name(GET_ACTION_COLLECTION_BY_ID)
.tap(Micrometer.observation(observationRegistry));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.appsmith.server.services.AnalyticsService;
import com.appsmith.server.solutions.ActionPermission;
import com.appsmith.server.solutions.ApplicationPermission;
import io.micrometer.observation.ObservationRegistry;
import jakarta.validation.Validator;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
Expand All @@ -22,7 +23,8 @@ public ActionCollectionServiceImpl(
PolicyGenerator policyGenerator,
ApplicationService applicationService,
ApplicationPermission applicationPermission,
ActionPermission actionPermission) {
ActionPermission actionPermission,
ObservationRegistry observationRegistry) {
super(
validator,
repository,
Expand All @@ -31,6 +33,7 @@ public ActionCollectionServiceImpl(
policyGenerator,
applicationService,
applicationPermission,
actionPermission);
actionPermission,
observationRegistry);
}
}
Loading
Loading