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

Switch configuration to @ConfigMapping #285

Merged
merged 1 commit into from
Feb 20, 2025
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
quarkus.log.sentry=true
quarkus.log.sentry.enabled=true
quarkus.log.sentry.dsn=https://123@example.com/22222
quarkus.log.sentry.level=TRACE
quarkus.log.sentry.in-app-packages=io.quarkus.logging.sentry,org.test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
quarkus.log.sentry=true
quarkus.log.sentry.enabled=true
quarkus.log.sentry.dsn=https://123@default.com/22222
quarkus.log.sentry.in-app-packages=*
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
quarkus.log.sentry=true
quarkus.log.sentry.enabled=true
quarkus.log.sentry.dsn=https://123@example.com/22222
quarkus.log.sentry.level=TRACE
quarkus.log.sentry.in-app-packages=io.quarkus.logging.sentry,org.test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
quarkus.log.sentry=true
quarkus.log.sentry.enabled=true
quarkus.log.sentry.dsn=https://123@example.com/22222
quarkus.log.sentry.level=TRACE
quarkus.log.sentry.in-app-packages=io.quarkus.logging.sentry,org.test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
quarkus.log.sentry=true
quarkus.log.sentry.enabled=true
quarkus.log.sentry.dsn=https://123@default.com/22222
quarkus.log.sentry.in-app-packages=*
quarkus.log.sentry.traces-sample-rate=1.0
Original file line number Diff line number Diff line change
@@ -1 +1 @@
quarkus.log.sentry=true
quarkus.log.sentry.enabled=true
12 changes: 6 additions & 6 deletions docs/modules/ROOT/pages/includes/quarkus-logging-sentry.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ h|[.header-title]##Configuration property##
h|Type
h|Default

a| [[quarkus-logging-sentry_quarkus-log-sentry]] [.property-path]##link:#quarkus-logging-sentry_quarkus-log-sentry[`quarkus.log.sentry`]##
a| [[quarkus-logging-sentry_quarkus-log-sentry-enabled]] [.property-path]##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+++[]
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+++`
Environment variable: `+++QUARKUS_LOG_SENTRY_ENABLED+++`
endif::add-copy-button-to-env-var[]
--
|boolean
Expand Down Expand Up @@ -263,18 +263,18 @@ endif::add-copy-button-to-env-var[]
|Map<String,String>
|

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

[.description]
--
Determine whether to enable a Proxy for all Sentry outbound requests. This is also used for HTTPS requests.


ifdef::add-copy-button-to-env-var[]
Environment variable: env_var_with_copy_button:+++QUARKUS_LOG_SENTRY_PROXY+++[]
Environment variable: env_var_with_copy_button:+++QUARKUS_LOG_SENTRY_PROXY_ENABLED+++[]
endif::add-copy-button-to-env-var[]
ifndef::add-copy-button-to-env-var[]
Environment variable: `+++QUARKUS_LOG_SENTRY_PROXY+++`
Environment variable: `+++QUARKUS_LOG_SENTRY_PROXY_ENABLED+++`
endif::add-copy-button-to-env-var[]
--
|boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ h|[.header-title]##Configuration property##
h|Type
h|Default

a| [[quarkus-logging-sentry_quarkus-log-sentry]] [.property-path]##link:#quarkus-logging-sentry_quarkus-log-sentry[`quarkus.log.sentry`]##
a| [[quarkus-logging-sentry_quarkus-log-sentry-enabled]] [.property-path]##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+++[]
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+++`
Environment variable: `+++QUARKUS_LOG_SENTRY_ENABLED+++`
endif::add-copy-button-to-env-var[]
--
|boolean
Expand Down Expand Up @@ -263,18 +263,18 @@ endif::add-copy-button-to-env-var[]
|Map<String,String>
|

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

[.description]
--
Determine whether to enable a Proxy for all Sentry outbound requests. This is also used for HTTPS requests.


ifdef::add-copy-button-to-env-var[]
Environment variable: env_var_with_copy_button:+++QUARKUS_LOG_SENTRY_PROXY+++[]
Environment variable: env_var_with_copy_button:+++QUARKUS_LOG_SENTRY_PROXY_ENABLED+++[]
endif::add-copy-button-to-env-var[]
ifndef::add-copy-button-to-env-var[]
Environment variable: `+++QUARKUS_LOG_SENTRY_PROXY+++`
Environment variable: `+++QUARKUS_LOG_SENTRY_PROXY_ENABLED+++`
endif::add-copy-button-to-env-var[]
--
|boolean
Expand Down
4 changes: 2 additions & 2 deletions docs/modules/ROOT/pages/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ quarkus.log.sentry.in-app-packages=*
.All errors and warnings occurring in any of the packages will be sent to Sentry with DSN `https://abcd@sentry.io/1234`
[source, properties]
----
quarkus.log.sentry=true
quarkus.log.sentry.enabled=true
quarkus.log.sentry.dsn=https://abcd@sentry.io/1234
quarkus.log.sentry.in-app-packages=*
----

.All errors occurring in the package `org.example` will be sent to Sentry with DSN `https://abcd@sentry.io/1234`
[source, properties]
----
quarkus.log.sentry=true
quarkus.log.sentry.enabled=true
quarkus.log.sentry.dsn=https://abcd@sentry.io/1234
quarkus.log.sentry.level=ERROR
quarkus.log.sentry.in-app-packages=org.example
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
quarkus.log.sentry=true
quarkus.log.sentry.enabled=true
quarkus.log.sentry.dsn=https://123@default.com/22222
quarkus.log.sentry.in-app-packages=*
quarkus.log.sentry.tags."test.tag"=testvalue
3 changes: 0 additions & 3 deletions runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@
<version>${quarkus.version}</version>
</path>
</annotationProcessorPaths>
<compilerArgs>
<arg>-AlegacyConfigRoot=true</arg>
</compilerArgs>
</configuration>
</execution>
</executions>
Expand Down
70 changes: 36 additions & 34 deletions runtime/src/main/java/io/quarkus/logging/sentry/SentryConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,53 +6,64 @@
import java.util.OptionalDouble;
import java.util.logging.Level;

import io.quarkus.runtime.annotations.ConfigItem;
import io.quarkus.runtime.annotations.ConfigPhase;
import io.quarkus.runtime.annotations.ConfigRoot;
import io.smallrye.config.ConfigMapping;
import io.smallrye.config.WithDefault;
import io.smallrye.config.WithParentName;

/**
* Configuration for Sentry logging.
*/
@ConfigRoot(phase = ConfigPhase.RUN_TIME, name = "log.sentry")
public class SentryConfig {
@ConfigRoot(phase = ConfigPhase.RUN_TIME)
@ConfigMapping(prefix = "quarkus.log.sentry")
public interface SentryConfig {

/**
* Determine whether to enable the Sentry logging extension.
*
* @deprecated we try to stay away from this pattern now, replace with {@code quarkus.log.sentry.enabled}.
*/
@Deprecated(forRemoval = true)
@WithParentName
Optional<Boolean> enable();

/**
* Determine whether to enable the Sentry logging extension.
*/
@ConfigItem(name = ConfigItem.PARENT)
boolean enable;
@WithDefault("false")
boolean enabled();

/**
* Sentry DSN
*
* The DSN is the first and most important thing to configure because it tells the SDK where to send events. You can find
* your project’s DSN in the “Client Keys” section of your “Project Settings” in Sentry.
*/
@ConfigItem
public Optional<String> dsn;
Optional<String> dsn();

/**
* The sentry log level.
*/
@ConfigItem(defaultValue = "WARN")
public Level level;
@WithDefault("WARN")
Level level();

/**
* The minimum event level.
*
* Every log statement that is greater than minimum event level is turned into Sentry event.
*/
@ConfigItem(defaultValue = "WARN")
public Level minimumEventLevel;
@WithDefault("WARN")
Level minimumEventLevel();

/**
* The minimum breadcrumb level.
*
* Every log statement that is greater than minimum breadcrumb level is added to Sentry scope as a breadcrumb,
* which can be later attached to SentryEvent if one is triggered.
*/
@ConfigItem(defaultValue = "INFO")
public Level minimumBreadcrumbLevel;
@WithDefault("INFO")
Level minimumBreadcrumbLevel();

/**
* Sentry differentiates stack frames that are directly related to your application (“in application”) from stack frames
Expand All @@ -64,8 +75,7 @@ public class SentryConfig {
* This option is highly recommended as it affects stacktrace grouping and display on Sentry. See documentation:
* https://quarkus.io/guides/logging-sentry#in-app-packages
*/
@ConfigItem
public Optional<List<String>> inAppPackages;
Optional<List<String>> inAppPackages();

/**
* Sentry differentiates stack frames that are directly related to your application (“in application”) from stack frames
Expand All @@ -76,17 +86,15 @@ public class SentryConfig {
*
* You can configure which package prefixes you want to exclude from logging.
*/
@ConfigItem
public Optional<List<String>> inAppExcludedPackages;
Optional<List<String>> inAppExcludedPackages();

/**
*
* You can use this option to set exceptions that will be filtered out before sending to Sentry
* by adding the names of the exception.(e.g. java.lang.RuntimeException)
*
*/
@ConfigItem
public Optional<List<String>> ignoredExceptionsForType;
Optional<List<String>> ignoredExceptionsForType();

/**
* Environment
Expand All @@ -100,8 +108,7 @@ public class SentryConfig {
* -> the environment name cannot contain newlines or spaces, cannot be the string “None” or exceed 64 characters.
*
*/
@ConfigItem
public Optional<String> environment;
Optional<String> environment();

/**
* Release
Expand All @@ -114,49 +121,44 @@ public class SentryConfig {
* - Receive email notifications when your code gets deployed
*
*/
@ConfigItem
public Optional<String> release;
Optional<String> release();

/**
* Server name
*
* Sets the server name that will be sent with each event.
*/
@ConfigItem
public Optional<String> serverName;
Optional<String> serverName();

/**
* Debug
*
* Enables Sentry debug mode.
*/
@ConfigItem(defaultValue = "false")
public boolean debug;
@WithDefault("false")
boolean debug();

/**
* This should be a float/double between 0.0 and 1.0 (inclusive) and represents the percentage chance that any given
* transaction will be sent to Sentry.
* So, barring outside influence, 0.0 is a 0% chance (none will be sent) and 1.0 is a 100% chance (all will be sent). This
* rate applies equally to all transactions.
*/
@ConfigItem()
public OptionalDouble tracesSampleRate;
OptionalDouble tracesSampleRate();

/**
* Context Tags
*
* Specifics the MDC tags that are used as Sentry tags
*/
@ConfigItem
public Optional<List<String>> contextTags;
Optional<List<String>> contextTags();

/**
* Static tags
*
* Static tags that are sent to Sentry with every event.
*/
@ConfigItem
public Map<String, String> tags;
Map<String, String> tags();

public SentryProxyConfig proxy;
SentryProxyConfig proxy();
}
Loading
Loading