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
[issue-69] Redis instrumentation #176
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you have a look at https://github.com/opentracing-contrib/java-redis-client?
@malafeev could it be consumed and used here?
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-data-redis</artifactId> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it has to be optional
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've made it optional, I'll push the change in a minute
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RedisAutoConfiguration has to be changed to kick in only when redis classes are on classpath. Please also add test to NoDepsTest.java
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, I'll have look
* | ||
* @author Daniel del Castillo | ||
*/ | ||
final class RedisCommand { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could be this names consumed from redis lib? we could also use class names
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you mean from org.springframework.data.redis.core.RedisCommand
? I couldn't find all the operations in this enum, e.g. cluster operations are not defined there. I didn't look in specific client libraries.
@pavolloffay I couldn't find an easy way to make use of |
But maybe we can move this instrumentation into |
Indeed these could be useful for a regular spring project. I'll refactor the code and open a PR against the other project |
java-redis-client version 0.0.7 with spring support is released. |
thanks @malafeev |
hi @pavolloffay any thoughts on this PR? |
|
||
<properties> | ||
<main.basedir>${project.basedir}/../..</main.basedir> | ||
<opentracing.redis.spring.version>0.0.7</opentracing.redis.spring.version> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move to root readme with name pattern used in this project
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've moved it to parent POM using the naming convention
@@ -50,6 +50,11 @@ public void testNoRxJavaHooks() throws ClassNotFoundException { | |||
this.getClass().getClassLoader().loadClass("rx.plugins.RxJavaHooks"); | |||
} | |||
|
|||
@Test(expected = ClassNotFoundException.class) | |||
public void testNoRedisJavaHooks() throws ClassNotFoundException { | |||
this.getClass().getClassLoader().loadClass("org.springframework.data.redis.core.RedisTemplate"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please also add a check on some core redis class?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure how you mean. I could only depend on some java client class but that would restrict the integrations allowed with spring-data. IMO if someone depends on spring-data-redis
is because they use Redis, that together with the autoconfig options should be sufficient to activate the aspect(?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test if redis classes are not on classpath like: this.getClass().getClassLoader().loadClass("redis.clients.jedis.Client");
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want to go furthher with tests look at https://github.com/opentracing-contrib/java-spring-cloud/blob/master/opentracing-spring-cloud-starter/pom.xml#L138 profile. This will require adding a dependency on redis spring starter and adding an integration test here https://github.com/opentracing-contrib/java-spring-cloud/tree/master/opentracing-spring-cloud-starter/src/test/java/io/opentracing/contrib/spring/cloud
<dependency> | ||
<groupId>io.opentracing.contrib</groupId> | ||
<artifactId>opentracing-redis-spring</artifactId> | ||
<version>${opentracing.redis.spring.version}</version> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably exclude all transitive dependencies. See my comment about adding a dependency test on core redis class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've made this optional
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks fine, but dependencies have to be corrected. Instrumentation jar cannot be optional
<groupId>io.opentracing.contrib</groupId> | ||
<artifactId>opentracing-redis-spring</artifactId> | ||
<version>${version.io.opentracing.contrib-opentracing-spring-redis}</version> | ||
<optional>true</optional> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not right. We want to exclude all 3rd party deps (including redis). So only instrumentation classes are included. The redis classes will be pulled when user adds a dependency on spring-boot-starter-data-redis
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, fixed
@@ -50,6 +50,11 @@ public void testNoRxJavaHooks() throws ClassNotFoundException { | |||
this.getClass().getClassLoader().loadClass("rx.plugins.RxJavaHooks"); | |||
} | |||
|
|||
@Test(expected = ClassNotFoundException.class) | |||
public void testNoRedisJavaHooks() throws ClassNotFoundException { | |||
this.getClass().getClassLoader().loadClass("org.springframework.data.redis.core.RedisTemplate"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test if redis classes are not on classpath like: this.getClass().getClassLoader().loadClass("redis.clients.jedis.Client");
@@ -50,6 +50,11 @@ public void testNoRxJavaHooks() throws ClassNotFoundException { | |||
this.getClass().getClassLoader().loadClass("rx.plugins.RxJavaHooks"); | |||
} | |||
|
|||
@Test(expected = ClassNotFoundException.class) | |||
public void testNoRedisJavaHooks() throws ClassNotFoundException { | |||
this.getClass().getClassLoader().loadClass("org.springframework.data.redis.core.RedisTemplate"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want to go furthher with tests look at https://github.com/opentracing-contrib/java-spring-cloud/blob/master/opentracing-spring-cloud-starter/pom.xml#L138 profile. This will require adding a dependency on redis spring starter and adding an integration test here https://github.com/opentracing-contrib/java-spring-cloud/tree/master/opentracing-spring-cloud-starter/src/test/java/io/opentracing/contrib/spring/cloud
Sorry, I'm snowed under ATM... I'll try to take a look at this tonight |
@pavolloffay with regards adding more testing under the |
cool, thanks @pavolloffay |
* [issue-69] Redis instrumentation * [issue-69] PR changes * [issue-69] Fix dependecies
* Make JDBC tracing configurable through properties (#177) * Make JDBC tracer configurable through Spring properties Add properties for "withActiveSpanOnly" and "ignoreStatement" so the behaviour of the JDBC tracer can be controlled through application.yaml * Formatting fixes Fix indentation and licences headers on new test classes. * Fix pom ordering * Rename package, fix tests * Add default test, document properties * Revert "Add default test, document properties" This reverts commit bdbf55a. * Add Default test * Add documentation for new properties * Revert "Add documentation for new properties" This reverts commit 5274ddb. * Revert "Add Default test" This reverts commit 1a72821. * Revert "Revert "Add documentation for new properties"" This reverts commit 47353f2. * Add identical test * Empty out test * Add empty test * Delete defaults test * Rebased #176 (#182) * [issue-69] Redis instrumentation * [issue-69] PR changes * [issue-69] Fix dependecies * Use redis 0.0.7 Signed-off-by: Pavol Loffay <ploffay@redhat.com> * Use -redis-spring-data Signed-off-by: Pavol Loffay <ploffay@redhat.com> * Assert redis command on operation name Signed-off-by: Pavol Loffay <ploffay@redhat.com>
Fixes #69
Please feed back on this approach