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

DSN is required. Use empty string to disable SDK when building Native in Spring Boot #2742

Closed
JakobStadlhuber opened this issue May 29, 2023 · 16 comments · Fixed by #2915
Closed
Assignees
Labels
Platform: Java Type: Bug Something isn't working

Comments

@JakobStadlhuber
Copy link

JakobStadlhuber commented May 29, 2023

Integration

sentry

Java Version

17

Spring Boot Version

3.0.7
and plugin with id("org.graalvm.buildtools.native") version "0.9.20"

I tried it on an M1 with this additional option:
kotlin tasks.withType<org.springframework.boot.gradle.tasks.bundling.BootBuildImage> { if (org.gradle.nativeplatform.platform.internal.DefaultNativePlatform.getCurrentArchitecture().isArm) { builder.set("dashaun/builder-arm:tiny") } }

Version

6.20.0 (logback, sentry-jdbc, sentry-spring-boot-starter-jakarta)

Steps to Reproduce

  1. Configure Sentry with application.properties (sentry.dsn=xxxx)
  2. gradle bootBuildImage

Expected Result

No error when building the native image

Actual Result

Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sentryTransactionAdvice' defined in class path resource [io/sentry/spring/jakarta/tracing/SentryAdviceConfiguration.class]: Unsatisfied dependency expressed through method 'sentryTransactionAdvice' parameter 0: Error creating bean with name 'sentryHub' defined in class path resource [io/sentry/spring/boot/jakarta/SentryAutoConfiguration$HubConfiguration.class]: Failed to instantiate [io.sentry.IHub]: Factory method 'sentryHub' threw exception with message: DSN is required. Use empty string to disable SDK.

@bj97301
Copy link

bj97301 commented May 29, 2023

i got this error when i set debug to a string value instead of a bool recently

@adinauer
Copy link
Member

@JakobStadlhuber please let us know if @bj97301's comment helped to fix your problem.

@bj97301
Copy link

bj97301 commented May 30, 2023

@JakobStadlhuber please let us know if @bj97301's comment helped to fix your problem.

Can we get a better error message for this though?

@adinauer
Copy link
Member

@bj97301 we'll look into improving the error message.

@JakobStadlhuber
Copy link
Author

JakobStadlhuber commented Jun 8, 2023

@JakobStadlhuber please let us know if @bj97301's comment helped to fix your problem.

No,

I use no debugging and the problem still appears:

sentry.dsn=xxx
sentry.traces-sample-rate=1.0
sentry.environment=dev

I tried it with sentry.debug=false still the same error.

@adinauer
Copy link
Member

adinauer commented Jun 9, 2023

@JakobStadlhuber can you please try without sentry.traces-sample-rate=1.0 in your application.properties?

@adinauer
Copy link
Member

Could you please also give the following a try:

  @Bean
  Sentry.OptionsConfiguration<SentryOptions> optionsConfiguration() {
    return new Sentry.OptionsConfiguration<SentryOptions>() {
      @Override
      public void configure(@NotNull SentryOptions options) {
        options.setTracesSampleRate(1.0);
      }
    };
  }

@adinauer
Copy link
Member

This could be related to AOP. When I tried some possible fixes while on the branch for #2764 I wasn't able to fix it. Need to check if disabling all AOP related things gets rid of the problem.

@getsantry
Copy link

getsantry bot commented Jul 22, 2023

This issue has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you remove the label Waiting for: Community, I will leave it alone ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

@getsantry getsantry bot added the Stale label Jul 22, 2023
@JakobStadlhuber
Copy link
Author

Are there any news on this?

@adinauer
Copy link
Member

Hello @JakobStadlhuber not yet. Working on something else at the moment. Can't say yet when I'll get to this - sorry.

@lbloder
Copy link
Collaborator

lbloder commented Sep 6, 2023

Hi @JakobStadlhuber,
Sorry for the delay. With #2915 we're introducing a new property: sentry.enable-aot-compatibility that you can set to true in the application.properties. This disables the AOP related functionality (e.g. @SentryTransaction and @SentrySpan) which interfered with building for graalvm. As soon as this is merged and included in a Release you can give it a try.

In order to then successfully run it, it is still required to create the .json hint files for reflection, proxies etc. There's a java agent that automatically creates these for you. Documentation on that can be found here: https://docs.spring.io/spring-boot/docs/current/reference/html/native-image.html#native-image.advanced.using-the-tracing-agent.

Looking forward to your feedback.

@julien-lisub
Copy link

Hello,

I am using the Sentry-Expo plugin and I had an issue where I constantly got the DSN is required message.
After a lot of debugging and drilling down, I found out that since I was using .env to set the init config, the debug property ended up as a string. Which was leading to that error.

I ended up setting debug based on the environment, so it's always a boolean.

Just wanted to share my experience here.

@adinauer
Copy link
Member

Let's keep this open until we have some feedback.

@adinauer
Copy link
Member

adinauer commented Oct 2, 2023

@JakobStadlhuber can you please retest with sentry.enable-aot-compatibility=true using at least 6.30.0 of the Java SDK?

@JakobStadlhuber
Copy link
Author

Yes it works, thank you :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Platform: Java Type: Bug Something isn't working
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

6 participants