-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[Configuration] Sentry 관련 설정
- Loading branch information
Showing
3 changed files
with
76 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/main/java/com/guttery/madii/common/exception/SentryCapturingHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.guttery.madii.common.exception; | ||
|
||
import io.sentry.Sentry; | ||
import lombok.AccessLevel; | ||
import lombok.NoArgsConstructor; | ||
|
||
@NoArgsConstructor(access = AccessLevel.PRIVATE) | ||
public class SentryCapturingHelper { | ||
private static final String SPRING_PROFILE_ACTIVE = "spring.profiles.active"; | ||
private static final String SENTRY_ENABLED_PROFILE = "prod"; | ||
|
||
public static void captureException(Exception e) { | ||
if (isSentryEnabled()) { | ||
Sentry.captureException(e); | ||
} | ||
} | ||
|
||
private static boolean isSentryEnabled() { | ||
if (System.getProperty(SPRING_PROFILE_ACTIVE) == null) { | ||
return false; | ||
} | ||
|
||
return System.getProperty(SPRING_PROFILE_ACTIVE).equals(SENTRY_ENABLED_PROFILE); | ||
} | ||
|
||
} |