Skip to content

Commit

Permalink
Handle Sentry in-app-packages=* and doc
Browse files Browse the repository at this point in the history
  • Loading branch information
ia3andy committed Dec 3, 2019
1 parent e1819df commit 30a6027
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 5 deletions.
19 changes: 18 additions & 1 deletion docs/src/main/asciidoc/logging-sentry.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,30 @@ application POM as the following snippet illustrates.
</build>
----

[id="in-app-packages"]
=== “In Application” Stack Frames
Sentry differentiates stack frames that are directly related to your application (“in application”) from stack frames that come from other packages such as the standard library, frameworks, or other dependencies. The difference is visible in the Sentry web interface where only the “in application” frames are displayed by default.

You can configure which package prefixes your application uses with the stacktrace.app.packages option, which takes a comma separated list.
[source, properties]
----
quarkus.log.sentry.in-app-packages=com.mycompany,com.other.name
----
If you don’t want to use this feature but want to disable the warning, simply set it to "*":

[source, properties]
----
quarkus.log.sentry.in-app-packages=*
----

== Example

.All errors and warnings occuring in any the packages will be sent to Sentry with DSN `https://[email protected]/1234`
[source, properties]
----
`
quarkus.log.sentry=true
quarkus.log.sentry.dsn=https://[email protected]/1234
quarkus.log.sentry.in-app-packages=*
----
.All errors occuring in the package `org.example` will be sent to Sentry with DSN `https://[email protected]/1234`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
quarkus.log.sentry=true
quarkus.log.sentry.dsn=https://[email protected]/22222
quarkus.log.sentry.dsn=https://[email protected]/22222
quarkus.log.sentry.in-app-packages=*
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class SentryConfig {
* You can configure which package prefixes your application uses with this option.
*
* This option is highly recommended as it affects stacktrace grouping and display on Sentry. See documentation:
* https://docs.sentry.io/clients/java/config/#in-application-stack-frames
* https://quarkus.io/guides/logging-sentry#in-app-packages
*/
@ConfigItem
public Optional<List<String>> inAppPackages;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import static java.lang.String.join;

import java.util.Objects;

import io.sentry.DefaultSentryClientFactory;
import io.sentry.config.provider.ConfigurationProvider;

Expand All @@ -20,7 +22,9 @@ class SentryConfigProvider implements ConfigurationProvider {
public String getProperty(String key) {
switch (key) {
case DefaultSentryClientFactory.IN_APP_FRAMES_OPTION:
return config.inAppPackages.map(p -> join(",", p)).orElse("");
return config.inAppPackages.map(p -> join(",", p))
.filter(s -> !Objects.equals(s, "*"))
.orElse("");
// New SentryConfig options should be mapped here
default:
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public RuntimeValue<Optional<Handler>> create(final SentryConfig config) {
}
if (!config.inAppPackages.isPresent()) {
LOG.warn(
"No 'quarkus.sentry.in-app-packages' was configured, this option is highly recommended as it affects stacktrace grouping and display on Sentry.");
"No 'quarkus.sentry.in-app-packages' was configured, this option is highly recommended as it affects stacktrace grouping and display on Sentry. See https://quarkus.io/guides/logging-sentry#in-app-packages");
}
final SentryConfigProvider provider = new SentryConfigProvider(config);
Sentry.init(SentryOptions.from(new Lookup(provider, provider), config.dsn));
Expand Down

0 comments on commit 30a6027

Please sign in to comment.