Coder Social home page Coder Social logo

gavlyukovskiy / spring-boot-data-source-decorator Goto Github PK

View Code? Open in Web Editor NEW
805.0 805.0 81.0 2.8 MB

Spring Boot integration with p6spy, datasource-proxy, flexy-pool and spring-cloud-sleuth

License: Apache License 2.0

Java 100.00%
connection-pool datasource datasource-proxy flexy-pool jdbc micrometer p6spy spring-boot spring-boot-starters spring-cloud-sleuth sql-queries

spring-boot-data-source-decorator's Introduction

spring-boot-data-source-decorator's People

Contributors

chadlwilson avatar cyrilp avatar gavlyukovskiy avatar kevinjom avatar oburgosm avatar reta avatar rvullriede avatar scordio avatar shakuzen avatar svanacker avatar ttddyy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

spring-boot-data-source-decorator's Issues

ClassNotFoundException found for DataSourcePoolMetadata in Springboot 2.0.0.RC2

When including below dependency in my springboot application I get a ClassNotFoundException.

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

Looks like DataSourcePoolMetadata moved from
org.springframework.boot.autoconfigure.jdbc.metadata.DataSourcePoolMetadata
to
org.springframework.boot.jdbc.metadata.DataSourcePoolMetadataProvider

Are there plans for a Springboot 2 compatible version?

Out of memory when using datasource-proxy-spring-boot-starter

When I include datasource-proxy-spring-boot-starter (v1.3.2) in my project I get an out of memory exception. When analysing it in MAT I see:

One instance of "java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue" loaded by "<system class loader>" occupies 84,915,400 (35.90%) bytes. The instance is referenced by net.ttddyy.dsproxy.listener.logging.SLF4JSlowQueryListener @ 0xef5be0d8 , loaded by "org.springframework.boot.loader.LaunchedURLClassLoader @ 0xed41b578". The memory is accumulated in one instance of "java.util.concurrent.RunnableScheduledFuture[]" loaded by "<system class loader>".
Any ideas why this might happen?

Set the dataSourceName as remoteServiceName in TracingListenerStrategy

Right now, in our Spring Sleuth Configuration you are using the dataSourceName in TracingListenerStrategy.beforeGetConnection only in the span name, but if you would also call connectionSpan.setRemoteServiceName(dataSourceName) then then database name would be sent to Zipkin as well and the database then would also be shown in the dependencies-view of Zipkin.

Same would need to be done in beforeQuery and beforeResultSetNext

This is how the brave-instrumentation library does exactly that job: https://github.com/openzipkin/brave/blob/master/instrumentation/p6spy/src/main/java/brave/p6spy/TracingJdbcEventListener.java#L118

Getting empty results

I configured a spring boot starter as per instructions

## p6spy ###
# Register P6LogFactory to log JDBC events
decorator.datasource.p6spy.enable-logging=true
decorator.datasource.datasource-proxy.query.log-level=debug
decorator.datasource.datasource-proxy.slow-query.enable-logging=true
decorator.datasource.datasource-proxy.slow-query.log-level=warn
decorator.datasource.datasource-proxy.slow-query.logger-name=
# Use com.p6spy.engine.spy.appender.MultiLineFormat instead of com.p6spy.engine.spy.appender.SingleLineFormat
decorator.datasource.p6spy.multiline=true
# Use logging for default listeners [slf4j, sysout, file]
decorator.datasource.p6spy.logging=slf4j
# Log file to use (only with logging=file)
decorator.datasource.p6spy.log-file=spy.log
# Custom log format, if specified com.p6spy.engine.spy.appender.CustomLineFormat will be used with this log format
decorator.datasource.p6spy.log-format=

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

but getting some empty output from p6spy:

2019-12-24 16:22:13.103 DEBUG 11672 --- [ntainer#0-0-C-1] o.s.jdbc.core.JdbcTemplate               : Executing prepared SQL query
2019-12-24 16:22:13.103 DEBUG 11672 --- [ntainer#0-0-C-1] o.s.jdbc.core.JdbcTemplate               : Executing prepared SQL statement [SELECT COMIT_ID FROM DPL_PARTY.USR_DTL WHERE INDVDL_ID = (SELECT INDVDL_ID FROM DPL_PARTY.INDVDL_TLCMMNCTN WHERE EML_VAL = ?)]
2019-12-24 16:22:13.181  INFO 11672 --- [ntainer#0-0-C-1] p6spy                                    : 
2019-12-24 16:22:13.182 DEBUG 11672 --- [ntainer#0-0-C-1] c.s.a.repository.UserRepository          : Obtained comitId=XBBKRHL for email of [email protected] from the DB.
2019-12-24 16:22:13.286  INFO 11672 --- [ntainer#0-0-C-1] p6spy                                    : 

The query themselves execute fine. What am I missing here? Thanks.

Traces are send to Zipkin bypassing RabbitMQ

After adding dependency compile('com.github.gavlyukovskiy:datasource-proxy-spring-boot-starter:1.3.5'), i found that traces are sent directly to Zipkin.

I am unable to find a way to hook RabbitMQ which i was able to do using,
compile("org.springframework.cloud:spring-cloud-starter-zipkin")
compile("org.springframework.amqp:spring-rabbit")

Is it an issue or configuration problem?

Thanks

DataSource decorator with HikariDataSourcePoolMetadata

I have an SB 2.5 application with a Hikari datasource and I'm using datasource-proxy-spring-boot-starter (1.7.1).

Also I am using datasources metrics provided by SB, based on class HikariDataSourcePoolMetadata, and here I have the problem. The method getActive invoke to getHikariPool that does this:

        private HikariPool getHikariPool() {
		return (HikariPool) new DirectFieldAccessor(getDataSource()).getPropertyValue("pool");
	}

But, because the datasource is a proxy, it return null.

I¡m not sure if it's possible that proxied datasource will give access to field pool, or it's an issue that I should report to SB.

Meanwhile I have a workaround. I have created the next bean, which take into account that HikariDataSource could be a proxy and it have more priority that bean hikariPoolDataSourceMetadataProvider provides by SB :

    @Bean
    @Order(Ordered.LOWEST_PRECEDENCE - 10)
    DataSourcePoolMetadataProvider customHikariPoolDataSourceMetadataProvider() {
        return (dataSource) -> {
            HikariDataSource hikariDataSource = DataSourceUnwrapper.unwrap(dataSource, HikariConfigMXBean.class,
                    HikariDataSource.class);
            if (hikariDataSource != null) {
                // Because HikariDataSourcePoolMetadata access to HikariPool via reflection, we need to unwrap AOP
                // proxies
                if (AopUtils.isAopProxy(hikariDataSource)) {
                    Object target;
                    try {
                        target = ((Advised) hikariDataSource).getTargetSource().getTarget();
                        hikariDataSource = (HikariDataSource) target;
                    } catch (Exception ex) {
                        LOG.warn(
                                "Unwrap hikari AOP proxy failed. We instrument Hikari proxied datasource, but some metrics might not be available");
                    }
                }
                return new HikariDataSourcePoolMetadata(hikariDataSource);
            }
            return null;
        };
    }


Hibernate and Update Queries

I'm using Spring Boot, Hibernate, and spring-boot-datasource-decorator with p6spy. For whatever reason, I don't see any update statements logged. The only related thing I could find is:

https://stackoverflow.com/questions/46251315/p6spy-does-not-log-hibernate-update-with-hsqldb

I tried the suggestion of not excluding batch, but that didn't help either.

Since spring-boot-datasource-proxy-decorator supports datasource-proxy, I tried datasource-proxy. It didn't log updates either.

Is there another setting required to log updates?

Is there a setting in hibernate that has to be done?

DataSourceHealthIndicator throws NPE v1.5.6

Integrated spring-boot-data-source-decorator 1.5.6 with spring boot 2.1.6 micro service , and getting DataSourceHealthIndicator : DataSource health check failed Null pointer exception.


[io-18201-exec-5]o.s.b.a.jdbc.DataSourceHealthIndicator : DataSource health check failed

java.lang.NullPointerException: null
at com.github.gavlyukovskiy.cloud.sleuth.TracingListenerStrategy.beforeQuery(TracingListenerStrategy.java:56)
at com.github.gavlyukovskiy.cloud.sleuth.TracingQueryExecutionListener.beforeQuery(TracingQueryExecutionListener.java:53)

at net.ttddyy.dsproxy.listener.ChainListener.beforeQuery(ChainListener.java:20)
at net.ttddyy.dsproxy.proxy.StatementProxyLogic.performQueryExecutionListener(StatementProxyLogic.java:308)
at net.ttddyy.dsproxy.proxy.StatementProxyLogic.access$700(StatementProxyLogic.java:37)
at net.ttddyy.dsproxy.proxy.StatementProxyLogic$1.execute(StatementProxyLogic.java:123)
at net.ttddyy.dsproxy.listener.MethodExecutionListenerUtils.invoke(MethodExecutionListenerUtils.java:42)
at net.ttddyy.dsproxy.proxy.StatementProxyLogic.invoke(StatementProxyLogic.java:120)
at net.ttddyy.dsproxy.proxy.jdk.StatementInvocationHandler.invoke(StatementInvocationHandler.java:34)
at com.sun.proxy.$Proxy362.executeQuery(Unknown Source)
at org.springframework.jdbc.core.JdbcTemplate$1QueryStatementCallback.doInStatement(JdbcTemplate.java:438)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:375)
at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:451)
at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:461)
at org.springframework.boot.actuate.jdbc.DataSourceHealthIndicator.doDataSourceHealthCheck(DataSourceHealthIndicator.java:112)
at org.springframework.boot.actuate.jdbc.DataSourceHealthIndicator.doHealthCheck(DataSourceHealthIndicator.java:102)
at org.springframework.boot.actuate.health.AbstractHealthIndicator.health(AbstractHealthIndicator.java:82)
at org.springframework.boot.actuate.health.CompositeHealthIndicator.health(CompositeHealthIndicator.java:95)
at org.springframework.boot.actuate.health.CompositeHealthIndicator.health(CompositeHealthIndicator.java:95)
at org.springframework.boot.actuate.health.HealthEndpoint.health(HealthEndpoint.java:50)
at org.springframework.boot.actuate.health.HealthEndpointWebExtension.health(HealthEndpointWebExtension.java:53)
at sun.reflect.GeneratedMethodAccessor289.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:282)
at org.springframework.boot.actuate.endpoint.invoke.reflect.ReflectiveOperationInvoker.invoke(ReflectiveOperationInvoker.java:76)
at org.springframework.boot.actuate.endpoint.annotation.AbstractDiscoveredOperation.invoke(AbstractDiscoveredOperation.java:60)
at org.springframework.boot.actuate.endpoint.web.servlet.AbstractWebMvcEndpointHandlerMapping$ServletWebOperationAdapter.handle(AbstractWebMvcEndpointHandlerMapping.java:278)
at org.springframework.boot.actuate.endpoint.web.servlet.AbstractWebMvcEndpointHandlerMapping$OperationHandler.handle(AbstractWebMvcEndpointHandlerMapping.java:334)
at sun.reflect.GeneratedMethodAccessor288.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:892)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:797)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
at org.springframework.boot.actuate.autoconfigure.web.servlet.CompositeHandlerAdapter.handle(CompositeHandlerAdapter.java:58)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1039)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:942)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1005)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:897)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:634)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:882)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:209)
at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:490)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:853)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1587)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)

Possible memory leak - datasource proxy

Hello, today I have come across possible memory leak in datasource proxy inside TracingListenerStrategy

After 250k requests to server, the strategy instance acumulates nearly 900MB of memory and never releases it.

image

I have latest version of datasource proxy spring boot starter.

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

configuration properties

decorator:
  datasource:
    datasource-proxy:
      query:
        enable-logging: false
      slow-query:
        threshold: 1
      count-query: true

When using p6spy, the problem does not seem to be present.

Upgrade to Sleuth 2.X

Hey,

Are there any plans to upgrade to the latest version of spring-sleuth? At the minute the library does not appear to work due to some of the changes in sleuth/zipkin.

Cheers!

p6spy-spring-boot-starter:1.5.0 with SpringBoot 2.0.6 exception

I'm trying to use p6spy-spring-boot-starter with a spring boot 2.0.6.RELEASE but it fails after startup with FileNotFoundException. Problem dissappears after removing p6spy-starter. Jdk version is jdk1.8.0_161.
Please see stack trace in attached file.
Let me know if I can provide more details about this issue. Thank you in advance.

p6spy-exception.txt

Datasource Decorator For Multi-Tenancy

When we have a map of data sources in case of multi-tenant, every entry needs to be decorated in order to get it instumented.

How can we configure such thing ?

Null pointer in case of scheduled jobs

I am working on v1.3.3 and using p6spy module with springboot 1.5.4. One of our scheduled jobs runs using org.springframework.cloud.sleuth.instrument.async.LazyTraceExecutor for tracing.

Whenever this job runs, there is a null pointer at TracingJdbcEventListener.onAfterStatementClose():141 because tracer.getCurrentSpan() is null at this point. Would be good if there is a null check here before you do currentSpan.getName()

Excessive logging queries

How to turn off logging or make it debug or trace? I want to retain zipkin tags for queries, though.

Adding

decorator.datasource.datasource-proxy.query.log-level=TRACE

or

decorator.datasource.datasource-proxy.query.enable-logging=false

to my app's spring application properties does not help either. Maybe I am missing some point here

How to limit what logs

I am using p6spy but I am getting so many db logs that i am not interested example

[INFO ] 2019-03-21 13:32:39.570 [DiscoveryClient-InstanceInfoReplicator-0] p6spy - #1553200359570 | took 13ms | statement | connection 27| url
SELECT 1

How to configure dynamic switch p6spy decorator

Set this parameter to enable

# Register P6LogFactory to log JDBC events
decorator.datasource.p6spy.enable-logging=true
		<dependency>
			<groupId>com.github.gavlyukovskiy</groupId>
			<artifactId>p6spy-spring-boot-starter</artifactId>
			<version>1.7.1</version>
		</dependency>

But it doesn't work if I use Apollo dynamic configuration

How to configure dynamic switch p6spy decorator?

ty

P6Spy differences on batch log output

There seems to be some inconsistency (or perhaps mis-configuration on my part) with the logging output from p6spy vs this implementation.

I have a Springboot app hooked up to postgres via hibernate. I have batching enabled with a batch size of 50. When doing bulk inserts / updates to postgres with p6spy I can clearly see logs telling me that batching is taking place:

Screenshot 2020-06-12 at 08 38 19

When using this package with no code changes (with the exception of course of updating the app.yml) I'm getting this:

Screenshot 2020-06-12 at 08 42 55

There are no batch logs at all for the same work - it could of course be doing all the batching in the background but I'm not able to confirm using this package. Am I doing something wrong?

My app.yml config is pretty straightforward:

decorator:
  datasource:
    p6spy:
      enable-logging: true
      logging: slf4j
      multiline: false

Apologies if I've just missed something from the docs (I will have another read to be sure)

"Tried to close span but it is not the current span" in transactions with several datasources

Hello.

I'm using datasource-decorator with datasource-proxy, sleuth and atomikos. I've verified that if I have two datasources in a XA transaction, the spans is not closing correctly. In logs I see the next trace:

  • 2018-05-22 10:18:15,785 [main] WARN org.springframework.cloud.sleuth.util.ExceptionUtils - [data-framework-it-jta,5b03d224214b159527c66be694e13dfa,b3ea5e53e954cf35,2ab0b3ba30ec5b72,false] - Tried to close span but it is not the current span: [Trace: 5b03d224214b159527c66be694e13dfa, Span: 2ab0b3ba30ec5b72, Parent: 27c66be694e13dfa, exportable:false]. You may have forgotten to close or detach [Trace: 5b03d224214b159527c66be694e13dfa, Span: b3ea5e53e954cf35, Parent: 2ab0b3ba30ec5b72, exportable:false].

I think that the problem is in class TracingQueryExecutionListener. I start a transaction. TracingQueryExecutionListener create a new span for first connection, and later, create a second span for the second connection, which have as parent Span the span of connnection1. After, it close connection1, but it can't close span, because the current Span is the span of connection2.

P6Spy For Multi-Tenancy

When we have a map of data sources in case of multi-tenant, every entry needs to be decorated in order to get it instumented.

How can we configure such thing ?

TracingQueryExecutionListener Order

I think it would be useful that TracingQueryExecutionListener bean had an Order with a high precedence.

I am using spring-boot-data-source-decorator 1.5.1 with datasource-proxy. I need to use my custom MethodExecutionListener. Sometimes, depending on configuration order, my custom MethodExcecutionListener may be executed before the connection span has been created.

Thanks in advance.

ClassNotFoundException: com.p6spy.engine.spy.appender.FormattedLogger after update to 1.6.3

I have an application with datasource-proxy-spring-boot-starter and jasypt for encrypt password. It's working fine with datasource-decorator 1.6.2, but after update to 1.6.3 I have next exception:

Caused by: java.lang.ClassNotFoundException: com.p6spy.engine.spy.appender.FormattedLogger
    at java.net.URLClassLoader.findClass (URLClassLoader.java:471)
    at java.lang.ClassLoader.loadClass (ClassLoader.java:588)
    at java.lang.ClassLoader.loadClass (ClassLoader.java:521)
    at java.lang.Class.forName0 (Native Method)
    at java.lang.Class.forName (Class.java:398)
    at sun.reflect.generics.factory.CoreReflectionFactory.makeNamedType (CoreReflectionFactory.java:114)
    at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature (Reifier.java:125)
    at sun.reflect.generics.tree.ClassTypeSignature.accept (ClassTypeSignature.java:49)
    at sun.reflect.generics.reflectiveObjects.LazyReflectiveObjectGenerator.reifyBounds (LazyReflectiveObjectGenerator.java:65)
    at sun.reflect.generics.reflectiveObjects.WildcardTypeImpl.getUpperBounds (WildcardTypeImpl.java:105)
    at sun.reflect.generics.reflectiveObjects.WildcardTypeImpl.hashCode (WildcardTypeImpl.java:185)
    at java.util.Arrays.hashCode (Arrays.java:4685)
    at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.hashCode (ParameterizedTypeImpl.java:202)
    at org.springframework.util.ConcurrentReferenceHashMap.getHash (ConcurrentReferenceHashMap.java:222)
    at org.springframework.util.ConcurrentReferenceHashMap.getReference (ConcurrentReferenceHashMap.java:264)
    at org.springframework.util.ConcurrentReferenceHashMap.get (ConcurrentReferenceHashMap.java:235)
    at org.springframework.core.SerializableTypeWrapper.forTypeProvider (SerializableTypeWrapper.java:119)
    at org.springframework.core.ResolvableType.forType (ResolvableType.java:1421)
    at org.springframework.core.ResolvableType.forMethodParameter (ResolvableType.java:1310)
    at org.springframework.boot.context.properties.bind.JavaBeanBinder$BeanProperty.getType (JavaBeanBinder.java:318)
    at org.springframework.boot.context.properties.bind.JavaBeanBinder.bind (JavaBeanBinder.java:90)
    at org.springframework.boot.context.properties.bind.JavaBeanBinder.bind (JavaBeanBinder.java:82)
    at org.springframework.boot.context.properties.bind.JavaBeanBinder.bind (JavaBeanBinder.java:59)
    at org.springframework.boot.context.properties.bind.Binder.lambda$bindDataObject$5 (Binder.java:452)
    at org.springframework.boot.context.properties.bind.Binder$Context.withIncreasedDepth (Binder.java:572)
    at org.springframework.boot.context.properties.bind.Binder$Context.withDataObject (Binder.java:558)
    at org.springframework.boot.context.properties.bind.Binder$Context.access$400 (Binder.java:513)
    at org.springframework.boot.context.properties.bind.Binder.bindDataObject (Binder.java:450)
    at org.springframework.boot.context.properties.bind.Binder.bindObject (Binder.java:391)
    at org.springframework.boot.context.properties.bind.Binder.bind (Binder.java:320)
    at org.springframework.boot.context.properties.bind.Binder.lambda$bindDataObject$4 (Binder.java:448)
    at org.springframework.boot.context.properties.bind.JavaBeanBinder.bind (JavaBeanBinder.java:93)
    at org.springframework.boot.context.properties.bind.JavaBeanBinder.bind (JavaBeanBinder.java:82)
    at org.springframework.boot.context.properties.bind.JavaBeanBinder.bind (JavaBeanBinder.java:59)
    at org.springframework.boot.context.properties.bind.Binder.lambda$bindDataObject$5 (Binder.java:452)
    at org.springframework.boot.context.properties.bind.Binder$Context.withIncreasedDepth (Binder.java:572)
    at org.springframework.boot.context.properties.bind.Binder$Context.withDataObject (Binder.java:558)
    at org.springframework.boot.context.properties.bind.Binder$Context.access$400 (Binder.java:513)
    at org.springframework.boot.context.properties.bind.Binder.bindDataObject (Binder.java:450)
    at org.springframework.boot.context.properties.bind.Binder.bindObject (Binder.java:391)
    at org.springframework.boot.context.properties.bind.Binder.bind (Binder.java:320)
    at org.springframework.boot.context.properties.bind.Binder.bind (Binder.java:308)
    at org.springframework.boot.context.properties.bind.Binder.bind (Binder.java:238)
    at org.springframework.boot.context.properties.bind.Binder.bind (Binder.java:225)
    at org.springframework.boot.context.properties.ConfigurationPropertiesBinder.bind (ConfigurationPropertiesBinder.java:89)
    at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.bind (ConfigurationPropertiesBindingPostProcessor.java:107)
    at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.postProcessBeforeInitialization (ConfigurationPropertiesBindingPostProcessor.java:96)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization (AbstractAutowireCapableBeanFactory.java:415)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean (AbstractAutowireCapableBeanFactory.java:1786)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean (AbstractAutowireCapableBeanFactory.java:594)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean (AbstractAutowireCapableBeanFactory.java:516)
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0 (AbstractBeanFactory.java:324)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton (DefaultSingletonBeanRegistry.java:234)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean (AbstractBeanFactory.java:322)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean (AbstractBeanFactory.java:227)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveNamedBean (DefaultListableBeanFactory.java:1175)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveBean (DefaultListableBeanFactory.java:420)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean (DefaultListableBeanFactory.java:349)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean (DefaultListableBeanFactory.java:342)
    at org.springframework.context.support.AbstractApplicationContext.getBean (AbstractApplicationContext.java:1127)
    at com.github.gavlyukovskiy.boot.jdbc.decorator.DataSourceDecoratorBeanPostProcessor.getDataSourceDecoratorProperties (DataSourceDecoratorBeanPostProcessor.java:92)
    at com.github.gavlyukovskiy.boot.jdbc.decorator.DataSourceDecoratorBeanPostProcessor.postProcessAfterInitialization (DataSourceDecoratorBeanPostProcessor.java:57)
...

I'm not sure if problem is with datasource-decorator, because application works if I disable jasypt.

I have a demo project to reproduce the issue at https://github.com/oburgosm/decorator-jasypt-demo

Step to reproduce:

mvn spring-boot:run

p6spy-spring-boot-starter:1.4.3 with SpringBoot 2.0.4 fails with ArrayStoreException

I'm trying to use p6spy-spring-boot-starter with a spring boot 2.0.4 application however it fails almost immediately after startup with an array store exception. Googling around it seems like there may be changes needed to support spring boot 2 (spring cloud had to make similiar changes). I've attached the stack trace to this issue. Let me know if I can provide more details
output.txt

NPE v1.5.7

We have an application affected for this issue: #35.

Then, we updated to v1.5.7, but now, we have another similar exception:

java.lang.NullPointerException: null
at com.github.gavlyukovskiy.cloud.sleuth.TracingListenerStrategy.addQueryRowCount(TracingListenerStrategy.java:66)
at com.github.gavlyukovskiy.cloud.sleuth.TracingQueryExecutionListener.afterQuery(TracingQueryExecutionListener.java:59)
...

Cannot get statistics for connection, query, fetch in zipkin

Hi, this is not a bug but more likely a configuration problem.

Today I configure a spring boot instance with your starter using flexy pool, by adding in pom.xml:

        <dependency>
            <groupId>com.github.gavlyukovskiy</groupId>
            <artifactId>flexy-pool-spring-boot-starter</artifactId>
            <version>1.7.0</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-zipkin</artifactId>
            <version>2.2.7.RELEASE</version>
        </dependency>
        <!--flexy-pool fin -->

I test and autowire datasource and found is instance of DecoratedDataSource and HikariDataSource, and its working, then in properties add this lines:

spring.zipkin.base-url=http://localhost:9411/
decorator.datasource.flexy-pool.acquiring-strategy.increment-pool.max-overflow-pool-size=15
decorator.datasource.flexy-pool.acquiring-strategy.increment-pool.timeout-millis=500
decorator.datasource.flexy-pool.acquiring-strategy.retry.attempts=2
decorator.datasource.flexy-pool.metrics.reporter.jmx.enabled=true
decorator.datasource.flexy-pool.metrics.reporter.jmx.auto-start=false
decorator.datasource.flexy-pool.metrics.reporter.log.millis=300000
decorator.datasource.flexy-pool.threshold.connection.acquire=50
decorator.datasource.flexy-pool.threshold.connection.lease=1000

but when cheking zipkin output just notice no data for connection, query and fetch like in your sample image, next image show you my point:

image

What is missing in my config or what I'm doing wrong?

Thanks in advance for your help.

multiline sql

Why do you output two times SQL
for example:
p6spy : #1524122276922 | took 663ms | statement | connection 4|SELECT * FROM XXX|SELECT * FROM XXX

JDBC spans not made with Spring Cloud Finchley

I noticed that spans are not reported to Zipkin for any JDBC calls when using Finchley. Looking at the autoconfiguration's conditions, it still depends on the type org.springframework.cloud.sleuth.Tracer which does not exist in Sleuth 2 anymore.

If the plan is to support only Spring Boot 2 / Spring Cloud Finchley in the 1.4.x line, it's probably best to update the Sleuth version compiled against to at least 2.0.0.RELEASE.

sleuthVersion = '1.3.1.RELEASE'

NPE in 1.5.8

Using Spring Boot 2.2.1.RELEASE, spring-cloud-starter-zipkin:Hoxton.RC1 and p6spy-spring-boot-starter 1.5.8, I get NPE whenever I run my application.

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.cloud.autoconfigure.RefreshAutoConfiguration$JpaInvokerConfiguration': Invocation of init method failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.jdbc.DataSourceInitializerInvoker': Invocation of init method failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource': Post-processing of FactoryBean's singleton object failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.github.gavlyukovskiy.boot.jdbc.decorator.p6spy.P6SpyConfiguration': Invocation of init method failed; nested exception is java.lang.ExceptionInInitializerError
	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:160) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:416) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1795) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:595) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1108) ~[spring-context-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:868) ~[spring-context-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550) ~[spring-context-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141) ~[spring-boot-2.2.1.RELEASE.jar:2.2.1.RELEASE]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747) ~[spring-boot-2.2.1.RELEASE.jar:2.2.1.RELEASE]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) ~[spring-boot-2.2.1.RELEASE.jar:2.2.1.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) ~[spring-boot-2.2.1.RELEASE.jar:2.2.1.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) ~[spring-boot-2.2.1.RELEASE.jar:2.2.1.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) ~[spring-boot-2.2.1.RELEASE.jar:2.2.1.RELEASE]
	at com.netent.cj.player.Application.main(Application.java:10) ~[classes/:na]
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.jdbc.DataSourceInitializerInvoker': Invocation of init method failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource': Post-processing of FactoryBean's singleton object failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.github.gavlyukovskiy.boot.jdbc.decorator.p6spy.P6SpyConfiguration': Invocation of init method failed; nested exception is java.lang.ExceptionInInitializerError
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1803) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:595) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.cloud.autoconfigure.RefreshAutoConfiguration$JpaInvokerConfiguration.init(RefreshAutoConfiguration.java:121) ~[spring-cloud-context-2.2.0.RC2.jar:2.2.0.RC2]
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
	at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:389) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:333) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:157) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	... 18 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource': Post-processing of FactoryBean's singleton object failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.github.gavlyukovskiy.boot.jdbc.decorator.p6spy.P6SpyConfiguration': Invocation of init method failed; nested exception is java.lang.ExceptionInInitializerError
	at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:119) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1818) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getObjectForBeanInstance(AbstractAutowireCapableBeanFactory.java:1266) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1287) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory$DependencyObjectProvider.getIfUnique(DefaultListableBeanFactory.java:1942) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.boot.autoconfigure.jdbc.DataSourceInitializerInvoker.getDataSourceInitializer(DataSourceInitializerInvoker.java:98) ~[spring-boot-autoconfigure-2.2.1.RELEASE.jar:2.2.1.RELEASE]
	at org.springframework.boot.autoconfigure.jdbc.DataSourceInitializerInvoker.afterPropertiesSet(DataSourceInitializerInvoker.java:61) ~[spring-boot-autoconfigure-2.2.1.RELEASE.jar:2.2.1.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1862) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1799) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	... 32 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.github.gavlyukovskiy.boot.jdbc.decorator.p6spy.P6SpyConfiguration': Invocation of init method failed; nested exception is java.lang.ExceptionInInitializerError
	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:160) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:416) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1795) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:595) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:400) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1338) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1177) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:557) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:617) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:605) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.getBeansOfType(AbstractApplicationContext.java:1242) ~[spring-context-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at com.github.gavlyukovskiy.boot.jdbc.decorator.DataSourceDecoratorBeanPostProcessor.postProcessAfterInitialization(DataSourceDecoratorBeanPostProcessor.java:61) ~[datasource-decorator-spring-boot-autoconfigure-1.5.8.jar:na]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:431) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.postProcessObjectFromFactoryBean(AbstractAutowireCapableBeanFactory.java:1946) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:116) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	... 43 common frames omitted
Caused by: java.lang.ExceptionInInitializerError: null
	at com.github.gavlyukovskiy.boot.jdbc.decorator.p6spy.P6SpyConfiguration.init(P6SpyConfiguration.java:112) ~[datasource-decorator-spring-boot-autoconfigure-1.5.8.jar:na]
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
	at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:389) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:333) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:157) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	... 67 common frames omitted
Caused by: java.lang.NullPointerException: null
	at com.p6spy.engine.common.ClassHasher.getHashCode(ClassHasher.java:32) ~[p6spy-3.8.2.jar:na]
	at com.p6spy.engine.common.CustomHashedHashSet.add(CustomHashedHashSet.java:96) ~[p6spy-3.8.2.jar:na]
	at com.p6spy.engine.spy.option.P6OptionsRepository.setSet(P6OptionsRepository.java:169) ~[p6spy-3.8.2.jar:na]
	at com.p6spy.engine.spy.P6SpyOptions.setModulelist(P6SpyOptions.java:386) ~[p6spy-3.8.2.jar:na]
	at com.p6spy.engine.spy.P6SpyOptions.load(P6SpyOptions.java:101) ~[p6spy-3.8.2.jar:na]
	at com.p6spy.engine.spy.P6ModuleManager.loadOptions(P6ModuleManager.java:181) ~[p6spy-3.8.2.jar:na]
	at com.p6spy.engine.spy.P6ModuleManager.registerModule(P6ModuleManager.java:153) ~[p6spy-3.8.2.jar:na]
	at com.p6spy.engine.spy.P6ModuleManager.<init>(P6ModuleManager.java:118) ~[p6spy-3.8.2.jar:na]
	at com.p6spy.engine.spy.P6ModuleManager.initMe(P6ModuleManager.java:65) ~[p6spy-3.8.2.jar:na]
	at com.p6spy.engine.spy.P6ModuleManager.<clinit>(P6ModuleManager.java:58) ~[p6spy-3.8.2.jar:na]
	... 75 common frames omitted

/configprops causes NoClassDefFoundError: ProxyDataSourceBuilder

/configprops causes NoClassDefFoundError: ProxyDataSourceBuilder when datasource-proxy is not in the classpath.
DataSourceProxyProperties has link to datasource-proxy specific classes and error is thrown when DataSourceDecoratorProperties is serializing.

Add config to toggle on/off effective sql string when using p6spy

Currently, the sql statement added in the span is always effective sql string, which has ? replaced with real values when using prepared statement, it will be good if we can introduce a flag to switch between the raw query (with placeholders) and the resolved sql query with parameter values, because some people would prefer to not including all the values (especially confidential/pii data) in the spans.

I noticed the related code is at TracingJdbcEventListener.java#L120, it should not be a big change, I would be more than happy to prepare a PR if you are happy with that.

Error with v.1.3.4

I'm trying to use v1.3.4 and I'm seeing the following error:

org.springframework.batch.item.ItemStreamException: Error while closing item reader
	at org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader.close(AbstractItemCountingItemStreamItemReader.java:136)
	at org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader$$FastClassBySpringCGLIB$$ebb633d0.invoke(<generated>)
	at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:738)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
	at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:133)
	at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:121)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
	at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:673)
	at org.springframework.batch.item.database.HibernatePagingItemReader$$EnhancerBySpringCGLIB$$771cae9e.close(<generated>)
	at org.springframework.batch.item.support.CompositeItemStream.close(CompositeItemStream.java:85)
	at org.springframework.batch.core.step.item.ChunkMonitor.close(ChunkMonitor.java:106)
	at org.springframework.batch.item.support.CompositeItemStream.close(CompositeItemStream.java:85)
	at org.springframework.batch.core.step.tasklet.TaskletStep.close(TaskletStep.java:305)
	at org.springframework.batch.core.step.AbstractStep.execute(AbstractStep.java:271)
	at org.springframework.batch.core.job.SimpleStepHandler.handleStep(SimpleStepHandler.java:148)
	at org.springframework.batch.core.job.AbstractJob.handleStep(AbstractJob.java:392)
	at org.springframework.batch.core.job.SimpleJob.doExecute(SimpleJob.java:135)
	at org.springframework.batch.core.job.AbstractJob.execute(AbstractJob.java:306)
	at org.springframework.batch.core.launch.support.SimpleJobLauncher$1.run(SimpleJobLauncher.java:135)
	at org.springframework.core.task.SimpleAsyncTaskExecutor$ConcurrencyThrottlingRunnable.run(SimpleAsyncTaskExecutor.java:271)
	at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NullPointerException: null
	at com.github.gavlyukovskiy.cloud.sleuth.TracingQueryExecutionListener.afterMethod(TracingQueryExecutionListener.java:131)
	at net.ttddyy.dsproxy.listener.CompositeMethodListener.afterMethod(CompositeMethodListener.java:25)
	at net.ttddyy.dsproxy.listener.MethodExecutionListenerUtils.invoke(MethodExecutionListenerUtils.java:53)
	at net.ttddyy.dsproxy.proxy.ConnectionProxyLogic.invoke(ConnectionProxyLogic.java:47)
	at net.ttddyy.dsproxy.proxy.jdk.ConnectionInvocationHandler.invoke(ConnectionInvocationHandler.java:25)
	at com.sun.proxy.$Proxy161.close(Unknown Source)
	at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.closeConnection(DatasourceConnectionProviderImpl.java:127)
	at org.hibernate.internal.AbstractSessionImpl$NonContextualJdbcConnectionAccess.releaseConnection(AbstractSessionImpl.java:397)
	at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.releaseConnection(LogicalConnectionManagedImpl.java:172)
	at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.close(LogicalConnectionManagedImpl.java:215)
	at org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.close(JdbcCoordinatorImpl.java:193)
	at org.hibernate.internal.SessionImpl.close(SessionImpl.java:421)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.springframework.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:216)
	at org.springframework.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:201)
	at org.springframework.batch.item.database.HibernateItemReaderHelper.close(HibernateItemReaderHelper.java:204)
	at org.springframework.batch.item.database.HibernatePagingItemReader.doClose(HibernatePagingItemReader.java:178)
	at org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader.close(AbstractItemCountingItemStreamItemReader.java:133)
	... 21 common frames omitted

adding datasource-proxy-spring-boot-starter as maven dependency is throwing error

adding below dependency is throwing error

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

The POM for com.github.gavlyukovskiy:datasource-decorator-spring-boot-autoconfigure:jar:1.2.1 is missing, no dependency information available

All requests as subspans with flyway enabled

Hello, I have a simple spring boot application, where I connect to oracle and wanted to instrument the db communication. The db database model is maintained by flyway.

The instrumentation itself seems to be working ok, but there is one issue. All requests are paired to last log record acquired during the start of the application.

If I turn of flyway, everything works ok. I tried both p6spy and datasource proxy and they both have the same issue.

The flyway is configured with autoconfiguration of spring boot. However, the same problem appears, when I run the flyway migrate funcionality manually like this

@Bean
    fun flyway(
            dataSource: DataSource
    ): Flyway {
        val flyway = Flyway()
        flyway.dataSource = dataSource
        flyway.table = "flyway_schema_history"
        flyway.setLocations("classpath:db/migration")
        flyway.migrate()
        return flyway
    }

It's not problem of flyway, because without the instrumentation of db communication, the spanning works fine even with flyway enabled.

flexy-pool-sample project is broken?

When I debug SampleController.java I see the datasource is of type HikariDataSource (not FlexyPoolDataSource), and in JConsole I see an MBean For HikariDataSource and nothing for FlexyPoolDataSource.

I noticed in the README.md,

NOTE: To use FlexyPool you must add PoolAdapter for your particular connection pool.

but this sample project doesn't seem to do so.

Guide on registering custom Metrics factory for flexy-pool

I would like to see an example/ test code where a custom metrics factory can be configured to the flexy-pool decorator. I have defined a metricsFactory() bean and still the logging is seen on console instead of a custom metrics service I use to track the data

How to decorate two datasources?

Hello.
I have 2 datasources - for ex spring.a-datasource.... and spring.b-datasource....
And I want to use flexy-pool-spring-boot-starter.
How can I create 2 decorated datasources?
Thanx.

NPE with RoutingDatasource

I have an application with a RoutingDatasource. Using datasource-decorator (datasource-proxy-spring-boot-starter), we have a NPE sometimes.

I created a simple app to reproduce the problem: https://github.com/oburgosm/routing-datasource-test

The exception is:

java.lang.NullPointerException: null
	at com.github.gavlyukovskiy.cloud.sleuth.TracingListenerStrategy.afterQuery(TracingListenerStrategy.java:83) ~[datasource-decorator-spring-boot-autoconfigure-1.5.8.jar:na]
	at com.github.gavlyukovskiy.cloud.sleuth.TracingQueryExecutionListener.afterQuery(TracingQueryExecutionListener.java:62) ~[datasource-decorator-spring-boot-autoconfigure-1.5.8.jar:na]
	at net.ttddyy.dsproxy.listener.ChainListener.afterQuery(ChainListener.java:27) ~[datasource-proxy-1.5.1.jar:na]
	at net.ttddyy.dsproxy.proxy.StatementProxyLogic.performQueryExecutionListener(StatementProxyLogic.java:395) ~[datasource-proxy-1.5.1.jar:na]
	at net.ttddyy.dsproxy.proxy.StatementProxyLogic.access$700(StatementProxyLogic.java:37) ~[datasource-proxy-1.5.1.jar:na]
	at net.ttddyy.dsproxy.proxy.StatementProxyLogic$1.execute(StatementProxyLogic.java:123) ~[datasource-proxy-1.5.1.jar:na]
	at net.ttddyy.dsproxy.listener.MethodExecutionListenerUtils.invoke(MethodExecutionListenerUtils.java:42) ~[datasource-proxy-1.5.1.jar:na]
	at net.ttddyy.dsproxy.proxy.StatementProxyLogic.invoke(StatementProxyLogic.java:120) ~[datasource-proxy-1.5.1.jar:na]
	at net.ttddyy.dsproxy.proxy.jdk.PreparedStatementInvocationHandler.invoke(PreparedStatementInvocationHandler.java:37) ~[datasource-proxy-1.5.1.jar:na]
	at com.sun.proxy.$Proxy101.executeQuery(Unknown Source) ~[na:na]
	at jdk.internal.reflect.GeneratedMethodAccessor27.invoke(Unknown Source) ~[na:na]
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
	at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
	at net.ttddyy.dsproxy.proxy.StatementProxyLogic.performQueryExecutionListener(StatementProxyLogic.java:316) ~[datasource-proxy-1.5.1.jar:na]
	at net.ttddyy.dsproxy.proxy.StatementProxyLogic.access$700(StatementProxyLogic.java:37) ~[datasource-proxy-1.5.1.jar:na]
	at net.ttddyy.dsproxy.proxy.StatementProxyLogic$1.execute(StatementProxyLogic.java:123) ~[datasource-proxy-1.5.1.jar:na]
	at net.ttddyy.dsproxy.listener.MethodExecutionListenerUtils.invoke(MethodExecutionListenerUtils.java:42) ~[datasource-proxy-1.5.1.jar:na]
	at net.ttddyy.dsproxy.proxy.StatementProxyLogic.invoke(StatementProxyLogic.java:120) ~[datasource-proxy-1.5.1.jar:na]
	at net.ttddyy.dsproxy.proxy.jdk.PreparedStatementInvocationHandler.invoke(PreparedStatementInvocationHandler.java:37) ~[datasource-proxy-1.5.1.jar:na]
	at com.sun.proxy.$Proxy101.executeQuery(Unknown Source) ~[na:na]
	at com.bracso.test.routing.RoutingTestApplicationTests.executeDummyQuery(RoutingTestApplicationTests.java:63) ~[test-classes/:na]
	at com.bracso.test.routing.RoutingTestApplicationTests.lambda$testConcurrencia$0(RoutingTestApplicationTests.java:83) ~[test-classes/:na]
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[na:na]
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) ~[na:na]
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) ~[na:na]
	at java.base/java.lang.Thread.run(Thread.java:834) ~[na:na]

unable to follow readme.

If I create repository like:
public interface ContactRepository extends CrudRepository<JpaContact, UUID>

and call save on it, only selects are logged. Selects are related to entityManager.merge, which are fired regardless of JpaContact being annotated by @SelectBeforeUpdate(false) ), inserts inserts data into DB, but are not logged.

Ok, but I don't want selects, which shouldn't be invoked anyways. So I will do:


@Repository
@Transactional
public class ContactRepository {

    @PersistenceContext
    private EntityManager entityManager;

public void persist(JpaContact contact) {
        entityManager.persist(contact);
    }
}

and then selects aren't correctly invoked, but only tx commit is logged by p6spy.

settings:

spring.jpa.database=POSTGRESQL
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=validate

#log4j.logger.org.hibernate=TRACE
#log4j.logger.org.hibernate.type=TRACE
#log4j.logger.org.hibernate.SQL=TRACE
#logging.level.org.hibernate=TRACE
#logging.level.org.hibernate.type=TRACE
#logging.level.org.hibernate.SQL=TRACE

spring.datasource.url = jdbc:postgresql://localhost:5432/postgres
spring.datasource.driver-class-name = org.postgresql.Driver
spring.datasource.username=postgres
spring.datasource.password=postgres

#---------
#hibernate.jdbc.batch_size=5
#hibernate.order_inserts=true
#hibernate.order_updates=true
#hibernate.jdbc.batch_versioned_data=true
#spring.jpa.hibernate.jdbc.batch_size=5
#spring.jpa.hibernate.order_inserts=true
#spring.jpa.hibernate.order_updates=true
#spring.jpa.hibernate.jdbc.batch_versioned_data=true
spring.jpa.properties.hibernate.jdbc.batch_size=5
spring.jpa.properties.hibernate.order_inserts=true
spring.jpa.properties.hibernate.order_updates=true
spring.jpa.properties.hibernate.jdbc.batch_versioned_data=true


#-------------
# Register RuntimeListenerSupportFactory if JdbcEventListener beans were found
decorator.datasource.p6spy.enable-runtime-listeners=true
# Register P6LogFactory to log JDBC events
decorator.datasource.p6spy.enable-logging=true
# Use com.p6spy.engine.spy.appender.MultiLineFormat instead of com.p6spy.engine.spy.appender.SingleLineFormat
decorator.datasource.p6spy.multiline=true
# Use logging for default listeners [slf4j, sysout, file]
decorator.datasource.p6spy.logging=file
# Log file to use (only with logging=file)
decorator.datasource.p6spy.log-file=/tmp/spy.log
# Custom log format, if specified com.p6spy.engine.spy.appender.CustomLineFormat will be used with this log format
#decorator.datasource.p6spy.log-format=

decorator.datasource.datasource-proxy.query.enable-logging=true
decorator.datasource.datasource-proxy.query.log-level=warn
# Logger name to log all queries, default depends on chosen logging, e.g. net.ttddyy.dsproxy.listener.logging.SLF4JQueryLoggingListener
decorator.datasource.datasource-proxy.query.logger-name=p6spy

also selects does not log into console, but only into the file, spy.properties is ignored altogether ... I'm really confused what should be configured, where and how.

Update how to use

Can you please update in readMe.md how to use this in spring-boot projects out of the box. I am eagerly looking at one such approach to use datasource-decorator

Tracing : avoid some span to be exportable

Hi.

I trace db statements with p6spy and spring cloud sleuth. It exports connection , query and fetch spans...Is it possible to only export to zipkin query statements ???

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.