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

[issue-69] Redis instrumentation #176

Closed
wants to merge 3 commits into from

Conversation

ddcprg
Copy link

@ddcprg ddcprg commented Sep 20, 2018

Fixes #69

Please feed back on this approach

Copy link
Contributor

@pavolloffay pavolloffay left a 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>
Copy link
Contributor

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

Copy link
Author

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

Copy link
Contributor

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

Copy link
Author

@ddcprg ddcprg Sep 20, 2018

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 {
Copy link
Contributor

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

Copy link
Author

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.

@ddcprg
Copy link
Author

ddcprg commented Sep 20, 2018

@pavolloffay I couldn't find an easy way to make use of java-redis-client in the Spring classes. I'll wait for @malafeev 's advice on this

@malafeev
Copy link

malafeev commented Sep 20, 2018

java-redis-client is more low level api for jedis and lettuce clients.
I don't think it can be used here because here is abstraction over any client. And that's good.

But maybe we can move this instrumentation into java-redis-client as module?
And use it here? It would be useful for spring projects without cloud.
opentracing-contrib/java-redis-client#8

@ddcprg
Copy link
Author

ddcprg commented Sep 20, 2018

Indeed these could be useful for a regular spring project. I'll refactor the code and open a PR against the other project

@ddcprg
Copy link
Author

ddcprg commented Sep 20, 2018

@malafeev
Copy link

java-redis-client version 0.0.7 with spring support is released.
It will be available in maven central during 24 hours.

@ddcprg
Copy link
Author

ddcprg commented Sep 20, 2018

thanks @malafeev

@ddcprg
Copy link
Author

ddcprg commented Oct 8, 2018

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>
Copy link
Contributor

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

Copy link
Author

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");
Copy link
Contributor

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?

Copy link
Author

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(?)

Copy link
Contributor

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");

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<dependency>
<groupId>io.opentracing.contrib</groupId>
<artifactId>opentracing-redis-spring</artifactId>
<version>${opentracing.redis.spring.version}</version>
Copy link
Contributor

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.

Copy link
Author

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

Copy link
Contributor

@pavolloffay pavolloffay left a 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>
Copy link
Contributor

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.

https://github.com/opentracing-contrib/java-spring-cloud/blob/master/instrument-starters/opentracing-spring-cloud-jdbc-starter/pom.xml#L40

Copy link
Author

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");
Copy link
Contributor

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");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ddcprg
Copy link
Author

ddcprg commented Oct 17, 2018

Sorry, I'm snowed under ATM... I'll try to take a look at this tonight

@ddcprg
Copy link
Author

ddcprg commented Oct 22, 2018

@pavolloffay with regards adding more testing under the alldeps profile, this will require setting up an embedded Redis to be able to fetch a connection. I'm not sure whether is worth doing all this in this test but let me know and I can add it

@pavolloffay pavolloffay mentioned this pull request Oct 31, 2018
pavolloffay added a commit that referenced this pull request Oct 31, 2018
* [issue-69] Redis instrumentation

* [issue-69] PR changes

* [issue-69] Fix dependecies
@pavolloffay
Copy link
Contributor

Merged in #172. Thanks @ddcprg. I wanted to rush and do release with this feature. Thanks again.

@ddcprg
Copy link
Author

ddcprg commented Oct 31, 2018

cool, thanks @pavolloffay

@ddcprg ddcprg deleted the issue-69 branch October 31, 2018 10:53
pavolloffay added a commit to pavolloffay/java-spring-cloud that referenced this pull request Jan 17, 2019
* [issue-69] Redis instrumentation

* [issue-69] PR changes

* [issue-69] Fix dependecies
pavolloffay added a commit that referenced this pull request Jan 23, 2019
* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants