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

allow enabling the extension using quarkus.log.sentry.enabled key #254

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package io.quarkus.logging.sentry;

import static io.quarkus.logging.sentry.SentryLoggerTest.getSentryHandler;
import static org.assertj.core.api.Assertions.assertThat;

import java.util.logging.Handler;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

import io.quarkus.test.QuarkusUnitTest;
import io.sentry.Sentry;

public class SentryLoggerEnabledTest {

@RegisterExtension
static final QuarkusUnitTest config = new QuarkusUnitTest()
.setAllowTestClassOutsideDeployment(true)
.withConfigurationResource("application-sentry-logger-enabled.properties");

@Test
public void sentryLoggerEnabledTest() {
//test enabling sentry using quarkus.log.sentry.enabled
final Handler sentryHandler = getSentryHandler();
assertThat(sentryHandler).isNotNull();
assertThat(Sentry.isEnabled()).isTrue();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
quarkus.log.sentry.enabled=true
quarkus.log.sentry.dsn=https://[email protected]/22222
16 changes: 16 additions & 0 deletions docs/modules/ROOT/pages/includes/quarkus-logging-sentry.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,22 @@ endif::add-copy-button-to-env-var[]
|`false`


a| [[quarkus-logging-sentry_quarkus.log.sentry.enabled]]`link:#quarkus-logging-sentry_quarkus.log.sentry.enabled[quarkus.log.sentry.enabled]`

[.description]
--
Determine whether to enable the Sentry logging extension.

ifdef::add-copy-button-to-env-var[]
Environment variable: env_var_with_copy_button:+++QUARKUS_LOG_SENTRY_ENABLED+++[]
endif::add-copy-button-to-env-var[]
ifndef::add-copy-button-to-env-var[]
Environment variable: `+++QUARKUS_LOG_SENTRY_ENABLED+++`
endif::add-copy-button-to-env-var[]
--|boolean
|


a| [[quarkus-logging-sentry_quarkus.log.sentry.dsn]]`link:#quarkus-logging-sentry_quarkus.log.sentry.dsn[quarkus.log.sentry.dsn]`

[.description]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ public class SentryConfig {
@ConfigItem(name = ConfigItem.PARENT)
boolean enable;

/**
* Determine whether to enable the Sentry logging extension.
*/
@ConfigItem
public Optional<Boolean> enabled;

/**
* Sentry DSN
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class SentryHandlerValueFactory {

public RuntimeValue<Optional<Handler>> create(final SentryConfig config) {

if (!config.enable) {
if (!config.enabled.orElse(config.enable)) {
return new RuntimeValue<>(Optional.empty());
}

Expand Down
Loading