question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Setry does not capture event if inited programatically with Spring boot starter

See original GitHub issue

Hi there,

I am building and app, where I need to configure both backend and frontend DSNs in my properties.yaml such as

tolgee:
  sentry:
    enabled: true
    server-dsn: ...
    client-dsn: ...

That’s why i don’t want to use other configuration options such as “sentry.dsn” option.

I would like to init sentry in code as documentation says: https://docs.sentry.io/platforms/java/guides/spring-boot/configuration/

import io.sentry.Sentry;

Sentry.init(options -> {
  options.setDsn("https://examplePublicKey@o0.ingest.sentry.io/0");
});

But when I do so, It doesn’t capture anything. So maybe the documentation is wrong or I am doing something wrong. I am calling the init method in my main Application class constructor.

If i provide “sentry.dsn”, it works properly, so as a workaround I do this in my application.yaml

sentry:
  dsn: ${tolgee.sentry.server-dsn}

Should I call the Sentry.init method elsewhere? Or is there another reason why it doesn’t work?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7

github_iconTop GitHub Comments

2reactions
maciejwalkowiakcommented, Mar 19, 2021

You cannot default to null this way (read more: https://github.com/spring-projects/spring-framework/issues/19986).

Sentry accepts empty string as a DSN - this will disable Sentry integration:

sentry.dsn=${tolgee.sentry.server-dsn:}

Spring integration is configured only if property sentry.dsn is present. If you initialize Sentry manually, you can send Sentry events created manually but you the whole servlet infrastructure to capture exceptions to Sentry isn’t there.

0reactions
maciejwalkowiakcommented, Mar 19, 2021

Great! 💪

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshooting Spring Boot applications with Sentry
Sentry Spring Boot Starter provides an auto-configuration for Logback - once it finds out that both logback and sentry-logback are in the ...
Read more >
Sentry.io doesn't capture errors when Spring Boot running in ...
When you add Sentry's SDK to your app and configure it with the correct DSN , your app will connect to Sentry to...
Read more >
Bootiful Exception Reporting with Sentry & Spring Boot
0:00 - The problem with error reporting0:54 - What is Sentry ? 3:49 - Sentry + Spring Boot Integration7:11 - Attaching user information...
Read more >
[VDZ22] Troubleshooting Spring Boot applications with Sentry ...
No matter how clean our code is, how good our tests are, how well our infrastructure scales - one day, eventually something will...
Read more >
Sentry with Spring Boot - 42talents
Adding Sentry to your Spring Boot applications is done in two steps: Add sentry-spring-boot-starter as a dependency to pom.xml . Since it's not...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found