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

Auto instrumentation doesn't work + JDBC metrics doesn't send #2465

Closed
NDruce opened this issue Jan 11, 2023 · 31 comments
Closed

Auto instrumentation doesn't work + JDBC metrics doesn't send #2465

NDruce opened this issue Jan 11, 2023 · 31 comments
Assignees

Comments

@NDruce
Copy link

NDruce commented Jan 11, 2023

Integration

sentry-spring-boot-starter

Java Version

17

Version

6.0.0

Steps to Reproduce

Followed official tutorials, rereading them ~30 times, searching a lot of Internet for week, and now I decided to create issue.

I have all Maven dependencies, Sentry Exceptions are successfully sending (but settings in application.properties wasn't work so I wasted 1-2 days to make just work anything). But no one Spring Boot MVC requests was traced:
https://docs.sentry.io/platforms/java/guides/spring-boot/performance/instrumentation/automatic-instrumentation/
(all written in instruction I was made and this Bean was told me via System.out.println that it was called). But no Transactions in Sentry. My sentry.properties config:

dsn=https://**********@**************.ingest.sentry.io/**********
traces-sample-rate=1.0
sample-rate=1.0
debug=true
enable-tracing=true
enable-user-interaction-tracing=true
#exception-resolver-order=-2147483647
send-default-pii=true
max-request-body-size=medium
logging.minimum-event-level=info
logging.minimum-breadcrumb-level=debug
max-breadcrumbs=150
#in-app-includes="com.companyname.application"

I made custom instrumentation:
https://hastebin.com/uwulijeput.php

But I think it's kind of crutch and just a desperation, because no other (and more correct) way of tracing requests doesn’t want to work, and therefore I write the entire implementation myself...

With my instrumentation I have no ability to get all detailed stack trace of calling functions where each submethod call is new child span. And I forced to manually declare spans for each submethod in code.

I just want to understand why automatic instrumentation don't working. Because now I have to take time for write each separate span for a lot of method calls.
When with automatic instrumentation, having code like

public void checkout() {
    paymentServiceCall();
    anyOtherMethod();
}

public void paymentServiceCall() {
    runFraudScorer();
    withdrawFunds();
}

, I can leave this code as is and see in Sentry this:

==========================================================

  • checkout span [took X ms]:
    • paymentServiceCall span [took X ms]:
      • runFraudScorer span [took X ms]
      • withdrawFunds span [took X ms]
    • anyOtherMethod span [took X ms]

==========================================================

I want see this look of Trace ^
And to don't to write a lot of times this:

public void checkout() {
    ITransaction transaction = httpServletRequest.getAttribute("sentryTransactionStoredInRequestAttributesToRetrieveItFromDoFilterMethod");

    ISpan paymentServiceCall_Span = transaction.startChild("paymentServiceCall()");
    paymentServiceCall(paymentServiceCall_Span);
    paymentServiceCall_Span.finish();

    ISpan anyOtherMethod_Span = transaction.startChild("anyOtherMethod()");
    anyOtherMethod(anyOtherMethod_Span);
    anyOtherMethod_Span.finish();
}

public void paymentServiceCall(ISpan parentSpan) {
    ISpan runFraudScorer_Span = parentSpan.startChild("runFraudScorer()");
    runFraudScorer(runFraudScorer_Span);
    runFraudScorer_Span.finish();

    ISpan withdrawFunds_Span = parentSpan.startChild("withdrawFunds()");
    withdrawFunds(withdrawFunds_Span);
    withdrawFunds_Span.finish();
}

Expected Result

Described above.

Also JDBC tracing is not working, I don't see anything in Sentry, but configured that by instruction. My application.properties:

pebble.suffix = .peb
pebble.cache=false
spring.application.name=Application
management.metrics.web.server.auto-time-requests=true
spring.jpa.properties.hibernate.enable_lazy_load_no_trans=true
spring.jpa.hibernate.ddl-auto=create

spring.datasource.url=jdbc:p6spy:h2:mem:testdb
spring.datasource.username=********
spring.datasource.password=********
spring.datasource.driver-class-name=com.p6spy.engine.spy.P6SpyDriver

endpoints.enabled=true
endpoints.actuator.enabled=true
management.endpoints.enabled-by-default=false
management.endpoint.metrics.enabled=true
management.endpoints.metrics.enabled=true
management.endpoints.web.exposure.include=*

Maven:

<dependency>
    <groupId>io.sentry</groupId>
    <artifactId>sentry-jdbc</artifactId>
    <version>6.11.0</version>
</dependency>

Actual Result

No any transaction for any controller request was created. Only with instrumentation coded on my own... As the latest way and the only possible (and single working) way

@NDruce
Copy link
Author

NDruce commented Jan 11, 2023

For sending JDBC metrics also found and tried this AutoConfiguring packages, but nothing became worked:

	<dependency>
		<groupId>com.github.gavlyukovskiy</groupId>
		<artifactId>p6spy-spring-boot-starter</artifactId>
		<version>1.8.1</version>
	</dependency>

	<dependency>
		<groupId>com.github.gavlyukovskiy</groupId>
		<artifactId>datasource-proxy-spring-boot-starter</artifactId>
		<version>1.8.1</version>
	</dependency>

Tried separately and together.

@adinauer
Copy link
Member

adinauer commented Jan 12, 2023

Hello @NDruce I presume you're using Spring Boot 3 in combination with sentry-spring-boot-starter. Can you please give this another try with sentry-spring-boot-starter-jakarta? Sorry for the inconvenience, we're working on improving the docs on the matter. Docs have now been updated https://docs.sentry.io/platforms/java/guides/spring-boot/

@NDruce
Copy link
Author

NDruce commented Jan 12, 2023

Thank you for help and updating documentation. Tried -jakarta dependency, temporarily commented creation of my custom transactions, runned application,
but nothing was traced to Sentry (no debug JSON-report in console and no data in Sentry). In Sentry debug I found only this:

INFO: Initializing SDK with DSN: 'https://xxx@xxx.ingest.sentry.io/xxx'
INFO: No outbox dir path is defined in options.
INFO: GlobalHubMode: 'false'
DEBUG: UncaughtExceptionHandlerIntegration enabled: true
DEBUG: UncaughtExceptionHandlerIntegration installed.
DEBUG: ShutdownHookIntegration installed.
INFO: Initializing SDK with DSN: 'https://xxx@xxx.ingest.sentry.io/xxx'
INFO: No outbox dir path is defined in options.
INFO: GlobalHubMode: 'false'
DEBUG: UncaughtExceptionHandlerIntegration removed.
INFO: Closing SentryClient.
DEBUG: Shutting down
DEBUG: UncaughtExceptionHandlerIntegration enabled: true
DEBUG: UncaughtExceptionHandlerIntegration installed.
DEBUG: ShutdownHookIntegration installed.

Possibly reason is those lines:

INFO: Closing SentryClient.
DEBUG: Shutting down

But have no idea what is cause of it

@NDruce
Copy link
Author

NDruce commented Jan 14, 2023

Help with it please

@adinauer
Copy link
Member

@NDruce can you please share a reproducible sample. I'm unable to reproduce your issue so far. Putting your properties in application.properties (and prefixing them with sentry., e.g. sentry.dsn=...) works for me.

@NDruce
Copy link
Author

NDruce commented Jan 16, 2023

With settings inside application.properties doesn't starting:

image


image


pom.xml: hastebin

@adinauer
Copy link
Member

Can you try updating your pom.xml:

<dependency>
	<groupId>io.sentry</groupId>
	<artifactId>sentry-bom</artifactId>
	<version>6.0.0-beta.2</version>
	<type>pom</type>
	<scope>import</scope>
</dependency>

Having an old version here might be causing issues.

Do other settings, that are not Sentry specific but spring specific in your applicaton.properties take effect?

@NDruce
Copy link
Author

NDruce commented Jan 17, 2023

After updating pom.xml sentry-bom to latest 6.12.0 still
IllegalArgumentException: DSN is required. Use empty string to disable SDK.

My application.properties:

pebble.suffix = .peb
pebble.cache=false
spring.application.name=App
spring.jpa.properties.hibernate.enable_lazy_load_no_trans=true

spring.datasource.url=jdbc:p6spy:h2:mem:testdb
spring.datasource.username=user
spring.datasource.password=password
spring.datasource.driver-class-name=com.p6spy.engine.spy.P6SpyDriver
p6spy.config.modulelist=com.p6spy.engine.spy.P6SpyFactory
p6spy.enable-logging=true
p6spy.logging=slf4j

spring.jpa.hibernate.ddl-auto=create
#spring.jpa.show-sql = true
#spring.jpa.properties.hibernate.format_sql = true
#spring.jpa.properties.hibernate.use_sql_comments = true

#logging.level.org.springframework.security=DEBUG
spring.devtools.livereload.enabled=true

management.metrics.web.server.auto-time-requests=true




# TODO:

#endpoints.enabled=false
#endpoints.actuator.enabled=false
#management.endpoints.enabled-by-default=false
#management.endpoint.metrics.enabled=false
#management.endpoints.metrics.enabled=false
#management.endpoints.web.exposure.include=

# TEMP!!!: #
endpoints.enabled=true
endpoints.actuator.enabled=true
management.endpoints.enabled-by-default=false
management.endpoint.metrics.enabled=true
management.endpoints.metrics.enabled=true
management.endpoints.web.exposure.include=* 
##############

sentry.dsn=https://xxx@xxx.ingest.sentry.io/xxx
sentry.traces-sample-rate=1.0
sentry.sample-rate=1.0
sentry.debug=true
sentry.enable-tracing=true
sentry.enable-user-interaction-tracing=true
sentry.exception-resolver-order=-2147483647
sentry.send-default-pii=true
sentry.max-request-body-size=medium
sentry.logging.minimum-event-level=info
sentry.logging.minimum-breadcrumb-level=debug
sentry.max-breadcrumbs=150
#sentry.in-app-includes="com.company.app"
sentry.modulelist=com.p6spy.engine.spy.P6SpyFactory

@adinauer
Copy link
Member

Things you can try:

  • provide a reproducible sample so I can test things and help you
  • check (e.g. using debugger) what's calling Sentry.init; I assume it's not our Spring Boot integration performing the init because it checks for dsn to be present.
  • check Spring DEBUG log. It should show, amongst others, these lines:
Creating shared instance of singleton bean 'sentry-io.sentry.spring.boot.jakarta.SentryProperties'
SentryAutoConfiguration matched:
      - @ConditionalOnProperty (sentry.dsn) matched (OnPropertyCondition)
SentryLogbackAppenderAutoConfiguration matched:
      - @ConditionalOnClass found required classes 'ch.qos.logback.classic.LoggerContext', 'io.sentry.logback.SentryAppender' (OnClassCondition)
      - @ConditionalOnProperty (sentry.logging.enabled=true) matched (OnPropertyCondition)
      - @ConditionalOnBean (types: io.sentry.spring.boot.jakarta.SentryProperties; SearchStrategy: all) found bean 'sentry-io.sentry.spring.boot.jakarta.SentryProperties' (OnBeanCondition)

@NDruce
Copy link
Author

NDruce commented Jan 18, 2023

Wow. I was removed Sentry.init() and now it work. But log contain only this:

[  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'io.sentry.spring.jakarta.tracing.SentryAdviceConfiguration' of type [io.sentry.spring.jakarta.tracing.SentryAdviceConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
[  restartedMain] ocalVariableTableParameterNameDiscoverer : Using deprecated '-debug' fallback for parameter name resolution. Compile the affected code with '-parameters' instead or avoid its introspection: io.sentry.spring.jakarta.tracing.SentryAdviceConfiguration
[  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'io.sentry.spring.jakarta.tracing.SentrySpanPointcutConfiguration' of type [io.sentry.spring.jakarta.tracing.SentrySpanPointcutConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
[  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'sentrySpanPointcut' of type [org.springframework.aop.support.ComposablePointcut] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
[  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'io.sentry.spring.boot.jakarta.SentryAutoConfiguration$HubConfiguration' of type [io.sentry.spring.boot.jakarta.SentryAutoConfiguration$HubConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
[  restartedMain] ocalVariableTableParameterNameDiscoverer : Using deprecated '-debug' fallback for parameter name resolution. Compile the affected code with '-parameters' instead or avoid its introspection: io.sentry.spring.boot.jakarta.SentryAutoConfiguration$HubConfiguration
[  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'io.sentry.spring.boot.jakarta.SentryAutoConfiguration$HubConfiguration$ContextTagsEventProcessorConfiguration' of type [io.sentry.spring.boot.jakarta.SentryAutoConfiguration$HubConfiguration$ContextTagsEventProcessorConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
[  restartedMain] ocalVariableTableParameterNameDiscoverer : Using deprecated '-debug' fallback for parameter name resolution. Compile the affected code with '-parameters' instead or avoid its introspection: io.sentry.spring.boot.jakarta.SentryAutoConfiguration$HubConfiguration$ContextTagsEventProcessorConfiguration
[  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'sentry-io.sentry.spring.boot.jakarta.SentryProperties' of type [io.sentry.spring.boot.jakarta.SentryProperties] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
[  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'contextTagsEventProcessor' of type [io.sentry.spring.jakarta.ContextTagsEventProcessor] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
[  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'inAppPackagesResolver' of type [io.sentry.spring.boot.jakarta.InAppIncludesResolver] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
[  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'sentryOptionsConfiguration' of type [io.sentry.spring.boot.jakarta.SentryAutoConfiguration$HubConfiguration$$Lambda$653/0x000000080103f3a8] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
[  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'devAppApplication' of type [com.company.app.AppApplication$$SpringCGLIB$$0] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
INFO: Initializing SDK with DSN: 'https://xxx@xxx.ingest.sentry.io/xxx'
INFO: No outbox dir path is defined in options.
INFO: GlobalHubMode: 'false'
DEBUG: UncaughtExceptionHandlerIntegration enabled: true
DEBUG: UncaughtExceptionHandlerIntegration installed.
DEBUG: ShutdownHookIntegration installed.
[  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'sentryHub' of type [io.sentry.HubAdapter] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
[  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'sentrySpanAdvice' of type [io.sentry.spring.jakarta.tracing.SentrySpanAdvice] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
[  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'sentrySpanAdvisor' of type [org.springframework.aop.support.DefaultPointcutAdvisor] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
[  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'io.sentry.spring.jakarta.tracing.SentryTransactionPointcutConfiguration' of type [io.sentry.spring.jakarta.tracing.SentryTransactionPointcutConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
[  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'sentryTransactionPointcut' of type [org.springframework.aop.support.ComposablePointcut] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
[  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'sentryTransactionAdvice' of type [io.sentry.spring.jakarta.tracing.SentryTransactionAdvice] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
[  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'sentryTransactionAdvisor' of type [org.springframework.aop.support.DefaultPointcutAdvisor] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)

[  restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)

(What does all this ^ means?)


And contain debug about which data sent in envelops to Sentry:

DEBUG: Serializing object: {
    ...
}
DEBUG: Envelope sent successfully.
DEBUG: Envelope flushed

@NDruce
Copy link
Author

NDruce commented Jan 18, 2023

And how to take current transaction inside controller? To create spans inside controller method

@adinauer
Copy link
Member

Have you looked at https://docs.sentry.io/platforms/java/guides/spring-boot/performance/instrumentation/custom-instrumentation/ . It explains how you can do it. Please let me know if you have any more questions.

@NDruce
Copy link
Author

NDruce commented Jan 19, 2023

How to deal with console output above? It doesn't match reference you published to compare

@adinauer
Copy link
Member

restartedMain indicates dev tools restarting, haven't tried that. I assume that's the reason for the different logs as well. Please try a clean restart of the application.

@NDruce
Copy link
Author

NDruce commented Jan 20, 2023

Tried to clean restart of application, even with devtools livereload disabled in application.properties (pom.xmls don't have this at all), but still the same problem. Googled, but no result to understand how to solve it.

I fount that other guy having the same issue, but his thread name is main, not restartedMain. So I think it's not the reason of non-eligibility of Sentry Beans

@adinauer
Copy link
Member

Developer tools are automatically disabled when running a fully packaged application. If your application is launched from java -jar or if it is started from a special classloader, then it is considered a “production application”. You can control this behavior by using the spring.devtools.restart.enabled system property. To enable devtools, irrespective of the classloader used to launch your application, set the -Dspring.devtools.restart.enabled=true system property. This must not be done in a production environment where running devtools is a security risk. To disable devtools, exclude the dependency or set the -Dspring.devtools.restart.enabled=false system property.

Maybe this helps. Found it here: https://docs.spring.io/spring-boot/docs/current/reference/html/using.html#using.devtools

I'm still unable to reproduce. Please provide a sample that allows me to help you if you need my assistance.

@NDruce
Copy link
Author

NDruce commented Jan 23, 2023

Option to disable devtools is worked via run arg, thread name now "main", but still the same problems with Beans are displayed in log.

Can you send please working example of application for reference?
I will compare it with my code and will know which code files need to sent in case if it will still not work after changes according to example

@adinauer
Copy link
Member

You can find a sample here: https://github.com/getsentry/sentry-java/tree/main/sentry-samples/sentry-samples-spring-boot-jakarta

There's more in the parent directory if it's not the one you need.

@NDruce
Copy link
Author

NDruce commented Jan 25, 2023

I getting this error:

image

I was patched it with this method to work:

	@Bean
	public RestTemplateBuilder restTemplateBuilder() {
		return new RestTemplateBuilder();
	}

But seems like it's wrong way.

Tried to run app with this error, it's started, but Beans problem in log still exist and no any JDBC metric in Sentry.

In app code all is like in example.
I'm not sure about I will be allowed to share app code. All is already like as on examples

@adinauer
Copy link
Member

Did you try starting the sample with your own DSN to verify that's working?

@NDruce
Copy link
Author

NDruce commented Jan 27, 2023

Yes

@adinauer
Copy link
Member

So the problem only shows up in your own application but not our sample, correct? I'm still unable to help you without a sample that reproduces this. If you can tell me how I need to modify our sample to get your error to show up, I might be able to help.

@NDruce
Copy link
Author

NDruce commented Jan 30, 2023

Invited to https://github.com/NDruce/testapp

@adinauer adinauer self-assigned this Feb 2, 2023
@adinauer
Copy link
Member

adinauer commented Feb 2, 2023

Hello @NDruce. Thank you for the sample. I tested and it sends events to Sentry.

After adding an @Entity and Repository to your sample and using the repo in TestController a transaction is created for /api/test which contains a Span for the DB query. This also shows up in Sentry UI.

The log messages seem to be linked to using spring-boot-starter-data-jpa. If I strip that (and related code) from your sample the log messages disappear. When adding spring-boot-starter-data-jpa to our sample the log messages also show up.

I still haven't figured out how to fix it. I also haven't found any broken features due to this either.

@NDruce
Copy link
Author

NDruce commented Feb 3, 2023

Tested. It's working. Messages in console are still existing, but working. I have some questions:

  1. Can I make names like on screenshot below instead of weird http.server and etc.?
    image
    I was made them in custom instrumentation, but it was not good way which doesn't have many things like JDBC tracing stuff.

  2. How to do not trace requests to controllers like /assets/**? It's just static files (images, css, js...)

  3. How to give names for some operations? Can you provide exact example, how to start and end custom span with custom name inside controller code? Because documentation has different code examples (implementations) for that. And I need somehow get current transaction object inside controller code. I was seen Sentry.* static examples, but it's static Sentry object, so it's doesn't refers to create spans in current transaction. Static != current

@NDruce
Copy link
Author

NDruce commented Feb 3, 2023

  1. How to track scheduled jobs? I see only one scheduled job was sent to Sentry:
    image

  2. I found a bug:
    image
    Access to .svg file (and other static files) is described as "Application is started". Application was started just once. But completely other events are still using this message.

-------------------------------> Full log <-------------------------------

@adinauer
Copy link
Member

adinauer commented Feb 3, 2023

  1. The http.server op should only be shown for the topmost span of the transaction. You can see the nicer looking name on top of your screenshot: POST /api/autocomplete.
  2. You can use beforeSend to filter out errors and beforeSendTransaction to filter out transactions
  3. We use a ThreadLocal to set the Hub on the current Thread. So invocations to the static Sentry.* should go to the correct transaction. This (https://docs.sentry.io/platforms/java/guides/spring-boot/performance/instrumentation/custom-instrumentation/#add-more-spans-to-the-transaction) should help figure out the code.
  4. Should be as simple as slapping @SentryTransaction on the job class. See https://docs.sentry.io/platforms/java/guides/spring-boot/performance/instrumentation/custom-instrumentation/#capturing-a-transaction
  5. This is just a breadcrumb that was added because your sentry-logback is configured to add breadcrumbs for log lines of level debug or higher (sentry.logging.minimum-breadcrumb-level=debug in application.properties). These may be of varying usefulness.

Hope this helps.

@NDruce
Copy link
Author

NDruce commented Feb 3, 2023

So invocations to the static Sentry.* should go to the correct transaction

But what if in one time app will handle multiple requests? Maybe about 64 in one time? It will be 64 threads? I guess one thread utilizing one CPU core, but cores amount is 4-16 at all, so some requests possibly can unite/hook into one thread (so 64 queries / 8 cpu cores = 8 requests in one thread, causing getting wrong transaction object). Are my assumptions correct or wrong?

@NDruce
Copy link
Author

NDruce commented Feb 3, 2023

Also have this error when stopping application:

2023-02-03T17:54:52.667-05:00  INFO 24844 --- [ionShutdownHook] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown initiated...
2023-02-03T17:54:52.668-05:00  INFO 24844 --- [ionShutdownHook] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown completed.
DEBUG: UncaughtExceptionHandlerIntegration removed.
ERROR: Error while closing the Hub.
java.lang.IllegalStateException: Shutdown in progress
	at java.base/java.lang.ApplicationShutdownHooks.remove(ApplicationShutdownHooks.java:82)
	at java.base/java.lang.Runtime.removeShutdownHook(Runtime.java:245)
	at io.sentry.ShutdownHookIntegration.close(ShutdownHookIntegration.java:44)
	at io.sentry.Hub.close(Hub.java:340)
	at io.sentry.Sentry.close(Sentry.java:304)
	at io.sentry.HubAdapter.close(HubAdapter.java:82)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at org.springframework.beans.factory.support.DisposableBeanAdapter.invokeCustomDestroyMethod(DisposableBeanAdapter.java:283)
	at org.springframework.beans.factory.support.DisposableBeanAdapter.destroy(DisposableBeanAdapter.java:232)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroyBean(DefaultSingletonBeanRegistry.java:587)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingleton(DefaultSingletonBeanRegistry.java:559)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingleton(DefaultListableBeanFactory.java:1177)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingletons(DefaultSingletonBeanRegistry.java:520)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingletons(DefaultListableBeanFactory.java:1170)
	at org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1082)
	at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1051)
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.doClose(ServletWebServerApplicationContext.java:173)
	at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:1001)
	at org.springframework.boot.SpringApplicationShutdownHook.closeAndWait(SpringApplicationShutdownHook.java:139)
	at java.base/java.lang.Iterable.forEach(Iterable.java:75)
	at org.springframework.boot.SpringApplicationShutdownHook.run(SpringApplicationShutdownHook.java:108)
	at java.base/java.lang.Thread.run(Thread.java:833)


Process finished with exit code 130

@adinauer
Copy link
Member

adinauer commented Feb 6, 2023

In Spring WebMVC requests are handled in a blocking manner. Number of threads can be controlled using config properties like server.tomcat.threads.max=1. So the ThreadLocal approach works there. For WebFlux and similar the model doesn't work so well. There's multiple issues on this repo and we're exploring fixes for it but haven't found one we like yet.

I'll take a look at the Shutdown in progress.

@adinauer
Copy link
Member

Closing this now as all questions seem to have been answered and the PR has been merged. Feel free to reopen if you need more assistance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants