Skip to content

Commit

Permalink
chore: Removed spring security and redis traces (#24758)
Browse files Browse the repository at this point in the history
## Description
Adds a filter for http endpoints that are recorded in our traces. We
have discarded the actuator endpoints since we don't care about their
metrics.

We have also filtered spans to only contain the ones that we have
manually declared across the project. All spans need to use the
`appsmith.` prefix to pass through this filter. This change discards
spring security and redis spans as of today.

Fixes #24757

#### Type of change
- Chore (housekeeping or task changes that don't impact user perception)
>
## Testing
>
#### How Has This Been Tested?
- [x] Manual
>
>
## Checklist:
#### Dev activity
- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [x] New and existing unit tests pass locally with my changes
- [ ] PR is being merged under a feature flag
  • Loading branch information
nidhi-nair authored Jun 27, 2023
1 parent 5e46a2f commit 895ef52
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 30 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.appsmith.external.constants.spans;

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

public final class ActionSpan {

// Action execution spans
public static final String ACTION_EXECUTION_REQUEST_PARSING = APPSMITH_SPAN_PREFIX + "request.parsing";
public static final String ACTION_EXECUTION_CACHED_DATASOURCE = APPSMITH_SPAN_PREFIX + "get.datasource.cached";
public static final String ACTION_EXECUTION_DATASOURCE_CONTEXT = APPSMITH_SPAN_PREFIX + "get.datasource.context";
public static final String ACTION_EXECUTION_EDITOR_CONFIG = APPSMITH_SPAN_PREFIX + "get.editorConfig.cached";
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";

// 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";
public static final String GET_ACTION_REPOSITORY_CALL = APPSMITH_SPAN_PREFIX + "get.action.repository.call";


}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.appsmith.external.constants.spans;

public class BaseSpan {
public static final String APPSMITH_SPAN_PREFIX = "appsmith.";
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import java.util.Set;
import java.util.stream.Collectors;

import static com.appsmith.external.constants.spans.ActionSpans.ACTION_EXECUTION_PLUGIN_EXECUTION;
import static com.appsmith.external.constants.spans.ActionSpan.ACTION_EXECUTION_PLUGIN_EXECUTION;
import static com.appsmith.external.helpers.PluginUtils.getHintMessageForLocalhostUrl;
import static org.springframework.util.CollectionUtils.isEmpty;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package com.appsmith.server.configurations;

import io.micrometer.observation.Observation;
import io.micrometer.observation.ObservationPredicate;
import io.micrometer.observation.ObservationView;
import io.micrometer.tracing.Span;
import io.micrometer.tracing.exporter.SpanExportingPredicate;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.server.reactive.observation.ServerRequestObservationContext;

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

/**
* This configuration file creates beans that are required to filter just Appsmith specific spans
*/
@Configuration
public class TracingConfig {

private Observation.Context getRoot(Observation.Context current) {
ObservationView parent = current.getParentObservation();
if (parent == null) {
return current;
} else {
return getRoot((Observation.Context) parent.getContextView());
}
}

@Bean
ObservationPredicate noActuatorServerObservations() {
return (name, context) -> {
Observation.Context root = getRoot(context);
if (root instanceof ServerRequestObservationContext serverContext) {
// For endpoint spans, which would be the parent for the trace,
// ignore actuator endpoints
// This gets rid of the prometheus calls as well as the health check
return !serverContext.getCarrier().getPath().value().startsWith("/actuator");
} else {
return true;
}
};
}

@Bean
SpanExportingPredicate onlyAppsmithSpans() {
return (finishedSpan) -> {
if ((finishedSpan.getKind() != null && finishedSpan.getKind().equals(Span.Kind.SERVER))
|| finishedSpan.getName().startsWith(APPSMITH_SPAN_PREFIX)) {
// A span is either an http server request root or Appsmith specific
return true;
} else {
return false;
}
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@
import java.util.function.Function;
import java.util.stream.Collectors;

import static com.appsmith.external.constants.spans.ActionSpans.GET_ACTION_REPOSITORY_CALL;
import static com.appsmith.external.constants.spans.ActionSpans.GET_UNPUBLISHED_ACTION;
import static com.appsmith.external.constants.spans.ActionSpans.GET_VIEW_MODE_ACTION;
import static com.appsmith.external.constants.spans.ActionSpan.GET_ACTION_REPOSITORY_CALL;
import static com.appsmith.external.constants.spans.ActionSpan.GET_UNPUBLISHED_ACTION;
import static com.appsmith.external.constants.spans.ActionSpan.GET_VIEW_MODE_ACTION;
import static com.appsmith.external.helpers.AppsmithBeanUtils.copyNewFieldValuesIntoOldObject;
import static com.appsmith.external.helpers.PluginUtils.setValueSafelyInFormData;
import static com.appsmith.server.acl.AclPermission.EXECUTE_DATASOURCES;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@
import java.util.stream.Collectors;

import static com.appsmith.external.constants.CommonFieldName.REDACTED_DATA;
import static com.appsmith.external.constants.spans.ActionSpans.ACTION_EXECUTION_CACHED_DATASOURCE;
import static com.appsmith.external.constants.spans.ActionSpans.ACTION_EXECUTION_DATASOURCE_CONTEXT;
import static com.appsmith.external.constants.spans.ActionSpans.ACTION_EXECUTION_EDITOR_CONFIG;
import static com.appsmith.external.constants.spans.ActionSpans.ACTION_EXECUTION_REQUEST_PARSING;
import static com.appsmith.external.constants.spans.ActionSpans.ACTION_EXECUTION_SERVER_EXECUTION;
import static com.appsmith.external.constants.spans.ActionSpan.ACTION_EXECUTION_CACHED_DATASOURCE;
import static com.appsmith.external.constants.spans.ActionSpan.ACTION_EXECUTION_DATASOURCE_CONTEXT;
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.helpers.DataTypeStringUtils.getDisplayDataTypes;
import static com.appsmith.server.helpers.WidgetSuggestionHelper.getSuggestedWidgets;
import static java.lang.Boolean.FALSE;
Expand Down

0 comments on commit 895ef52

Please sign in to comment.