Skip to content

Failed to init Sentry during appender initialization: DSN is required #4531

Open
@dodgex

Description

@dodgex

Integration

sentry-spring-boot-jakarta

Java Version

21

Version

8.16.0

Steps to Reproduce

  • Spring Boot 3.5.3
  • no logback.xml
  • sentry.dsn in applicaiton.yml

Dependencies on classpath:

  • sentry
  • sentry-logback
  • sentry-reactor
  • sentry-spring-boot-jakarta
  • sentry-spring-boot-starter-jakarta
  • sentry-spring-jakarta

Expected Result

No warnings about sentry failing to init

Actual Result

There is a warning logged:

12:17:28,447 |-WARN in io.sentry.logback.SentryAppender[SENTRY_APPENDER] - Failed to init Sentry during appender initialization: DSN is required. Use empty string or set enabled to false in SentryOptions to disable SDK.

Even tho it works.

Adding a breakpoint in Sentry.init() reveals, that is been called twice, once from SentryAutoConfiguration and again from SentryAppender#start via SentryLogbackInitializer. The problem on that second call is, that the SentryAppender creates an empty SentryOptions instance that is used in start(). If the SentryLogbackInitializer would pass its instance of SentryProperties to the Appender on creation, the warning does not appear.

Potential fixes (from my understanding of what happens :D):

  • Add sentryAppender.setOptions(sentryProperties); here and potentially here too
  • or verify if the condition here should possibly be changed to options.getDsn() != null

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions