Skip to content

Commit

Permalink
only warn when the environment is function
Browse files Browse the repository at this point in the history
  • Loading branch information
musketyr committed Dec 4, 2020
1 parent 2a6fa65 commit 3d550a4
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import io.micronaut.context.annotation.Bean;
import io.micronaut.context.annotation.Context;
import io.micronaut.context.annotation.Factory;
import io.micronaut.context.env.Environment;
import io.sentry.Sentry;
import io.sentry.SentryClient;
import io.sentry.config.Lookup;
Expand Down Expand Up @@ -55,14 +56,15 @@ public class Log4AwsFactory {
*/
@Bean
@Context
public SentryAppender sentryAppender() {
boolean sync = !Boolean.FALSE.toString().equals(Lookup.getDefault().get(ASYNC_OPTION));
public SentryAppender sentryAppender(Environment environment) {
boolean async = !Boolean.FALSE.toString().equals(Lookup.getDefault().get(ASYNC_OPTION));
boolean dsnProvided = !Dsn.DEFAULT_DSN.equals(Dsn.dsnLookup());
boolean function = environment.getActiveNames().contains(Environment.FUNCTION);

if (sync && dsnProvided) {
if (async && dsnProvided && function) {
// in future releases
// throw new IllegalStateException("Sentry not configured correctly for synchornous calls! Please, create file 'sentry.properties' and add there a line 'async=false'");
LOGGER.error("Sentry not configured correctly for synchornous calls! Please, create file 'sentry.properties' and add there a line 'async=false'");
LOGGER.error("Sentry not configured correctly for synchronous calls! Please, create file 'sentry.properties' and add there a line 'async=false'");
}

return initializeAppenderIfMissing(
Expand Down

0 comments on commit 3d550a4

Please sign in to comment.