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] Sentry 설정 및 Discord 알람 설정 코드 변경 #245

Merged
merged 4 commits into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions smeem-api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ dependencies {
// Swagger
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.0.2'

// Sentry
implementation 'io.sentry:sentry-spring-boot-starter-jakarta:7.6.0'

}

ext {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ public ResponseEntity<FailureResponse> appleException(AppleException exception)
}

@ExceptionHandler(FcmException.class)
public ResponseEntity<FailureResponse> fcmException(FcmException exception, String message) {
return ApiResponseGenerator.failure(exception.getFailureCode(), message);
public ResponseEntity<FailureResponse> fcmException(FcmException exception) {
return ApiResponseGenerator.failure(exception.getFailureCode());
}

@ExceptionHandler(AuthException.class)
Expand Down
8 changes: 7 additions & 1 deletion smeem-api/src/main/resources/application-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,10 @@ smeem:
discord:
webhook:
error-url: ${DISCORD.WEBHOOK_ERROR_URL}
info-url: ${DISCORD.WEBHOOK_INFO_URL}
info-url: ${DISCORD.WEBHOOK_INFO_URL}

sentry:
dsn: ${SENTRY.DSN}
environment: dev
enable-tracing: true
exception-resolver-order: -2147483647
8 changes: 7 additions & 1 deletion smeem-api/src/main/resources/application-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,10 @@ smeem:
discord:
webhook:
error-url: ${DISCORD.WEBHOOK_ERROR_URL}
info-url: ${DISCORD.WEBHOOK_INFO_URL}
info-url: ${DISCORD.WEBHOOK_INFO_URL}

sentry:
dsn: ${SENTRY.DSN}
environment: prod
enable-tracing: true
exception-resolver-order: -2147483647
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@
import org.springframework.web.client.RestClient;

import static org.springframework.http.HttpHeaders.ACCEPT;
import static org.springframework.http.HttpHeaders.CONTENT_TYPE;

@Component
@RequiredArgsConstructor
@Slf4j
public class DiscordAlarmSender {

private static final String APPLICATION_JSON_UTF_8 = "application/json; UTF-8";

private final ObjectMapper objectMapper;
private final ValueConfig valueConfig;
private final Environment environment;
Expand All @@ -26,7 +29,8 @@ public void send(final String content, final DiscordAlarmCase alarmCase) {
val restClient = RestClient.create();
restClient.post()
.uri(webHookUri(alarmCase))
.header(ACCEPT, "application/json; UTF-8")
.header(CONTENT_TYPE, APPLICATION_JSON_UTF_8)
.header(ACCEPT, APPLICATION_JSON_UTF_8)
.body(makeRequestBody(content))
.retrieve();
} catch (RuntimeException | JsonProcessingException e) {
Expand Down
Loading