chore: removed sentry form server (#40990)

## Description
> [!TIP]  
> _Add a TL;DR when the description is longer than 500 words or
extremely technical (helps the content, marketing, and DevRel team)._
>
> _Please also include relevant motivation and context. List any
dependencies that are required for this change. Add links to Notion,
Figma or any other documents that might be relevant to the PR._


Fixes #`Issue Number`  
_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.All"

### 🔍 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/15815846167>
> Commit: 366aaa8596eefbf4c2a399d54460dacf22a550a5
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=15815846167&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.All`
> Spec:
> <hr>Mon, 23 Jun 2025 06:27:29 UTC
<!-- end of auto-generated comment: Cypress test results  -->


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


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

- **Refactor**
- Replaced Sentry-based error reporting with enhanced internal logging
for exceptions.
- Introduced a new logging utility to improve observability and error
context in logs.
- **Chores**
- Removed Sentry integration and related error reporting code from the
application.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
Apeksha Bhosale 2025-06-23 13:42:50 +05:30 committed by GitHub
parent d3d4f0c354
commit 814fb3d350
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 40 additions and 58 deletions

View File

@ -5,7 +5,6 @@ import com.appsmith.server.helpers.InstanceConfigHelper;
import com.appsmith.server.repositories.CacheableRepositoryHelper;
import com.appsmith.server.services.ConfigService;
import io.micrometer.observation.annotation.Observed;
import io.sentry.Sentry;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.event.ApplicationReadyEvent;
@ -71,7 +70,6 @@ public class InstanceConfig implements ApplicationListener<ApplicationReadyEvent
startupProcess.block();
} catch (Exception e) {
log.debug("Application start up encountered an error: {}", e.getMessage());
Sentry.captureException(e);
}
}

View File

@ -35,7 +35,7 @@ import java.nio.file.Path;
import java.util.HashMap;
import java.util.Map;
import static com.appsmith.server.exceptions.util.SentryLogger.doLog;
import static com.appsmith.server.exceptions.util.ObservabilityLogger.doLog;
/**
* This class catches all the Exceptions and formats them into a proper ResponseDTO<ErrorDTO> object before

View File

@ -0,0 +1,39 @@
package com.appsmith.server.exceptions.util;
import com.appsmith.external.exceptions.AppsmithErrorAction;
import com.appsmith.external.exceptions.BaseException;
import lombok.extern.slf4j.Slf4j;
import java.io.PrintWriter;
import java.io.StringWriter;
@Slf4j
public class ObservabilityLogger {
public static void doLog(Throwable error) {
if (error instanceof BaseException baseException && baseException.isHideStackTraceInLogs()) {
log.error(baseException.getClass().getSimpleName() + ": " + baseException.getMessage());
} else {
log.error("", error);
}
StringWriter stringWriter = new StringWriter();
PrintWriter printWriter = new PrintWriter(stringWriter);
error.printStackTrace(printWriter);
String stringStackTrace = stringWriter.toString();
// Log stack trace for debugging
log.error("Stack Trace: {}", stringStackTrace);
if (error instanceof BaseException) {
BaseException baseError = (BaseException) error;
if (baseError.getErrorAction() == AppsmithErrorAction.LOG_EXTERNALLY) {
// Log additional context for external logging
log.error(
"Downstream Error - Message: {}, Code: {}",
baseError.getDownstreamErrorMessage(),
baseError.getDownstreamErrorCode());
baseError.getContextMap().forEach((key, value) -> log.error("Context - {}: {}", key, value));
}
}
}
}

View File

@ -1,55 +0,0 @@
package com.appsmith.server.exceptions.util;
import com.appsmith.external.constants.MDCConstants;
import com.appsmith.external.exceptions.AppsmithErrorAction;
import com.appsmith.external.exceptions.BaseException;
import io.sentry.Sentry;
import io.sentry.SentryLevel;
import io.sentry.protocol.User;
import lombok.extern.slf4j.Slf4j;
import java.io.PrintWriter;
import java.io.StringWriter;
@Slf4j
public class SentryLogger {
public static void doLog(Throwable error) {
if (error instanceof BaseException baseException && baseException.isHideStackTraceInLogs()) {
log.error(baseException.getClass().getSimpleName() + ": " + baseException.getMessage());
} else {
log.error("", error);
}
StringWriter stringWriter = new StringWriter();
PrintWriter printWriter = new PrintWriter(stringWriter);
error.printStackTrace(printWriter);
String stringStackTrace = stringWriter.toString();
Sentry.configureScope(scope -> {
/**
* Send stack trace as a string message. This is a work around till it is figured out why raw
* stack trace is not visible on Sentry dashboard.
* */
scope.setExtra("Stack Trace", stringStackTrace);
scope.setLevel(SentryLevel.ERROR);
scope.setTag("source", "appsmith-internal-server");
});
if (error instanceof BaseException) {
BaseException baseError = (BaseException) error;
if (baseError.getErrorAction() == AppsmithErrorAction.LOG_EXTERNALLY) {
Sentry.configureScope(scope -> {
baseError.getContextMap().forEach(scope::setTag);
scope.setExtra("downstreamErrorMessage", baseError.getDownstreamErrorMessage());
scope.setExtra("downstreamErrorCode", baseError.getDownstreamErrorCode());
});
final User user = new User();
user.setEmail(baseError.getContextMap().getOrDefault(MDCConstants.USER_EMAIL, "unknownUser"));
Sentry.setUser(user);
Sentry.captureException(error);
}
} else {
Sentry.captureException(error);
}
}
}