├── .gitignore
├── .mvn
└── wrapper
│ ├── maven-wrapper.jar
│ └── maven-wrapper.properties
├── .settings.xml
├── .travis.yml
├── LICENSE
├── README.md
├── RELEASE.md
├── header.txt
├── mvnw
├── mvnw.cmd
├── opentracing-redis-common
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── io
│ │ └── opentracing
│ │ └── contrib
│ │ └── redis
│ │ └── common
│ │ ├── Action.java
│ │ ├── RedisCommand.java
│ │ ├── RedisSpanNameProvider.java
│ │ ├── ThrowingAction.java
│ │ ├── ThrowingSupplier.java
│ │ ├── TracingConfiguration.java
│ │ └── TracingHelper.java
│ └── test
│ └── java
│ └── io
│ └── opentracing
│ └── contrib
│ └── redis
│ └── common
│ ├── RedisSpanNameProviderTest.java
│ ├── TracingConfigurationTest.java
│ └── TracingHelperTest.java
├── opentracing-redis-jedis
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ ├── io
│ │ └── opentracing
│ │ │ └── contrib
│ │ │ └── redis
│ │ │ └── jedis
│ │ │ ├── TracingJedis.java
│ │ │ ├── TracingJedisCluster.java
│ │ │ ├── TracingJedisPool.java
│ │ │ └── TracingJedisSentinelPool.java
│ │ └── redis
│ │ └── clients
│ │ └── jedis
│ │ └── TracingJedisWrapper.java
│ └── test
│ └── java
│ └── io
│ └── opentracing
│ └── contrib
│ └── redis
│ └── jedis
│ ├── TracingJedisPoolTest.java
│ ├── TracingJedisSentinelPoolTest.java
│ └── TracingJedisTest.java
├── opentracing-redis-jedis3
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ ├── io
│ │ └── opentracing
│ │ │ └── contrib
│ │ │ └── redis
│ │ │ └── jedis3
│ │ │ ├── TracingJedis.java
│ │ │ ├── TracingJedisCluster.java
│ │ │ ├── TracingJedisPool.java
│ │ │ └── TracingJedisSentinelPool.java
│ │ └── redis
│ │ └── clients
│ │ └── jedis
│ │ └── TracingJedisWrapper.java
│ └── test
│ └── java
│ └── io.opentracing.contrib.redis.jedis3
│ ├── TracingJedisPoolTest.java
│ ├── TracingJedisSentinelPoolTest.java
│ └── TracingJedisTest.java
├── opentracing-redis-lettuce-5.0
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── io
│ │ └── opentracing
│ │ └── contrib
│ │ └── redis
│ │ └── lettuce50
│ │ ├── CompletableRedisFuture.java
│ │ ├── TracingRedisAdvancedClusterAsyncCommands.java
│ │ ├── TracingRedisAdvancedClusterCommands.java
│ │ ├── TracingRedisAsyncCommands.java
│ │ ├── TracingRedisCommands.java
│ │ ├── TracingRedisPubSubAsyncCommands.java
│ │ ├── TracingRedisPubSubCommands.java
│ │ ├── TracingRedisPubSubListener.java
│ │ ├── TracingStatefulRedisClusterConnection.java
│ │ ├── TracingStatefulRedisConnection.java
│ │ └── TracingStatefulRedisPubSubConnection.java
│ └── test
│ └── java
│ └── io
│ └── opentracing
│ └── contrib
│ └── redis
│ └── lettuce50
│ └── TracingLettuce50Test.java
├── opentracing-redis-lettuce-5.1
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── io
│ │ └── opentracing
│ │ └── contrib
│ │ └── redis
│ │ └── lettuce51
│ │ ├── CompletableRedisFuture.java
│ │ ├── TracingRedisAdvancedClusterAsyncCommands.java
│ │ ├── TracingRedisAdvancedClusterCommands.java
│ │ ├── TracingRedisAsyncCommands.java
│ │ ├── TracingRedisCommands.java
│ │ ├── TracingRedisPubSubAsyncCommands.java
│ │ ├── TracingRedisPubSubCommands.java
│ │ ├── TracingRedisPubSubListener.java
│ │ ├── TracingStatefulRedisClusterConnection.java
│ │ ├── TracingStatefulRedisConnection.java
│ │ └── TracingStatefulRedisPubSubConnection.java
│ └── test
│ └── java
│ └── io
│ └── opentracing
│ └── contrib
│ └── redis
│ └── lettuce51
│ └── TracingLettuce51Test.java
├── opentracing-redis-lettuce-5.2
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── io
│ │ └── opentracing
│ │ └── contrib
│ │ └── redis
│ │ └── lettuce52
│ │ ├── CompletableRedisFuture.java
│ │ ├── TracingRedisAdvancedClusterAsyncCommands.java
│ │ ├── TracingRedisAdvancedClusterCommands.java
│ │ ├── TracingRedisAsyncCommands.java
│ │ ├── TracingRedisCommands.java
│ │ ├── TracingRedisPubSubAsyncCommands.java
│ │ ├── TracingRedisPubSubCommands.java
│ │ ├── TracingRedisPubSubListener.java
│ │ ├── TracingStatefulRedisClusterConnection.java
│ │ ├── TracingStatefulRedisConnection.java
│ │ └── TracingStatefulRedisPubSubConnection.java
│ └── test
│ └── java
│ └── io
│ └── opentracing
│ └── contrib
│ └── redis
│ └── lettuce52
│ └── TracingLettuce52Test.java
├── opentracing-redis-redisson
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── io
│ │ └── opentracing
│ │ └── contrib
│ │ └── redis
│ │ └── redisson
│ │ ├── CompletableRFuture.java
│ │ ├── TracingRAtomicDouble.java
│ │ ├── TracingRAtomicLong.java
│ │ ├── TracingRBitSet.java
│ │ ├── TracingRBlockingDeque.java
│ │ ├── TracingRBlockingQueue.java
│ │ ├── TracingRBoundedBlockingQueue.java
│ │ ├── TracingRBucket.java
│ │ ├── TracingRBuckets.java
│ │ ├── TracingRCollectionMapReduce.java
│ │ ├── TracingRCountDownLatch.java
│ │ ├── TracingRDelayedQueue.java
│ │ ├── TracingRDeque.java
│ │ ├── TracingRDoubleAdder.java
│ │ ├── TracingRExpirable.java
│ │ ├── TracingRKeys.java
│ │ ├── TracingRLexSortedSet.java
│ │ ├── TracingRList.java
│ │ ├── TracingRListMultimap.java
│ │ ├── TracingRLocalCachedMap.java
│ │ ├── TracingRLock.java
│ │ ├── TracingRLongAdder.java
│ │ ├── TracingRMap.java
│ │ ├── TracingRMapCache.java
│ │ ├── TracingRMapReduce.java
│ │ ├── TracingRMapReduceExecutor.java
│ │ ├── TracingRMultimap.java
│ │ ├── TracingRObject.java
│ │ ├── TracingRPermitExpirableSemaphore.java
│ │ ├── TracingRPriorityBlockingDeque.java
│ │ ├── TracingRPriorityBlockingQueue.java
│ │ ├── TracingRPriorityDeque.java
│ │ ├── TracingRPriorityQueue.java
│ │ ├── TracingRQueue.java
│ │ ├── TracingRReadWriteLock.java
│ │ ├── TracingRRingBuffer.java
│ │ ├── TracingRScoredSortedSet.java
│ │ ├── TracingRSemaphore.java
│ │ ├── TracingRSet.java
│ │ ├── TracingRSetCache.java
│ │ ├── TracingRSetMultimap.java
│ │ ├── TracingRSetMultimapCache.java
│ │ ├── TracingRSortedSet.java
│ │ ├── TracingRTransferQueue.java
│ │ ├── TracingRedissonClient.java
│ │ └── TracingRedissonHelper.java
│ └── test
│ └── java
│ └── io
│ └── opentracing
│ └── contrib
│ └── redis
│ └── redisson
│ └── TracingRedissonTest.java
├── opentracing-redis-spring-data
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── io
│ │ └── opentracing
│ │ └── contrib
│ │ └── redis
│ │ └── spring
│ │ └── data
│ │ └── connection
│ │ ├── TracingRedisClusterConnection.java
│ │ ├── TracingRedisConnection.java
│ │ ├── TracingRedisConnectionFactory.java
│ │ └── TracingRedisSentinelConnection.java
│ └── test
│ └── java
│ └── io
│ └── opentracing
│ └── contrib
│ └── redis
│ └── spring
│ └── data
│ ├── connection
│ ├── AssertionUtils.java
│ ├── MockConfiguration.java
│ ├── TracingRedisClusterConnectionTest.java
│ ├── TracingRedisConnectionFactoryTest.java
│ └── TracingRedisConnectionTest.java
│ └── processor
│ ├── RedisConnectionFactoryBeanPostProcessor.java
│ ├── RedisConnectionFactoryBeanPostProcessorConfiguration.java
│ └── RedisConnectionFactoryBeanPostProcessorTest.java
├── opentracing-redis-spring-data2
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── io
│ │ └── opentracing
│ │ └── contrib
│ │ └── redis
│ │ └── spring
│ │ └── data2
│ │ └── connection
│ │ ├── TracingReactiveRedisClusterConnection.java
│ │ ├── TracingReactiveRedisConnection.java
│ │ ├── TracingRedisClusterConnection.java
│ │ ├── TracingRedisConnection.java
│ │ ├── TracingRedisConnectionFactory.java
│ │ └── TracingRedisSentinelConnection.java
│ └── test
│ └── java
│ └── io
│ └── opentracing
│ └── contrib
│ └── redis
│ └── spring
│ └── data2
│ ├── connection
│ ├── AssertionUtils.java
│ ├── MockConfiguration.java
│ ├── TracingRedisClusterConnectionTest.java
│ ├── TracingRedisConnectionFactoryTest.java
│ └── TracingRedisConnectionTest.java
│ ├── it
│ ├── SpringDataRedisTestConfiguration.java
│ └── TracingSpringDataRedisTest.java
│ └── processor
│ ├── RedisConnectionFactoryBeanPostProcessor.java
│ ├── RedisConnectionFactoryBeanPostProcessorConfiguration.java
│ └── RedisConnectionFactoryBeanPostProcessorTest.java
├── pom.xml
└── travis
└── publish.sh
/.gitignore:
--------------------------------------------------------------------------------
1 | .idea/
2 | *.iml
3 | target/
4 |
5 | # VS Code
6 | .vscode/
7 |
--------------------------------------------------------------------------------
/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/opentracing-contrib/java-redis-client/9f9def3f0fa0eab5712f125ae774349a688a89dc/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.0/apache-maven-3.5.0-bin.zip
--------------------------------------------------------------------------------
/.settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
21 |
22 |
23 | sonatype
24 | ${env.SONATYPE_USER}
25 | ${env.SONATYPE_PASSWORD}
26 |
27 |
28 | bintray
29 | ${env.BINTRAY_USER}
30 | ${env.BINTRAY_KEY}
31 |
32 |
33 | jfrog-snapshots
34 | ${env.BINTRAY_USER}
35 | ${env.BINTRAY_KEY}
36 |
37 |
38 | github.com
39 | ${env.GH_USER}
40 | ${env.GH_TOKEN}
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | sudo: required
2 | dist: trusty
3 |
4 | language: java
5 | jdk:
6 | - oraclejdk8
7 |
8 | git:
9 | quiet: true
10 |
11 | cache:
12 | directories:
13 | - $HOME/.m2/repository
14 |
15 | before_install:
16 | # allocate commits to CI, not the owner of the deploy key
17 | - git config user.name "opentracingci"
18 | - git config user.email "opentracingci+opentracing@googlegroups.com"
19 |
20 | # setup https authentication credentials, used by ./mvnw release:prepare
21 | - git config credential.helper "store --file=.git/credentials"
22 | - echo "https://$GH_TOKEN:@github.com" > .git/credentials
23 |
24 | install:
25 | # Override default travis to use the maven wrapper
26 | - ./mvnw install -DskipTests=true -Dmaven.javadoc.skip=true -B -V -q
27 |
28 | script:
29 | - ./travis/publish.sh
30 |
31 | branches:
32 | except:
33 | - /^[0-9]/
34 |
35 | after_success:
36 | - mvn -q jacoco:report coveralls:report
37 |
38 | env:
39 | global:
40 | # Ex. travis encrypt BINTRAY_USER=your_github_account
41 | - secure: "dSAhes4XbRi7YTrGgILztF7QNI3hVik2buaMKYBo9gkfNg+1bPxjdGSunXti2FuAm7ic5YSNqHy6mixE7chbIFQl5f0oDDm8kbRU8kAzjucvO0B9M/hbC6MwZuO9+y3QlWbUFrIDQtDK19LOr+xSeXcvFhDuBeFjKnIu6vuvalfaNUIihDQvUe3tJo4YO0EMc9HB7S3l+Os9vMQJTNHR1tt0y9bJkMJqFivVJjnso0H/jUS8g4t0hkmxVjS9OST/OBmzULK3bJ0L7uyd8dbG/YaV0pcjxuhVNoexbdwrCND1EdT4IjvluTPP5x+SU8A5lb6tMwYgPUCeIDAKGFSzxysNguzYXNo6DNHo+zvAUvqgCVzzHs+wbA98YDRdCL4eDKt6AMjKuesrwGiRQM1fY1aPBzxbWCM2Uc4Q3K+rRFM3tgLC49FzYUOjNApnLLa5HQZuhm2wSr45I0rAM4HwVwmS91GC4ujRlnE0SIu7XvSkBWnpRZtWPAJSm9m8Hr1av4fBjKrf4ACKvkyjJPolH6MzEfIJwZbB+M6dPR0vdJ1IlVky7yqpNTCtRH1EdI/yCwTnIV/pIVsY9cJ7jk54Ht9yqrv0gNLeHQvua5lXN8zZdwez7oGCmhUx7qN5Hs/7VidFpOopsleMsWYu26RiUjXaw6kuIxj3yMKyuHX1SRk="
42 | # Ex. travis encrypt BINTRAY_KEY=xxx-https://bintray.com/profile/edit-xxx --add
43 | - secure: "VVjLpq0GzXJKDMsokAX9Ukciqv30Bs1p6HCWDqdbtL4EbeFXH4DE96Mi9Ve+LF6ccK8ddh20oAWc1taZlgwSFOf1yIB3Q0GyOWLErvpdxO0gA60UGdbHwfctXEk+zdHKUI5heVF+5kTf8/tHhOr7SKcjz+TP2VW86Mdc8CxmLrKxGIQcXZxUaQdndklb0qWD9MJanU0ihaLvAU/XLpRlbITSMkROrP5YYmN4sb/nEiut2Ae2Lv0zyrlTReBWc/ldxWCwSaz/z7N88NORR9EzTX+gzEGn+HDKlHfXDgNgVf0zaetM6rw5g92KQWMT6YxLn8TSQGR2TIGpfRpH0kTaY70h+P8vZAcTv+SkzbadU2A9YAcJuU+xki8yoL5lUZJ5Sh+0UHKPzqmiwsPTkSGYOtGf2Yq3v7jU7o3jc1cMDvjkAe/a0Ot0qhGiAxRd1FIjnvZacOWPAZ2UhTtdDkOg1AsOchRbV83Lh/gZtVLMIp0CdrKUML/RQuCwJVXu7rufE7djx28Tw562xWJXfcGQky9Jb2TpJh4jwCC2DGFWl/LOIih78wlKPMDo+V7TVxcnUlNlqfDtg9CpcEb6gyP6LTNxPgNIogjhrCWI65mGOhcOnCZgX1HNeUlm+24nst+ugE0IMJbUK23W+aXjitqOfzONWy6Gx9t9m8POxxqoXwI="
44 | # Ex. travis encrypt GH_TOKEN=XXX-https://github.com/settings/tokens-XXX --add
45 | - secure: "KUDBwlA9qzCZlW3GkcXdcrUvouxYPUu1dOg9/C9J08YnYq6SKDJJLdCWOg3iCGeWQ54GDhReCBcPEbgslHnlKBHloDkpL6cxu5jNnZZhsC3VTpGYv1w7xm135BwhY6RouCfa0zoz/2sgU3LJQGVUQo9c11sgvPC7Exq6T/FrF+sT7Djc06EwOt6WcFLI7e0TidiWwBJxfUb+rQPYdmuDhTn2jQJKuuxPBa4UkSG/KPBe51HvnsJfA4rme2VdUIZt0F8NHj6zR6jY2zSf+fV6jvCSXm9SLWwEJnjBi3oOG8vKSAoD2f/c1aX2Bv8sXcSf4HXz0WFc+UMHhsvx/SuURvyRysKosIG2sYCUa78GEI5iNfDX2zBNmW05AfZOGc/Szic2Oq/t/A0Nk3vqTZI9n0qkLfPONgCrX1g8JUq8P4xZprVz4yz/falsg1B3RW7Bpjdahqa7XvS4j9G0LRn0h9gP4f6Yl74sKVmkSaPIAEJLIsLqUT7b/DtV+VAYmjV7r6qqDiBYxF4Bbb8pz0zjj7SRGPYP9mobQvOJsXz+DKytFKf/QqoLsvDFedIPPiLXnzICkzmq4WOmDu/A+thgrokpeQ8/acB8muvtw6iqAFPLqeydyrH3Y33e0XJVIkzxPU/Pmzh6FGLpus0bp+cakFP6EGQkAwFuO8k/0kT1Ye8="
46 | # Ex. travis encrypt SONATYPE_USER=your_sonatype_account
47 | - secure: "wiVXMjXD484eKFxler1Leu63kDGDuNBfFgqlMYb0LyT7pUnwNypIRqi4/S4p7FyMsy982TMEm2Vg56MN4yrDSZ/NnY4eb7g16dOXlIqaLkytJSAtylhD+f0NCD3rp0PoiBA2YeSwlmFyqSOCdzPnqFqqHEG2kMOgLpc5Qt4sID+cujIQn14H4zikyduihT10ivdmv/2jNVD7DvoJx4KiaOEt4FKUWls//TGUz9NgEDlqTeHqQQ2Yv0rlzzm0RwyTO3U1o2Ua0bVKCetAsptAsGK1gz0xMizhOGpc0olet/AR1eN6XmPixjL8KS12nCySGnBv/1ugXhSLdmifuToMBXMjYqLRIownN99NiVMT2DPVDo3Bwes4OKD5ZFVJskJZEJwlWoNzX25YZ/hDyXoiGuAUpJyyntFeGT7QsRv2XbfCy2bxxn6S6E4wtVcTgRDAHQvEiXOq3+qJFOfiae7DbStYJSUqAawJrt8p+50Agd1+r+fyBVbJ5xvD8G0xFVyHroJgM1YJQFwPCthsIrwXxtHQMuby5EXDHI8UcQ9yvb8D/AvytB/kT/F7k7E0OLEzM0BvQ+Pl3GBJJMOq1ydsWiZ+fb+KRUZf1tTTfY/mwDeRmMPkFAHobKy0sENh+GdwcB2z29RAeNS573pl5pq06ehVoqfQfY+aqs6XrAP2kFc="
48 | # Ex. travis encrypt SONATYPE_PASSWORD=your_sonatype_password
49 | - secure: "kgaNRDKsM9uzerO7aSiuW2CNQq+0p2WDiQ5Iy5fCOl8sBOiA2em22aa0nj4/2PmGc22OvBMFeKtJy3D53oYl4cLBimGDFg+vYm1BI/TrdD2dKPpP1KqnetZWNIF7LLdezba+rnLt2R2SZ4uxxrMB+9+wOCBDCqAl0k7D1XMuKJBl3u9KPOPxcEgGXWnijoMxe8jkoRnl+hGN8GvIkb3EtrIl3GlSYwWjpTYZ9ojuLrXjlaJy4Q+098worb8gtQFRMpZDc7WLJFqy1ENNGt/9+S5P5sPpGJbfM6aVbyO8A2Yl6+iwdBumPPRMJbPmPWrbwFxSUhZqqMgBWl9Ok4AlzOHxM6rl752EU6IXCQFn+fZ+XLYLDBbB5IuYAKhT60oIUUnBpRJy7BnU71tI6Hf0aXYC1fQACZNal7he16GiehLaLrBQcLArJp/JwO7q6fuv6ovplL++cUddKhp5daZTHh8Uwi1Emi+nUISpEnhYuswWUHwyhl79bXm+fAbTOOKmNnQ+iw2t3pTqyNwQRnIJCznshQlILz9LO4siJGyX87SGzUEWnGsRU2ECQkLDKpCGCJMez8vTmZlTOUAKv12T6dVM9Eq7u/j023Mrx+EsLYgsgu4sV+R3IHpA0I4pTbFfstu7TEz55taTLSRerEYmnrAOp8zzfOnPRn8qxitLTro="
50 |
--------------------------------------------------------------------------------
/RELEASE.md:
--------------------------------------------------------------------------------
1 | # OpenTracing Release Process
2 |
3 | This repo uses semantic versions. Please keep this in mind when choosing version numbers.
4 |
5 | For the up-to-date release process, please refer the
6 | [release process from the OpenTracing Java API](https://github.com/opentracing/opentracing-java/blob/master/RELEASE.md).
--------------------------------------------------------------------------------
/header.txt:
--------------------------------------------------------------------------------
1 | Copyright ${project.inceptionYear} The OpenTracing Authors
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
4 | in compliance with the License. You may obtain a copy of the License at
5 |
6 | http://www.apache.org/licenses/LICENSE-2.0
7 |
8 | Unless required by applicable law or agreed to in writing, software distributed under the License
9 | is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
10 | or implied. See the License for the specific language governing permissions and limitations under
11 | the License.
12 |
--------------------------------------------------------------------------------
/opentracing-redis-common/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 | opentracing-redis-parent
20 | io.opentracing.contrib
21 | 0.1.17-SNAPSHOT
22 |
23 | 4.0.0
24 |
25 | opentracing-redis-common
26 |
27 |
28 |
29 | com.github.kstyrc
30 | embedded-redis
31 | test
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/opentracing-redis-common/src/main/java/io/opentracing/contrib/redis/common/Action.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017-2020 The OpenTracing Authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the License
10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | * or implied. See the License for the specific language governing permissions and limitations under
12 | * the License.
13 | */
14 | package io.opentracing.contrib.redis.common;
15 |
16 | @FunctionalInterface
17 | public interface Action {
18 |
19 | void execute();
20 | }
21 |
--------------------------------------------------------------------------------
/opentracing-redis-common/src/main/java/io/opentracing/contrib/redis/common/RedisSpanNameProvider.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017-2020 The OpenTracing Authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the License
10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | * or implied. See the License for the specific language governing permissions and limitations under
12 | * the License.
13 | */
14 |
15 | package io.opentracing.contrib.redis.common;
16 |
17 | import java.util.function.Function;
18 |
19 | public class RedisSpanNameProvider {
20 |
21 | public static Function OPERATION_NAME = (operationName) ->
22 | ((operationName == null) ? "unknown" : operationName);
23 |
24 |
25 | public static Function PREFIX_OPERATION_NAME(final String prefix) {
26 | return (operationName) ->
27 | ((prefix == null) ? "" : prefix)
28 | + ((operationName == null) ? "unknown" : operationName);
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/opentracing-redis-common/src/main/java/io/opentracing/contrib/redis/common/ThrowingAction.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017-2020 The OpenTracing Authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the License
10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | * or implied. See the License for the specific language governing permissions and limitations under
12 | * the License.
13 | */
14 | package io.opentracing.contrib.redis.common;
15 |
16 | @FunctionalInterface
17 | public interface ThrowingAction {
18 |
19 | void execute() throws T;
20 | }
21 |
--------------------------------------------------------------------------------
/opentracing-redis-common/src/main/java/io/opentracing/contrib/redis/common/ThrowingSupplier.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017-2020 The OpenTracing Authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the License
10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | * or implied. See the License for the specific language governing permissions and limitations under
12 | * the License.
13 | */
14 | package io.opentracing.contrib.redis.common;
15 |
16 | @FunctionalInterface
17 | public interface ThrowingSupplier {
18 |
19 | V get() throws T;
20 | }
21 |
--------------------------------------------------------------------------------
/opentracing-redis-common/src/main/java/io/opentracing/contrib/redis/common/TracingConfiguration.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017-2020 The OpenTracing Authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the License
10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | * or implied. See the License for the specific language governing permissions and limitations under
12 | * the License.
13 | */
14 | package io.opentracing.contrib.redis.common;
15 |
16 | import io.opentracing.Tracer;
17 | import java.util.Map;
18 | import java.util.concurrent.ConcurrentHashMap;
19 | import java.util.function.Function;
20 |
21 | public class TracingConfiguration {
22 | static final int DEFAULT_KEYS_MAX_LENGTH = 100;
23 | private final Tracer tracer;
24 | private final boolean traceWithActiveSpanOnly;
25 | private final int keysMaxLength;
26 | private final Function spanNameProvider;
27 | private final Map extensionTags;
28 |
29 | private TracingConfiguration(Tracer tracer, boolean traceWithActiveSpanOnly, int keysMaxLength,
30 | Function spanNameProvider, Map extensionTags) {
31 | this.tracer = tracer;
32 | this.traceWithActiveSpanOnly = traceWithActiveSpanOnly;
33 | this.keysMaxLength = keysMaxLength;
34 | this.spanNameProvider = spanNameProvider;
35 | this.extensionTags = extensionTags;
36 | }
37 |
38 | public Tracer getTracer() {
39 | return tracer;
40 | }
41 |
42 | public boolean isTraceWithActiveSpanOnly() {
43 | return traceWithActiveSpanOnly;
44 | }
45 |
46 | public int getKeysMaxLength() {
47 | return keysMaxLength;
48 | }
49 |
50 | public Function getSpanNameProvider() {
51 | return spanNameProvider;
52 | }
53 |
54 | public Map getExtensionTags() {
55 | return extensionTags;
56 | }
57 |
58 | public TracingConfiguration extensionTag(String key, String value) {
59 | this.extensionTags.putIfAbsent(key, value);
60 | return this;
61 | }
62 |
63 | public static class Builder {
64 | private final Tracer tracer;
65 | private boolean traceWithActiveSpanOnly;
66 | private int keysMaxLength = DEFAULT_KEYS_MAX_LENGTH;
67 | private Function spanNameProvider = RedisSpanNameProvider.OPERATION_NAME;
68 | private Map extensionTags = new ConcurrentHashMap<>();
69 |
70 | public Builder(Tracer tracer) {
71 | this.tracer = tracer;
72 | }
73 |
74 | /**
75 | * @param traceWithActiveSpanOnly if true
then create new spans only if there is an
76 | * active span
77 | */
78 | public Builder traceWithActiveSpanOnly(boolean traceWithActiveSpanOnly) {
79 | this.traceWithActiveSpanOnly = traceWithActiveSpanOnly;
80 | return this;
81 | }
82 |
83 | /**
84 | * add tag
85 | *
86 | * @param key key
87 | * @param value value
88 | * @return this
89 | */
90 | public Builder extensionTag(String key, String value) {
91 | this.extensionTags.putIfAbsent(key, value);
92 | return this;
93 | }
94 |
95 | /**
96 | * Customize the span name, default is operation name ({@link RedisSpanNameProvider#OPERATION_NAME})
97 | *
98 | * @param spanNameProvider function to customize the span name
99 | */
100 | public Builder withSpanNameProvider(Function spanNameProvider) {
101 | this.spanNameProvider = spanNameProvider;
102 | return this;
103 | }
104 |
105 | /**
106 | * Limit number of keys to add to span (default is 100)
107 | *
108 | * @param keysMaxLength max keys length to add to span
109 | */
110 | public Builder withKeysMaxLength(int keysMaxLength) {
111 | this.keysMaxLength = keysMaxLength;
112 | return this;
113 | }
114 |
115 | public TracingConfiguration build() {
116 | if (spanNameProvider == null) {
117 | spanNameProvider = RedisSpanNameProvider.OPERATION_NAME;
118 | }
119 | if (keysMaxLength <= 0) {
120 | keysMaxLength = DEFAULT_KEYS_MAX_LENGTH;
121 | }
122 | return new TracingConfiguration(tracer, traceWithActiveSpanOnly, keysMaxLength,
123 | spanNameProvider, extensionTags);
124 | }
125 | }
126 | }
127 |
--------------------------------------------------------------------------------
/opentracing-redis-common/src/test/java/io/opentracing/contrib/redis/common/RedisSpanNameProviderTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017-2020 The OpenTracing Authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the License
10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | * or implied. See the License for the specific language governing permissions and limitations under
12 | * the License.
13 | */
14 |
15 | package io.opentracing.contrib.redis.common;
16 |
17 | import static org.junit.Assert.assertEquals;
18 |
19 | import java.util.function.Function;
20 | import org.junit.Before;
21 | import org.junit.Test;
22 |
23 |
24 | public class RedisSpanNameProviderTest {
25 |
26 | private String prefix = "redis.";
27 | private String actual = "";
28 | private Function prefixSpanName;
29 |
30 | @Before
31 | public void setUp() {
32 | prefixSpanName = RedisSpanNameProvider.PREFIX_OPERATION_NAME(prefix);
33 | }
34 |
35 | @Test
36 | public void testGetPrefix() {
37 | actual = prefixSpanName.apply("get");
38 | assertEquals("redis.get", actual);
39 | }
40 |
41 | @Test
42 | public void testSetPrefix() {
43 | actual = prefixSpanName.apply("set");
44 | assertEquals("redis.set", actual);
45 | }
46 |
47 | @Test
48 | public void testPersistPrefix() {
49 | actual = prefixSpanName.apply("persist");
50 | assertEquals("redis.persist", actual);
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/opentracing-redis-common/src/test/java/io/opentracing/contrib/redis/common/TracingConfigurationTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017-2020 The OpenTracing Authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the License
10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | * or implied. See the License for the specific language governing permissions and limitations under
12 | * the License.
13 | */
14 | package io.opentracing.contrib.redis.common;
15 |
16 | import static org.junit.Assert.assertEquals;
17 | import static org.junit.Assert.assertFalse;
18 | import static org.junit.Assert.assertNull;
19 | import static org.junit.Assert.assertSame;
20 | import static org.junit.Assert.assertTrue;
21 |
22 | import io.opentracing.Tracer;
23 | import io.opentracing.mock.MockTracer;
24 | import java.util.function.Function;
25 | import org.junit.Test;
26 |
27 | public class TracingConfigurationTest {
28 |
29 | @Test
30 | public void testDefaultValues() {
31 | Tracer tracer = new MockTracer();
32 | TracingConfiguration configuration = new TracingConfiguration.Builder(tracer).build();
33 | assertFalse(configuration.isTraceWithActiveSpanOnly());
34 | assertEquals(TracingConfiguration.DEFAULT_KEYS_MAX_LENGTH, configuration.getKeysMaxLength());
35 | assertSame(tracer, configuration.getTracer());
36 | assertSame(RedisSpanNameProvider.OPERATION_NAME, configuration.getSpanNameProvider());
37 | }
38 |
39 | @Test
40 | public void test() {
41 | Tracer tracer = new MockTracer();
42 | Function spanNameProvider = RedisSpanNameProvider.PREFIX_OPERATION_NAME("test");
43 |
44 | TracingConfiguration configuration = new TracingConfiguration.Builder(tracer)
45 | .withKeysMaxLength(10)
46 | .traceWithActiveSpanOnly(true)
47 | .withSpanNameProvider(spanNameProvider)
48 | .build();
49 |
50 | assertTrue(configuration.isTraceWithActiveSpanOnly());
51 | assertEquals(10, configuration.getKeysMaxLength());
52 | assertSame(tracer, configuration.getTracer());
53 | assertSame(spanNameProvider, configuration.getSpanNameProvider());
54 | }
55 |
56 | @Test
57 | public void testWrongValues() {
58 | TracingConfiguration configuration = new TracingConfiguration.Builder(null)
59 | .withKeysMaxLength(-20) // will be reverted to TracingConfiguration.DEFAULT_KEYS_MAX_LENGTH
60 | .withSpanNameProvider(null) // will be reverted to RedisSpanNameProvider.OPERATION_NAME
61 | .build();
62 |
63 | assertFalse(configuration.isTraceWithActiveSpanOnly());
64 | assertEquals(TracingConfiguration.DEFAULT_KEYS_MAX_LENGTH, configuration.getKeysMaxLength());
65 | assertNull(configuration.getTracer());
66 | assertSame(RedisSpanNameProvider.OPERATION_NAME, configuration.getSpanNameProvider());
67 | }
68 | }
--------------------------------------------------------------------------------
/opentracing-redis-common/src/test/java/io/opentracing/contrib/redis/common/TracingHelperTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017-2020 The OpenTracing Authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the License
10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | * or implied. See the License for the specific language governing permissions and limitations under
12 | * the License.
13 | */
14 |
15 | package io.opentracing.contrib.redis.common;
16 |
17 | import static org.junit.Assert.assertEquals;
18 |
19 | import io.opentracing.Tracer;
20 | import io.opentracing.mock.MockSpan;
21 | import io.opentracing.mock.MockTracer;
22 | import java.util.function.Function;
23 | import org.junit.Before;
24 | import org.junit.Test;
25 |
26 |
27 | public class TracingHelperTest {
28 |
29 | private Tracer mockTracer = new MockTracer();
30 | private MockSpan span;
31 | private String prefix = "redis.";
32 | private Function prefixSpanName;
33 | private TracingHelper helperWithProvider;
34 | private TracingHelper helperWithoutProvider;
35 |
36 | @Before
37 | public void setUp() {
38 | prefixSpanName = RedisSpanNameProvider.PREFIX_OPERATION_NAME(prefix);
39 | helperWithProvider = new TracingHelper(
40 | new TracingConfiguration.Builder(mockTracer).withSpanNameProvider(prefixSpanName).build());
41 | helperWithoutProvider = new TracingHelper(new TracingConfiguration.Builder(mockTracer).build());
42 | }
43 |
44 | @Test
45 | public void testPrefix() {
46 | span = (MockSpan) (helperWithProvider.buildSpan("get"));
47 | assertEquals("redis.get", span.operationName());
48 | }
49 |
50 | @Test
51 | public void testDefault() {
52 | span = (MockSpan) (helperWithoutProvider.buildSpan("get"));
53 | assertEquals("get", span.operationName());
54 | }
55 |
56 | @Test
57 | public void limitKeys() {
58 | TracingHelper helper = new TracingHelper(new TracingConfiguration.Builder(mockTracer)
59 | .withKeysMaxLength(2).build());
60 | Object[] keys = {"one", "two", "three"};
61 | assertEquals(2, helper.limitKeys(keys).length);
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/opentracing-redis-jedis/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 | opentracing-redis-parent
20 | io.opentracing.contrib
21 | 0.1.17-SNAPSHOT
22 |
23 | 4.0.0
24 |
25 | opentracing-redis-jedis
26 | OpenTracing Instrumentation for Jedis
27 | OpenTracing Instrumentation for Jedis
28 |
29 |
30 |
31 |
32 | io.opentracing.contrib
33 | opentracing-redis-common
34 | ${project.version}
35 |
36 |
37 |
38 | redis.clients
39 | jedis
40 | 2.10.2
41 | provided
42 |
43 |
44 |
45 | com.github.kstyrc
46 | embedded-redis
47 | test
48 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/opentracing-redis-jedis/src/test/java/io/opentracing/contrib/redis/jedis/TracingJedisPoolTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017-2020 The OpenTracing Authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the License
10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | * or implied. See the License for the specific language governing permissions and limitations under
12 | * the License.
13 | */
14 | package io.opentracing.contrib.redis.jedis;
15 |
16 | import static org.junit.Assert.assertEquals;
17 | import static org.junit.Assert.assertTrue;
18 |
19 | import io.opentracing.contrib.redis.common.TracingConfiguration;
20 | import io.opentracing.mock.MockSpan;
21 | import io.opentracing.mock.MockTracer;
22 | import java.util.List;
23 | import org.junit.After;
24 | import org.junit.Before;
25 | import org.junit.Test;
26 | import redis.clients.jedis.Jedis;
27 | import redis.clients.jedis.JedisPool;
28 | import redis.embedded.RedisServer;
29 |
30 | public class TracingJedisPoolTest {
31 |
32 | private MockTracer mockTracer = new MockTracer();
33 |
34 | private RedisServer redisServer;
35 |
36 | @Before
37 | public void before() {
38 | mockTracer.reset();
39 |
40 | redisServer = RedisServer.builder().setting("bind 127.0.0.1").build();
41 | redisServer.start();
42 | }
43 |
44 | @After
45 | public void after() {
46 | if (redisServer != null) {
47 | redisServer.stop();
48 | }
49 | }
50 |
51 | @Test
52 | public void testPoolReturnsTracedJedis() {
53 | JedisPool pool = new TracingJedisPool(new TracingConfiguration.Builder(mockTracer).build());
54 |
55 | Jedis jedis = pool.getResource();
56 | assertEquals("OK", jedis.set("key", "value"));
57 | assertEquals("value", jedis.get("key"));
58 |
59 | jedis.close();
60 |
61 | List spans = mockTracer.finishedSpans();
62 | assertEquals(2, spans.size());
63 | }
64 |
65 | @Test
66 | public void testClosingTracedJedisClosesUnderlyingJedis() {
67 | JedisPool pool = new TracingJedisPool(new TracingConfiguration.Builder(mockTracer).build());
68 | Jedis resource = pool.getResource();
69 | assertEquals(1, pool.getNumActive());
70 |
71 | resource.close();
72 | assertEquals(0, pool.getNumActive());
73 | assertEquals(1, pool.getNumIdle());
74 |
75 | // ensure that resource is reused
76 | Jedis nextResource = pool.getResource();
77 | assertEquals(1, pool.getNumActive());
78 | assertEquals(0, pool.getNumIdle());
79 | nextResource.close();
80 | }
81 |
82 | @Test
83 | public void shouldReturnResourceToThePoolAndStayConnected() {
84 | //given
85 | TracingJedisPool pool = new TracingJedisPool(
86 | new TracingConfiguration.Builder(mockTracer).build());
87 | Jedis resource = pool.getResource();
88 | assertTrue(resource.isConnected());
89 |
90 | //when
91 | pool.returnResource(resource);
92 |
93 | //then
94 | assertTrue(resource.isConnected());
95 | }
96 |
97 | @Test
98 | public void shouldReturnResourceToThePoolOnCloseAndStayConnected() {
99 | //given
100 | JedisPool pool = new TracingJedisPool(new TracingConfiguration.Builder(mockTracer).build());
101 | Jedis resource = pool.getResource();
102 | assertTrue(resource.isConnected());
103 |
104 | //when
105 | resource.close();
106 |
107 | //then - valid resource should not be destroyed but returned to pool & stay connected for at least {@link BaseGenericObjectPool#getMinEvictableIdleTimeMillis()}
108 | assertTrue(resource.isConnected());
109 | }
110 | }
111 |
--------------------------------------------------------------------------------
/opentracing-redis-jedis/src/test/java/io/opentracing/contrib/redis/jedis/TracingJedisSentinelPoolTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017-2020 The OpenTracing Authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the License
10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | * or implied. See the License for the specific language governing permissions and limitations under
12 | * the License.
13 | */
14 | package io.opentracing.contrib.redis.jedis;
15 |
16 | import static org.junit.Assert.assertEquals;
17 |
18 | import io.opentracing.contrib.redis.common.TracingConfiguration;
19 | import io.opentracing.mock.MockSpan;
20 | import io.opentracing.mock.MockTracer;
21 | import io.opentracing.util.ThreadLocalScopeManager;
22 | import java.util.HashSet;
23 | import java.util.List;
24 | import java.util.Set;
25 | import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
26 | import org.junit.After;
27 | import org.junit.Before;
28 | import org.junit.Test;
29 | import redis.clients.jedis.Jedis;
30 | import redis.clients.jedis.JedisSentinelPool;
31 | import redis.clients.jedis.Protocol;
32 | import redis.embedded.RedisSentinel;
33 | import redis.embedded.RedisServer;
34 |
35 | public class TracingJedisSentinelPoolTest {
36 |
37 | private MockTracer mockTracer = new MockTracer(new ThreadLocalScopeManager(),
38 | MockTracer.Propagator.TEXT_MAP);
39 |
40 | private RedisServer redisServer;
41 |
42 | private RedisSentinel redisSentinel;
43 |
44 | private static final String MASTER_NAME = "mymaster";
45 |
46 | private Set sentinels = new HashSet() {{
47 | add("127.0.0.1:" + (Protocol.DEFAULT_PORT + 1));
48 | }};
49 |
50 | @Before
51 | public void before() {
52 | mockTracer.reset();
53 |
54 | redisServer = RedisServer.builder().build();
55 | redisServer.start();
56 | redisSentinel = RedisSentinel.builder().port(Protocol.DEFAULT_PORT + 1).build();
57 | redisSentinel.start();
58 | }
59 |
60 | @After
61 | public void after() {
62 | if (redisSentinel != null) {
63 | redisSentinel.stop();
64 | }
65 | if (redisServer != null) {
66 | redisServer.stop();
67 | }
68 | }
69 |
70 | @Test
71 | public void testSentinelPoolReturnsTracedJedis() {
72 | JedisSentinelPool pool = new TracingJedisSentinelPool(
73 | new TracingConfiguration.Builder(mockTracer).build(), MASTER_NAME, sentinels,
74 | new GenericObjectPoolConfig());
75 | Jedis jedis = pool.getResource();
76 | assertEquals("OK", jedis.set("key", "value"));
77 | assertEquals("value", jedis.get("key"));
78 |
79 | jedis.close();
80 | pool.destroy();
81 |
82 | List spans = mockTracer.finishedSpans();
83 | assertEquals(2, spans.size());
84 | }
85 |
86 | @Test
87 | public void testClosingTracedJedisClosesUnderlyingJedis() {
88 | JedisSentinelPool pool = new TracingJedisSentinelPool(
89 | new TracingConfiguration.Builder(mockTracer).build(), MASTER_NAME, sentinels,
90 | new GenericObjectPoolConfig());
91 | Jedis resource = pool.getResource();
92 | assertEquals(1, pool.getNumActive());
93 |
94 | resource.close();
95 | assertEquals(0, pool.getNumActive());
96 | assertEquals(1, pool.getNumIdle());
97 |
98 | // ensure that resource is reused
99 | Jedis nextResource = pool.getResource();
100 | assertEquals(1, pool.getNumActive());
101 | assertEquals(0, pool.getNumIdle());
102 | nextResource.close();
103 |
104 | pool.destroy();
105 | }
106 | }
--------------------------------------------------------------------------------
/opentracing-redis-jedis/src/test/java/io/opentracing/contrib/redis/jedis/TracingJedisTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017-2020 The OpenTracing Authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the License
10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | * or implied. See the License for the specific language governing permissions and limitations under
12 | * the License.
13 | */
14 | package io.opentracing.contrib.redis.jedis;
15 |
16 | import static org.junit.Assert.assertEquals;
17 |
18 | import io.opentracing.contrib.redis.common.TracingConfiguration;
19 | import io.opentracing.mock.MockSpan;
20 | import io.opentracing.mock.MockTracer;
21 | import io.opentracing.util.ThreadLocalScopeManager;
22 | import java.util.List;
23 | import org.junit.After;
24 | import org.junit.Before;
25 | import org.junit.Test;
26 | import redis.clients.jedis.Jedis;
27 | import redis.embedded.RedisServer;
28 |
29 | public class TracingJedisTest {
30 |
31 | private MockTracer mockTracer = new MockTracer(new ThreadLocalScopeManager(),
32 | MockTracer.Propagator.TEXT_MAP);
33 |
34 | private RedisServer redisServer;
35 |
36 | @Before
37 | public void before() throws Exception {
38 | mockTracer.reset();
39 |
40 | redisServer = RedisServer.builder().setting("bind 127.0.0.1").build();
41 | redisServer.start();
42 | }
43 |
44 | @After
45 | public void after() {
46 | if (redisServer != null) {
47 | redisServer.stop();
48 | }
49 | }
50 |
51 | @Test
52 | public void test() {
53 | Jedis jedis = new TracingJedis(new TracingConfiguration.Builder(mockTracer).build());
54 |
55 | assertEquals("OK", jedis.set("key", "value"));
56 | assertEquals("value", jedis.get("key"));
57 |
58 | jedis.close();
59 |
60 | List spans = mockTracer.finishedSpans();
61 | assertEquals(2, spans.size());
62 | }
63 |
64 | }
65 |
--------------------------------------------------------------------------------
/opentracing-redis-jedis3/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 | opentracing-redis-parent
20 | io.opentracing.contrib
21 | 0.1.17-SNAPSHOT
22 |
23 | 4.0.0
24 |
25 | opentracing-redis-jedis3
26 | OpenTracing Instrumentation for Jedis 3
27 | OpenTracing Instrumentation for Jedis 3
28 |
29 |
30 |
31 |
32 | io.opentracing.contrib
33 | opentracing-redis-common
34 | ${project.version}
35 |
36 |
37 |
38 | redis.clients
39 | jedis
40 | 3.6.1
41 | provided
42 |
43 |
44 |
45 | com.github.kstyrc
46 | embedded-redis
47 | test
48 |
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/opentracing-redis-jedis3/src/test/java/io.opentracing.contrib.redis.jedis3/TracingJedisPoolTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017-2020 The OpenTracing Authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the License
10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | * or implied. See the License for the specific language governing permissions and limitations under
12 | * the License.
13 | */
14 | package io.opentracing.contrib.redis.jedis3;
15 |
16 | import static org.junit.Assert.assertEquals;
17 | import static org.junit.Assert.assertTrue;
18 |
19 | import io.opentracing.contrib.redis.common.TracingConfiguration;
20 | import io.opentracing.mock.MockSpan;
21 | import io.opentracing.mock.MockTracer;
22 | import io.opentracing.util.ThreadLocalScopeManager;
23 | import java.util.List;
24 | import org.junit.After;
25 | import org.junit.Before;
26 | import org.junit.Test;
27 | import redis.clients.jedis.Jedis;
28 | import redis.clients.jedis.JedisPool;
29 | import redis.embedded.RedisServer;
30 |
31 | public class TracingJedisPoolTest {
32 |
33 | private MockTracer mockTracer = new MockTracer(new ThreadLocalScopeManager(),
34 | MockTracer.Propagator.TEXT_MAP);
35 |
36 | private RedisServer redisServer;
37 |
38 | @Before
39 | public void before() {
40 | mockTracer.reset();
41 |
42 | redisServer = RedisServer.builder().setting("bind 127.0.0.1").build();
43 | redisServer.start();
44 | }
45 |
46 | @After
47 | public void after() {
48 | if (redisServer != null) {
49 | redisServer.stop();
50 | }
51 | }
52 |
53 | @Test
54 | public void testPoolReturnsTracedJedis() {
55 | JedisPool pool = new TracingJedisPool(new TracingConfiguration.Builder(mockTracer).build());
56 |
57 | Jedis jedis = pool.getResource();
58 | assertEquals("OK", jedis.set("key", "value"));
59 | assertEquals("value", jedis.get("key"));
60 |
61 | jedis.close();
62 |
63 | List spans = mockTracer.finishedSpans();
64 | assertEquals(2, spans.size());
65 | }
66 |
67 | @Test
68 | public void testClosingTracedJedisClosesUnderlyingJedis() {
69 | JedisPool pool = new TracingJedisPool(new TracingConfiguration.Builder(mockTracer).build());
70 | Jedis resource = pool.getResource();
71 | assertEquals(1, pool.getNumActive());
72 |
73 | resource.close();
74 | assertEquals(0, pool.getNumActive());
75 | assertEquals(1, pool.getNumIdle());
76 |
77 | // ensure that resource is reused
78 | Jedis nextResource = pool.getResource();
79 | assertEquals(1, pool.getNumActive());
80 | assertEquals(0, pool.getNumIdle());
81 | nextResource.close();
82 | }
83 |
84 | @Test
85 | public void shouldReturnResourceToThePoolAndStayConnected() {
86 | //given
87 | TracingJedisPool pool = new TracingJedisPool(
88 | new TracingConfiguration.Builder(mockTracer).build());
89 | Jedis resource = pool.getResource();
90 | assertTrue(resource.isConnected());
91 |
92 | //when
93 | pool.returnResource(resource);
94 |
95 | //then
96 | assertTrue(resource.isConnected());
97 | }
98 |
99 | @Test
100 | public void shouldReturnResourceToThePoolOnCloseAndStayConnected() {
101 | //given
102 | JedisPool pool = new TracingJedisPool(new TracingConfiguration.Builder(mockTracer).build());
103 | Jedis resource = pool.getResource();
104 | assertTrue(resource.isConnected());
105 |
106 | //when
107 | resource.close();
108 |
109 | //then - valid resource should not be destroyed but returned to pool & stay connected for at least {@link BaseGenericObjectPool#getMinEvictableIdleTimeMillis()}
110 | assertTrue(resource.isConnected());
111 | }
112 | }
113 |
--------------------------------------------------------------------------------
/opentracing-redis-jedis3/src/test/java/io.opentracing.contrib.redis.jedis3/TracingJedisSentinelPoolTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017-2020 The OpenTracing Authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the License
10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | * or implied. See the License for the specific language governing permissions and limitations under
12 | * the License.
13 | */
14 | package io.opentracing.contrib.redis.jedis3;
15 |
16 | import static org.junit.Assert.assertEquals;
17 |
18 | import io.opentracing.contrib.redis.common.TracingConfiguration;
19 | import io.opentracing.mock.MockSpan;
20 | import io.opentracing.mock.MockTracer;
21 | import io.opentracing.util.ThreadLocalScopeManager;
22 | import java.util.HashSet;
23 | import java.util.List;
24 | import java.util.Set;
25 | import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
26 | import org.junit.After;
27 | import org.junit.Before;
28 | import org.junit.Test;
29 | import redis.clients.jedis.Jedis;
30 | import redis.clients.jedis.JedisSentinelPool;
31 | import redis.clients.jedis.Protocol;
32 | import redis.embedded.RedisSentinel;
33 | import redis.embedded.RedisServer;
34 |
35 | public class TracingJedisSentinelPoolTest {
36 |
37 | private MockTracer mockTracer = new MockTracer(new ThreadLocalScopeManager(),
38 | MockTracer.Propagator.TEXT_MAP);
39 |
40 | private RedisServer redisServer;
41 |
42 | private RedisSentinel redisSentinel;
43 |
44 | private static final String MASTER_NAME = "mymaster";
45 |
46 | private Set sentinels = new HashSet() {{
47 | add("127.0.0.1:" + (Protocol.DEFAULT_PORT + 1));
48 | }};
49 |
50 | @Before
51 | public void before() {
52 | mockTracer.reset();
53 |
54 | redisServer = RedisServer.builder().build();
55 | redisServer.start();
56 | redisSentinel = RedisSentinel.builder().port(Protocol.DEFAULT_PORT + 1).build();
57 | redisSentinel.start();
58 | }
59 |
60 | @After
61 | public void after() {
62 | if (redisSentinel != null) {
63 | redisSentinel.stop();
64 | }
65 | if (redisServer != null) {
66 | redisServer.stop();
67 | }
68 | }
69 |
70 | @Test
71 | public void testSentinelPoolReturnsTracedJedis() {
72 | JedisSentinelPool pool = new TracingJedisSentinelPool(
73 | new TracingConfiguration.Builder(mockTracer).build(), MASTER_NAME, sentinels,
74 | new GenericObjectPoolConfig());
75 | Jedis jedis = pool.getResource();
76 | assertEquals("OK", jedis.set("key", "value"));
77 | assertEquals("value", jedis.get("key"));
78 |
79 | jedis.close();
80 | pool.destroy();
81 |
82 | List spans = mockTracer.finishedSpans();
83 | assertEquals(2, spans.size());
84 | }
85 |
86 | @Test
87 | public void testClosingTracedJedisClosesUnderlyingJedis() {
88 | JedisSentinelPool pool = new TracingJedisSentinelPool(
89 | new TracingConfiguration.Builder(mockTracer).build(), MASTER_NAME, sentinels,
90 | new GenericObjectPoolConfig());
91 | Jedis resource = pool.getResource();
92 | assertEquals(1, pool.getNumActive());
93 |
94 | resource.close();
95 | assertEquals(0, pool.getNumActive());
96 | assertEquals(1, pool.getNumIdle());
97 |
98 | // ensure that resource is reused
99 | Jedis nextResource = pool.getResource();
100 | assertEquals(1, pool.getNumActive());
101 | assertEquals(0, pool.getNumIdle());
102 | nextResource.close();
103 |
104 | pool.destroy();
105 | }
106 | }
--------------------------------------------------------------------------------
/opentracing-redis-jedis3/src/test/java/io.opentracing.contrib.redis.jedis3/TracingJedisTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017-2020 The OpenTracing Authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the License
10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | * or implied. See the License for the specific language governing permissions and limitations under
12 | * the License.
13 | */
14 | package io.opentracing.contrib.redis.jedis3;
15 |
16 | import static org.junit.Assert.assertEquals;
17 |
18 | import io.opentracing.contrib.redis.common.TracingConfiguration;
19 | import io.opentracing.mock.MockSpan;
20 | import io.opentracing.mock.MockTracer;
21 | import io.opentracing.util.ThreadLocalScopeManager;
22 | import java.util.List;
23 | import org.junit.After;
24 | import org.junit.Before;
25 | import org.junit.Test;
26 | import redis.clients.jedis.Jedis;
27 | import redis.embedded.RedisServer;
28 |
29 | public class TracingJedisTest {
30 |
31 | private MockTracer mockTracer = new MockTracer(new ThreadLocalScopeManager(),
32 | MockTracer.Propagator.TEXT_MAP);
33 |
34 | private RedisServer redisServer;
35 |
36 | @Before
37 | public void before() throws Exception {
38 | mockTracer.reset();
39 |
40 | redisServer = RedisServer.builder().setting("bind 127.0.0.1").build();
41 | redisServer.start();
42 | }
43 |
44 | @After
45 | public void after() {
46 | if (redisServer != null) {
47 | redisServer.stop();
48 | }
49 | }
50 |
51 | @Test
52 | public void test() {
53 | Jedis jedis = new TracingJedis(new TracingConfiguration.Builder(mockTracer).build());
54 |
55 | assertEquals("OK", jedis.set("key", "value"));
56 | assertEquals("value", jedis.get("key"));
57 |
58 | jedis.close();
59 |
60 | List spans = mockTracer.finishedSpans();
61 | assertEquals(2, spans.size());
62 | }
63 |
64 | }
65 |
--------------------------------------------------------------------------------
/opentracing-redis-lettuce-5.0/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 | opentracing-redis-parent
20 | io.opentracing.contrib
21 | 0.1.17-SNAPSHOT
22 |
23 | 4.0.0
24 |
25 | opentracing-redis-lettuce-5.0
26 | OpenTracing Instrumentation for Lettuce 5.0 Redis Client
27 | OpenTracing Instrumentation for Lettuce 5.0 Redis Client
28 |
29 |
30 |
31 |
32 | io.opentracing.contrib
33 | opentracing-redis-common
34 | ${project.version}
35 |
36 |
37 |
38 | io.lettuce
39 | lettuce-core
40 | 5.0.5.RELEASE
41 | provided
42 |
43 |
44 |
45 | com.github.kstyrc
46 | embedded-redis
47 | test
48 |
49 |
50 |
51 | org.awaitility
52 | awaitility
53 | test
54 |
55 |
56 |
57 |
--------------------------------------------------------------------------------
/opentracing-redis-lettuce-5.0/src/main/java/io/opentracing/contrib/redis/lettuce50/CompletableRedisFuture.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017-2020 The OpenTracing Authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the License
10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | * or implied. See the License for the specific language governing permissions and limitations under
12 | * the License.
13 | */
14 | package io.opentracing.contrib.redis.lettuce50;
15 |
16 | import io.lettuce.core.RedisFuture;
17 | import java.util.concurrent.CompletableFuture;
18 | import java.util.concurrent.TimeUnit;
19 |
20 | public class CompletableRedisFuture extends CompletableFuture implements RedisFuture {
21 |
22 | private RedisFuture wrappedFuture;
23 |
24 | public CompletableRedisFuture(RedisFuture wrappedFuture) {
25 | this.wrappedFuture = wrappedFuture;
26 | }
27 |
28 | @Override
29 | public String getError() {
30 | return wrappedFuture.getError();
31 | }
32 |
33 | @Override
34 | public boolean await(long timeout, TimeUnit unit) throws InterruptedException {
35 | return wrappedFuture.await(timeout, unit);
36 | }
37 | }
--------------------------------------------------------------------------------
/opentracing-redis-lettuce-5.0/src/main/java/io/opentracing/contrib/redis/lettuce50/TracingRedisPubSubAsyncCommands.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017-2020 The OpenTracing Authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the License
10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | * or implied. See the License for the specific language governing permissions and limitations under
12 | * the License.
13 | */
14 | package io.opentracing.contrib.redis.lettuce50;
15 |
16 | import io.lettuce.core.RedisFuture;
17 | import io.lettuce.core.pubsub.StatefulRedisPubSubConnection;
18 | import io.lettuce.core.pubsub.api.async.RedisPubSubAsyncCommands;
19 | import io.opentracing.Span;
20 | import io.opentracing.contrib.redis.common.TracingConfiguration;
21 | import java.util.Arrays;
22 |
23 | public class TracingRedisPubSubAsyncCommands extends
24 | TracingRedisAsyncCommands implements RedisPubSubAsyncCommands {
25 | private final RedisPubSubAsyncCommands commands;
26 |
27 | public TracingRedisPubSubAsyncCommands(
28 | RedisPubSubAsyncCommands commands,
29 | TracingConfiguration tracingConfiguration) {
30 | super(commands, tracingConfiguration);
31 | this.commands = commands;
32 | }
33 |
34 | @Override
35 | public RedisFuture psubscribe(K... patterns) {
36 | final Span span = helper.buildSpan("psubscribe");
37 | span.setTag("patterns", Arrays.toString(patterns));
38 | return prepareRedisFuture(commands.psubscribe(patterns), span);
39 | }
40 |
41 | @Override
42 | public RedisFuture punsubscribe(K... patterns) {
43 | final Span span = helper.buildSpan("punsubscribe");
44 | span.setTag("patterns", Arrays.toString(patterns));
45 | return prepareRedisFuture(commands.punsubscribe(patterns), span);
46 | }
47 |
48 | @Override
49 | public RedisFuture subscribe(K... channels) {
50 | final Span span = helper.buildSpan("subscribe");
51 | span.setTag("channels", Arrays.toString(channels));
52 | return prepareRedisFuture(commands.subscribe(channels), span);
53 | }
54 |
55 | @Override
56 | public RedisFuture unsubscribe(K... channels) {
57 | final Span span = helper.buildSpan("unsubscribe");
58 | span.setTag("channels", Arrays.toString(channels));
59 | return prepareRedisFuture(commands.unsubscribe(channels), span);
60 | }
61 |
62 | @Override
63 | public StatefulRedisPubSubConnection getStatefulConnection() {
64 | return new TracingStatefulRedisPubSubConnection<>(commands.getStatefulConnection(),
65 | tracingConfiguration);
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/opentracing-redis-lettuce-5.0/src/main/java/io/opentracing/contrib/redis/lettuce50/TracingRedisPubSubCommands.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017-2020 The OpenTracing Authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the License
10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | * or implied. See the License for the specific language governing permissions and limitations under
12 | * the License.
13 | */
14 | package io.opentracing.contrib.redis.lettuce50;
15 |
16 | import io.lettuce.core.pubsub.StatefulRedisPubSubConnection;
17 | import io.lettuce.core.pubsub.api.sync.RedisPubSubCommands;
18 | import io.opentracing.Span;
19 | import io.opentracing.contrib.redis.common.TracingConfiguration;
20 | import java.util.Arrays;
21 |
22 | public class TracingRedisPubSubCommands extends TracingRedisCommands implements
23 | RedisPubSubCommands {
24 | private final RedisPubSubCommands commands;
25 |
26 | public TracingRedisPubSubCommands(RedisPubSubCommands commands,
27 | TracingConfiguration tracingConfiguration) {
28 | super(commands, tracingConfiguration);
29 | this.commands = commands;
30 | }
31 |
32 | @Override
33 | public void psubscribe(K... patterns) {
34 | final Span span = helper.buildSpan("psubscribe");
35 | span.setTag("patterns", Arrays.toString(patterns));
36 | helper.decorate(span, () -> commands.psubscribe(patterns));
37 | }
38 |
39 | @Override
40 | public void punsubscribe(K... patterns) {
41 | final Span span = helper.buildSpan("punsubscribe");
42 | span.setTag("patterns", Arrays.toString(patterns));
43 | helper.decorate(span, () -> commands.punsubscribe(patterns));
44 | }
45 |
46 | @Override
47 | public void subscribe(K... channels) {
48 | final Span span = helper.buildSpan("subscribe");
49 | span.setTag("channels", Arrays.toString(channels));
50 | helper.decorate(span, () -> commands.subscribe(channels));
51 | }
52 |
53 | @Override
54 | public void unsubscribe(K... channels) {
55 | final Span span = helper.buildSpan("unsubscribe");
56 | span.setTag("channels", Arrays.toString(channels));
57 | helper.decorate(span, () -> commands.unsubscribe(channels));
58 | }
59 |
60 | @Override
61 | public StatefulRedisPubSubConnection getStatefulConnection() {
62 | return new TracingStatefulRedisPubSubConnection<>(commands.getStatefulConnection(),
63 | tracingConfiguration);
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/opentracing-redis-lettuce-5.0/src/main/java/io/opentracing/contrib/redis/lettuce50/TracingRedisPubSubListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017-2020 The OpenTracing Authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the License
10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | * or implied. See the License for the specific language governing permissions and limitations under
12 | * the License.
13 | */
14 | package io.opentracing.contrib.redis.lettuce50;
15 |
16 | import static io.opentracing.contrib.redis.common.TracingHelper.nullable;
17 |
18 | import io.lettuce.core.pubsub.RedisPubSubListener;
19 | import io.opentracing.Span;
20 | import io.opentracing.contrib.redis.common.TracingConfiguration;
21 | import io.opentracing.contrib.redis.common.TracingHelper;
22 |
23 | public class TracingRedisPubSubListener implements RedisPubSubListener {
24 |
25 | private final RedisPubSubListener listener;
26 | private final TracingHelper helper;
27 |
28 | public TracingRedisPubSubListener(RedisPubSubListener listener,
29 | TracingConfiguration tracingConfiguration) {
30 | this.listener = listener;
31 | this.helper = new TracingHelper(tracingConfiguration);
32 | }
33 |
34 | @Override
35 | public void message(K channel, V message) {
36 | final Span span = helper.buildSpan("message");
37 | span.setTag("channel", nullable(channel));
38 | span.setTag("message", nullable(message));
39 | helper.decorate(span, () -> listener.message(channel, message));
40 | }
41 |
42 | @Override
43 | public void message(K pattern, K channel, V message) {
44 | final Span span = helper.buildSpan("message");
45 | span.setTag("pattern", nullable(pattern));
46 | span.setTag("channel", nullable(channel));
47 | span.setTag("message", nullable(message));
48 | helper.decorate(span, () -> listener.message(pattern, channel, message));
49 | }
50 |
51 | @Override
52 | public void subscribed(K channel, long count) {
53 | final Span span = helper.buildSpan("subscribed");
54 | span.setTag("channel", nullable(channel));
55 | span.setTag("count", count);
56 | helper.decorate(span, () -> listener.subscribed(channel, count));
57 | }
58 |
59 | @Override
60 | public void psubscribed(K pattern, long count) {
61 | final Span span = helper.buildSpan("psubscribed");
62 | span.setTag("pattern", nullable(pattern));
63 | span.setTag("count", count);
64 | helper.decorate(span, () -> listener.psubscribed(pattern, count));
65 | }
66 |
67 | @Override
68 | public void unsubscribed(K channel, long count) {
69 | final Span span = helper.buildSpan("unsubscribed");
70 | span.setTag("channel", nullable(channel));
71 | span.setTag("count", count);
72 | helper.decorate(span, () -> listener.unsubscribed(channel, count));
73 | }
74 |
75 | @Override
76 | public void punsubscribed(K pattern, long count) {
77 | final Span span = helper.buildSpan("punsubscribed");
78 | span.setTag("pattern", nullable(pattern));
79 | span.setTag("count", count);
80 | helper.decorate(span, () -> listener.punsubscribed(pattern, count));
81 | }
82 |
83 | @Override
84 | public boolean equals(Object obj) {
85 | return listener.equals(obj);
86 | }
87 |
88 | @Override
89 | public int hashCode() {
90 | return listener.hashCode();
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/opentracing-redis-lettuce-5.0/src/main/java/io/opentracing/contrib/redis/lettuce50/TracingStatefulRedisConnection.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017-2020 The OpenTracing Authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the License
10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | * or implied. See the License for the specific language governing permissions and limitations under
12 | * the License.
13 | */
14 | package io.opentracing.contrib.redis.lettuce50;
15 |
16 | import io.lettuce.core.ClientOptions;
17 | import io.lettuce.core.api.StatefulRedisConnection;
18 | import io.lettuce.core.api.async.RedisAsyncCommands;
19 | import io.lettuce.core.api.reactive.RedisReactiveCommands;
20 | import io.lettuce.core.api.sync.RedisCommands;
21 | import io.lettuce.core.protocol.RedisCommand;
22 | import io.opentracing.contrib.redis.common.TracingConfiguration;
23 | import java.time.Duration;
24 | import java.util.Collection;
25 | import java.util.concurrent.TimeUnit;
26 |
27 | public class TracingStatefulRedisConnection implements StatefulRedisConnection {
28 |
29 | private final StatefulRedisConnection connection;
30 | final TracingConfiguration tracingConfiguration;
31 |
32 | /**
33 | * @param connection redis connection
34 | * @param tracingConfiguration tracing configuration
35 | */
36 | public TracingStatefulRedisConnection(StatefulRedisConnection connection,
37 | TracingConfiguration tracingConfiguration) {
38 | this.connection = connection;
39 | this.tracingConfiguration = tracingConfiguration;
40 | }
41 |
42 | @Override
43 | public boolean isMulti() {
44 | return connection.isMulti();
45 | }
46 |
47 | @Override
48 | public RedisCommands sync() {
49 | return new TracingRedisCommands<>(connection.sync(), tracingConfiguration);
50 | }
51 |
52 | @Override
53 | public RedisAsyncCommands async() {
54 | return new TracingRedisAsyncCommands<>(connection.async(), tracingConfiguration);
55 | }
56 |
57 | @Override
58 | public RedisReactiveCommands reactive() {
59 | return connection.reactive();
60 | }
61 |
62 | @Override
63 | public void setTimeout(Duration timeout) {
64 | connection.setTimeout(timeout);
65 | }
66 |
67 | @Override
68 | @Deprecated
69 | public void setTimeout(long timeout, TimeUnit unit) {
70 | connection.setTimeout(timeout, unit);
71 | }
72 |
73 | @Override
74 | public Duration getTimeout() {
75 | return connection.getTimeout();
76 | }
77 |
78 | @Override
79 | public RedisCommand dispatch(
80 | RedisCommand command) {
81 | return connection.dispatch(command);
82 | }
83 |
84 | @Override
85 | public Collection> dispatch(
86 | Collection extends RedisCommand> redisCommands) {
87 | return connection.dispatch(redisCommands);
88 | }
89 |
90 | @Override
91 | public void close() {
92 | connection.close();
93 | }
94 |
95 | @Override
96 | public boolean isOpen() {
97 | return connection.isOpen();
98 | }
99 |
100 | @Override
101 | public ClientOptions getOptions() {
102 | return connection.getOptions();
103 | }
104 |
105 | @Override
106 | public void reset() {
107 | connection.reset();
108 | }
109 |
110 | @Override
111 | public void setAutoFlushCommands(boolean autoFlush) {
112 | connection.setAutoFlushCommands(autoFlush);
113 | }
114 |
115 | @Override
116 | public void flushCommands() {
117 | connection.flushCommands();
118 | }
119 | }
120 |
--------------------------------------------------------------------------------
/opentracing-redis-lettuce-5.0/src/main/java/io/opentracing/contrib/redis/lettuce50/TracingStatefulRedisPubSubConnection.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017-2020 The OpenTracing Authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the License
10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | * or implied. See the License for the specific language governing permissions and limitations under
12 | * the License.
13 | */
14 | package io.opentracing.contrib.redis.lettuce50;
15 |
16 | import io.lettuce.core.pubsub.RedisPubSubListener;
17 | import io.lettuce.core.pubsub.StatefulRedisPubSubConnection;
18 | import io.lettuce.core.pubsub.api.async.RedisPubSubAsyncCommands;
19 | import io.lettuce.core.pubsub.api.reactive.RedisPubSubReactiveCommands;
20 | import io.lettuce.core.pubsub.api.sync.RedisPubSubCommands;
21 | import io.opentracing.contrib.redis.common.TracingConfiguration;
22 |
23 | public class TracingStatefulRedisPubSubConnection extends
24 | TracingStatefulRedisConnection implements
25 | StatefulRedisPubSubConnection {
26 |
27 | private final StatefulRedisPubSubConnection connection;
28 |
29 | public TracingStatefulRedisPubSubConnection(
30 | StatefulRedisPubSubConnection connection,
31 | TracingConfiguration tracingConfiguration) {
32 | super(connection, tracingConfiguration);
33 | this.connection = connection;
34 | }
35 |
36 | @Override
37 | public RedisPubSubCommands sync() {
38 | return new TracingRedisPubSubCommands<>(connection.sync(), tracingConfiguration);
39 | }
40 |
41 | @Override
42 | public RedisPubSubAsyncCommands async() {
43 | return new TracingRedisPubSubAsyncCommands<>(connection.async(), tracingConfiguration);
44 | }
45 |
46 | @Override
47 | public RedisPubSubReactiveCommands reactive() {
48 | return connection.reactive();
49 | }
50 |
51 | @Override
52 | public void addListener(RedisPubSubListener listener) {
53 | connection.addListener(new TracingRedisPubSubListener<>(listener, tracingConfiguration));
54 | }
55 |
56 | @Override
57 | public void removeListener(RedisPubSubListener listener) {
58 | connection.removeListener(listener);
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/opentracing-redis-lettuce-5.1/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 | opentracing-redis-parent
20 | io.opentracing.contrib
21 | 0.1.17-SNAPSHOT
22 |
23 | 4.0.0
24 |
25 | opentracing-redis-lettuce-5.1
26 | OpenTracing Instrumentation for Lettuce 5.1 Redis Client
27 | OpenTracing Instrumentation for Lettuce 5.1 Redis Client
28 |
29 |
30 |
31 |
32 | io.opentracing.contrib
33 | opentracing-redis-common
34 | ${project.version}
35 |
36 |
37 |
38 | io.lettuce
39 | lettuce-core
40 | 5.1.8.RELEASE
41 | provided
42 |
43 |
44 |
45 | com.github.kstyrc
46 | embedded-redis
47 | test
48 |
49 |
50 |
51 | org.awaitility
52 | awaitility
53 | test
54 |
55 |
56 |
57 |
--------------------------------------------------------------------------------
/opentracing-redis-lettuce-5.1/src/main/java/io/opentracing/contrib/redis/lettuce51/CompletableRedisFuture.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017-2020 The OpenTracing Authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the License
10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | * or implied. See the License for the specific language governing permissions and limitations under
12 | * the License.
13 | */
14 | package io.opentracing.contrib.redis.lettuce51;
15 |
16 | import io.lettuce.core.RedisFuture;
17 | import java.util.concurrent.CompletableFuture;
18 | import java.util.concurrent.TimeUnit;
19 |
20 | public class CompletableRedisFuture extends CompletableFuture implements RedisFuture {
21 |
22 | private RedisFuture wrappedFuture;
23 |
24 | public CompletableRedisFuture(RedisFuture wrappedFuture) {
25 | this.wrappedFuture = wrappedFuture;
26 | }
27 |
28 | @Override
29 | public String getError() {
30 | return wrappedFuture.getError();
31 | }
32 |
33 | @Override
34 | public boolean await(long timeout, TimeUnit unit) throws InterruptedException {
35 | return wrappedFuture.await(timeout, unit);
36 | }
37 | }
--------------------------------------------------------------------------------
/opentracing-redis-lettuce-5.1/src/main/java/io/opentracing/contrib/redis/lettuce51/TracingRedisPubSubAsyncCommands.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017-2020 The OpenTracing Authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the License
10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | * or implied. See the License for the specific language governing permissions and limitations under
12 | * the License.
13 | */
14 | package io.opentracing.contrib.redis.lettuce51;
15 |
16 | import io.lettuce.core.RedisFuture;
17 | import io.lettuce.core.pubsub.StatefulRedisPubSubConnection;
18 | import io.lettuce.core.pubsub.api.async.RedisPubSubAsyncCommands;
19 | import io.opentracing.Span;
20 | import io.opentracing.contrib.redis.common.TracingConfiguration;
21 | import java.util.Arrays;
22 |
23 | public class TracingRedisPubSubAsyncCommands extends
24 | TracingRedisAsyncCommands implements RedisPubSubAsyncCommands {
25 | private final RedisPubSubAsyncCommands commands;
26 |
27 | public TracingRedisPubSubAsyncCommands(
28 | RedisPubSubAsyncCommands commands,
29 | TracingConfiguration tracingConfiguration) {
30 | super(commands, tracingConfiguration);
31 | this.commands = commands;
32 | }
33 |
34 | @Override
35 | public RedisFuture psubscribe(K... patterns) {
36 | final Span span = helper.buildSpan("psubscribe");
37 | span.setTag("patterns", Arrays.toString(patterns));
38 | return prepareRedisFuture(commands.psubscribe(patterns), span);
39 | }
40 |
41 | @Override
42 | public RedisFuture punsubscribe(K... patterns) {
43 | final Span span = helper.buildSpan("punsubscribe");
44 | span.setTag("patterns", Arrays.toString(patterns));
45 | return prepareRedisFuture(commands.punsubscribe(patterns), span);
46 | }
47 |
48 | @Override
49 | public RedisFuture subscribe(K... channels) {
50 | final Span span = helper.buildSpan("subscribe");
51 | span.setTag("channels", Arrays.toString(channels));
52 | return prepareRedisFuture(commands.subscribe(channels), span);
53 | }
54 |
55 | @Override
56 | public RedisFuture unsubscribe(K... channels) {
57 | final Span span = helper.buildSpan("unsubscribe");
58 | span.setTag("channels", Arrays.toString(channels));
59 | return prepareRedisFuture(commands.unsubscribe(channels), span);
60 | }
61 |
62 | @Override
63 | public StatefulRedisPubSubConnection getStatefulConnection() {
64 | return new TracingStatefulRedisPubSubConnection<>(commands.getStatefulConnection(),
65 | tracingConfiguration);
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/opentracing-redis-lettuce-5.1/src/main/java/io/opentracing/contrib/redis/lettuce51/TracingRedisPubSubCommands.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017-2020 The OpenTracing Authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the License
10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | * or implied. See the License for the specific language governing permissions and limitations under
12 | * the License.
13 | */
14 | package io.opentracing.contrib.redis.lettuce51;
15 |
16 | import io.lettuce.core.pubsub.StatefulRedisPubSubConnection;
17 | import io.lettuce.core.pubsub.api.sync.RedisPubSubCommands;
18 | import io.opentracing.Span;
19 | import io.opentracing.contrib.redis.common.TracingConfiguration;
20 | import java.util.Arrays;
21 |
22 | public class TracingRedisPubSubCommands extends TracingRedisCommands implements
23 | RedisPubSubCommands {
24 | private final RedisPubSubCommands commands;
25 |
26 | public TracingRedisPubSubCommands(RedisPubSubCommands commands,
27 | TracingConfiguration tracingConfiguration) {
28 | super(commands, tracingConfiguration);
29 | this.commands = commands;
30 | }
31 |
32 | @Override
33 | public void psubscribe(K... patterns) {
34 | final Span span = helper.buildSpan("psubscribe");
35 | span.setTag("patterns", Arrays.toString(patterns));
36 | helper.decorate(span, () -> commands.psubscribe(patterns));
37 | }
38 |
39 | @Override
40 | public void punsubscribe(K... patterns) {
41 | final Span span = helper.buildSpan("punsubscribe");
42 | span.setTag("patterns", Arrays.toString(patterns));
43 | helper.decorate(span, () -> commands.punsubscribe(patterns));
44 | }
45 |
46 | @Override
47 | public void subscribe(K... channels) {
48 | final Span span = helper.buildSpan("subscribe");
49 | span.setTag("channels", Arrays.toString(channels));
50 | helper.decorate(span, () -> commands.subscribe(channels));
51 | }
52 |
53 | @Override
54 | public void unsubscribe(K... channels) {
55 | final Span span = helper.buildSpan("unsubscribe");
56 | span.setTag("channels", Arrays.toString(channels));
57 | helper.decorate(span, () -> commands.unsubscribe(channels));
58 | }
59 |
60 | @Override
61 | public StatefulRedisPubSubConnection getStatefulConnection() {
62 | return new TracingStatefulRedisPubSubConnection<>(commands.getStatefulConnection(),
63 | tracingConfiguration);
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/opentracing-redis-lettuce-5.1/src/main/java/io/opentracing/contrib/redis/lettuce51/TracingRedisPubSubListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017-2020 The OpenTracing Authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the License
10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | * or implied. See the License for the specific language governing permissions and limitations under
12 | * the License.
13 | */
14 | package io.opentracing.contrib.redis.lettuce51;
15 |
16 | import static io.opentracing.contrib.redis.common.TracingHelper.nullable;
17 |
18 | import io.lettuce.core.pubsub.RedisPubSubListener;
19 | import io.opentracing.Span;
20 | import io.opentracing.contrib.redis.common.TracingConfiguration;
21 | import io.opentracing.contrib.redis.common.TracingHelper;
22 |
23 | public class TracingRedisPubSubListener implements RedisPubSubListener {
24 |
25 | private final RedisPubSubListener listener;
26 | private final TracingHelper helper;
27 |
28 | public TracingRedisPubSubListener(RedisPubSubListener listener,
29 | TracingConfiguration tracingConfiguration) {
30 | this.listener = listener;
31 | this.helper = new TracingHelper(tracingConfiguration);
32 | }
33 |
34 | @Override
35 | public void message(K channel, V message) {
36 | final Span span = helper.buildSpan("message");
37 | span.setTag("channel", nullable(channel));
38 | span.setTag("message", nullable(message));
39 | helper.decorate(span, () -> listener.message(channel, message));
40 | }
41 |
42 | @Override
43 | public void message(K pattern, K channel, V message) {
44 | final Span span = helper.buildSpan("message");
45 | span.setTag("pattern", nullable(pattern));
46 | span.setTag("channel", nullable(channel));
47 | span.setTag("message", nullable(message));
48 | helper.decorate(span, () -> listener.message(pattern, channel, message));
49 | }
50 |
51 | @Override
52 | public void subscribed(K channel, long count) {
53 | final Span span = helper.buildSpan("subscribed");
54 | span.setTag("channel", nullable(channel));
55 | span.setTag("count", count);
56 | helper.decorate(span, () -> listener.subscribed(channel, count));
57 | }
58 |
59 | @Override
60 | public void psubscribed(K pattern, long count) {
61 | final Span span = helper.buildSpan("psubscribed");
62 | span.setTag("pattern", nullable(pattern));
63 | span.setTag("count", count);
64 | helper.decorate(span, () -> listener.psubscribed(pattern, count));
65 | }
66 |
67 | @Override
68 | public void unsubscribed(K channel, long count) {
69 | final Span span = helper.buildSpan("unsubscribed");
70 | span.setTag("channel", nullable(channel));
71 | span.setTag("count", count);
72 | helper.decorate(span, () -> listener.unsubscribed(channel, count));
73 | }
74 |
75 | @Override
76 | public void punsubscribed(K pattern, long count) {
77 | final Span span = helper.buildSpan("punsubscribed");
78 | span.setTag("pattern", nullable(pattern));
79 | span.setTag("count", count);
80 | helper.decorate(span, () -> listener.punsubscribed(pattern, count));
81 | }
82 |
83 | @Override
84 | public boolean equals(Object obj) {
85 | return listener.equals(obj);
86 | }
87 |
88 | @Override
89 | public int hashCode() {
90 | return listener.hashCode();
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/opentracing-redis-lettuce-5.1/src/main/java/io/opentracing/contrib/redis/lettuce51/TracingStatefulRedisConnection.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017-2020 The OpenTracing Authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the License
10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | * or implied. See the License for the specific language governing permissions and limitations under
12 | * the License.
13 | */
14 | package io.opentracing.contrib.redis.lettuce51;
15 |
16 | import io.lettuce.core.ClientOptions;
17 | import io.lettuce.core.api.StatefulRedisConnection;
18 | import io.lettuce.core.api.async.RedisAsyncCommands;
19 | import io.lettuce.core.api.reactive.RedisReactiveCommands;
20 | import io.lettuce.core.api.sync.RedisCommands;
21 | import io.lettuce.core.protocol.RedisCommand;
22 | import io.lettuce.core.resource.ClientResources;
23 | import io.opentracing.contrib.redis.common.TracingConfiguration;
24 | import java.time.Duration;
25 | import java.util.Collection;
26 | import java.util.concurrent.CompletableFuture;
27 | import java.util.concurrent.TimeUnit;
28 |
29 | public class TracingStatefulRedisConnection implements StatefulRedisConnection {
30 |
31 | private final StatefulRedisConnection connection;
32 | final TracingConfiguration tracingConfiguration;
33 |
34 | /**
35 | * @param connection redis connection
36 | * @param tracingConfiguration tracing configuration
37 | */
38 | public TracingStatefulRedisConnection(StatefulRedisConnection connection,
39 | TracingConfiguration tracingConfiguration) {
40 | this.connection = connection;
41 | this.tracingConfiguration = tracingConfiguration;
42 | }
43 |
44 | @Override
45 | public boolean isMulti() {
46 | return connection.isMulti();
47 | }
48 |
49 | @Override
50 | public RedisCommands sync() {
51 | return new TracingRedisCommands<>(connection.sync(), tracingConfiguration);
52 | }
53 |
54 | @Override
55 | public RedisAsyncCommands async() {
56 | return new TracingRedisAsyncCommands<>(connection.async(), tracingConfiguration);
57 | }
58 |
59 | @Override
60 | public RedisReactiveCommands reactive() {
61 | return connection.reactive();
62 | }
63 |
64 | @Override
65 | public void setTimeout(Duration timeout) {
66 | connection.setTimeout(timeout);
67 | }
68 |
69 | @Override
70 | @Deprecated
71 | public void setTimeout(long timeout, TimeUnit unit) {
72 | connection.setTimeout(timeout, unit);
73 | }
74 |
75 | @Override
76 | public Duration getTimeout() {
77 | return connection.getTimeout();
78 | }
79 |
80 | @Override
81 | public RedisCommand dispatch(
82 | RedisCommand command) {
83 | return connection.dispatch(command);
84 | }
85 |
86 | @Override
87 | public Collection> dispatch(
88 | Collection extends RedisCommand> redisCommands) {
89 | return connection.dispatch(redisCommands);
90 | }
91 |
92 | @Override
93 | public void close() {
94 | connection.close();
95 | }
96 |
97 | @Override
98 | public CompletableFuture closeAsync() {
99 | return connection.closeAsync();
100 | }
101 |
102 | @Override
103 | public boolean isOpen() {
104 | return connection.isOpen();
105 | }
106 |
107 | @Override
108 | public ClientOptions getOptions() {
109 | return connection.getOptions();
110 | }
111 |
112 | @Override
113 | public ClientResources getResources() {
114 | return connection.getResources();
115 | }
116 |
117 | @Override
118 | public void reset() {
119 | connection.reset();
120 | }
121 |
122 | @Override
123 | public void setAutoFlushCommands(boolean autoFlush) {
124 | connection.setAutoFlushCommands(autoFlush);
125 | }
126 |
127 | @Override
128 | public void flushCommands() {
129 | connection.flushCommands();
130 | }
131 | }
132 |
--------------------------------------------------------------------------------
/opentracing-redis-lettuce-5.1/src/main/java/io/opentracing/contrib/redis/lettuce51/TracingStatefulRedisPubSubConnection.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017-2020 The OpenTracing Authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the License
10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | * or implied. See the License for the specific language governing permissions and limitations under
12 | * the License.
13 | */
14 | package io.opentracing.contrib.redis.lettuce51;
15 |
16 | import io.lettuce.core.pubsub.RedisPubSubListener;
17 | import io.lettuce.core.pubsub.StatefulRedisPubSubConnection;
18 | import io.lettuce.core.pubsub.api.async.RedisPubSubAsyncCommands;
19 | import io.lettuce.core.pubsub.api.reactive.RedisPubSubReactiveCommands;
20 | import io.lettuce.core.pubsub.api.sync.RedisPubSubCommands;
21 | import io.opentracing.contrib.redis.common.TracingConfiguration;
22 |
23 | public class TracingStatefulRedisPubSubConnection extends
24 | TracingStatefulRedisConnection implements
25 | StatefulRedisPubSubConnection {
26 |
27 | private final StatefulRedisPubSubConnection connection;
28 |
29 | public TracingStatefulRedisPubSubConnection(
30 | StatefulRedisPubSubConnection connection,
31 | TracingConfiguration tracingConfiguration) {
32 | super(connection, tracingConfiguration);
33 | this.connection = connection;
34 | }
35 |
36 | @Override
37 | public RedisPubSubCommands sync() {
38 | return new TracingRedisPubSubCommands<>(connection.sync(), tracingConfiguration);
39 | }
40 |
41 | @Override
42 | public RedisPubSubAsyncCommands async() {
43 | return new TracingRedisPubSubAsyncCommands<>(connection.async(), tracingConfiguration);
44 | }
45 |
46 | @Override
47 | public RedisPubSubReactiveCommands reactive() {
48 | return connection.reactive();
49 | }
50 |
51 | @Override
52 | public void addListener(RedisPubSubListener listener) {
53 | connection.addListener(new TracingRedisPubSubListener<>(listener, tracingConfiguration));
54 | }
55 |
56 | @Override
57 | public void removeListener(RedisPubSubListener listener) {
58 | connection.removeListener(listener);
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/opentracing-redis-lettuce-5.2/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 | opentracing-redis-parent
20 | io.opentracing.contrib
21 | 0.1.17-SNAPSHOT
22 |
23 | 4.0.0
24 |
25 | opentracing-redis-lettuce-5.2
26 | OpenTracing Instrumentation for Lettuce 5.2 Redis Client
27 | OpenTracing Instrumentation for Lettuce 5.2 Redis Client
28 |
29 |
30 |
31 |
32 | io.opentracing.contrib
33 | opentracing-redis-common
34 | ${project.version}
35 |
36 |
37 |
38 | io.lettuce
39 | lettuce-core
40 | 5.2.2.RELEASE
41 | provided
42 |
43 |
44 |
45 | com.github.kstyrc
46 | embedded-redis
47 | test
48 |
49 |
50 |
51 | org.awaitility
52 | awaitility
53 | test
54 |
55 |
56 |
57 |
--------------------------------------------------------------------------------
/opentracing-redis-lettuce-5.2/src/main/java/io/opentracing/contrib/redis/lettuce52/CompletableRedisFuture.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017-2020 The OpenTracing Authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the License
10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | * or implied. See the License for the specific language governing permissions and limitations under
12 | * the License.
13 | */
14 | package io.opentracing.contrib.redis.lettuce52;
15 |
16 | import io.lettuce.core.RedisFuture;
17 | import java.util.concurrent.CompletableFuture;
18 | import java.util.concurrent.TimeUnit;
19 |
20 | public class CompletableRedisFuture extends CompletableFuture implements RedisFuture {
21 |
22 | private RedisFuture wrappedFuture;
23 |
24 | public CompletableRedisFuture(RedisFuture wrappedFuture) {
25 | this.wrappedFuture = wrappedFuture;
26 | }
27 |
28 | @Override
29 | public String getError() {
30 | return wrappedFuture.getError();
31 | }
32 |
33 | @Override
34 | public boolean await(long timeout, TimeUnit unit) throws InterruptedException {
35 | return wrappedFuture.await(timeout, unit);
36 | }
37 | }
--------------------------------------------------------------------------------
/opentracing-redis-lettuce-5.2/src/main/java/io/opentracing/contrib/redis/lettuce52/TracingRedisPubSubAsyncCommands.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017-2020 The OpenTracing Authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the License
10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | * or implied. See the License for the specific language governing permissions and limitations under
12 | * the License.
13 | */
14 | package io.opentracing.contrib.redis.lettuce52;
15 |
16 | import io.lettuce.core.RedisFuture;
17 | import io.lettuce.core.pubsub.StatefulRedisPubSubConnection;
18 | import io.lettuce.core.pubsub.api.async.RedisPubSubAsyncCommands;
19 | import io.opentracing.Span;
20 | import io.opentracing.contrib.redis.common.TracingConfiguration;
21 | import java.util.Arrays;
22 |
23 | public class TracingRedisPubSubAsyncCommands extends
24 | TracingRedisAsyncCommands implements RedisPubSubAsyncCommands {
25 | private final RedisPubSubAsyncCommands commands;
26 |
27 | public TracingRedisPubSubAsyncCommands(
28 | RedisPubSubAsyncCommands commands,
29 | TracingConfiguration tracingConfiguration) {
30 | super(commands, tracingConfiguration);
31 | this.commands = commands;
32 | }
33 |
34 | @Override
35 | public RedisFuture psubscribe(K... patterns) {
36 | final Span span = helper.buildSpan("psubscribe");
37 | span.setTag("patterns", Arrays.toString(patterns));
38 | return prepareRedisFuture(commands.psubscribe(patterns), span);
39 | }
40 |
41 | @Override
42 | public RedisFuture punsubscribe(K... patterns) {
43 | final Span span = helper.buildSpan("punsubscribe");
44 | span.setTag("patterns", Arrays.toString(patterns));
45 | return prepareRedisFuture(commands.punsubscribe(patterns), span);
46 | }
47 |
48 | @Override
49 | public RedisFuture subscribe(K... channels) {
50 | final Span span = helper.buildSpan("subscribe");
51 | span.setTag("channels", Arrays.toString(channels));
52 | return prepareRedisFuture(commands.subscribe(channels), span);
53 | }
54 |
55 | @Override
56 | public RedisFuture unsubscribe(K... channels) {
57 | final Span span = helper.buildSpan("unsubscribe");
58 | span.setTag("channels", Arrays.toString(channels));
59 | return prepareRedisFuture(commands.unsubscribe(channels), span);
60 | }
61 |
62 | @Override
63 | public StatefulRedisPubSubConnection getStatefulConnection() {
64 | return new TracingStatefulRedisPubSubConnection<>(commands.getStatefulConnection(),
65 | tracingConfiguration);
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/opentracing-redis-lettuce-5.2/src/main/java/io/opentracing/contrib/redis/lettuce52/TracingRedisPubSubCommands.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017-2020 The OpenTracing Authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the License
10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | * or implied. See the License for the specific language governing permissions and limitations under
12 | * the License.
13 | */
14 | package io.opentracing.contrib.redis.lettuce52;
15 |
16 | import io.lettuce.core.pubsub.StatefulRedisPubSubConnection;
17 | import io.lettuce.core.pubsub.api.sync.RedisPubSubCommands;
18 | import io.opentracing.Span;
19 | import io.opentracing.contrib.redis.common.TracingConfiguration;
20 | import java.util.Arrays;
21 |
22 | public class TracingRedisPubSubCommands extends TracingRedisCommands implements
23 | RedisPubSubCommands {
24 | private final RedisPubSubCommands commands;
25 |
26 | public TracingRedisPubSubCommands(RedisPubSubCommands commands,
27 | TracingConfiguration tracingConfiguration) {
28 | super(commands, tracingConfiguration);
29 | this.commands = commands;
30 | }
31 |
32 | @Override
33 | public void psubscribe(K... patterns) {
34 | final Span span = helper.buildSpan("psubscribe");
35 | span.setTag("patterns", Arrays.toString(patterns));
36 | helper.decorate(span, () -> commands.psubscribe(patterns));
37 | }
38 |
39 | @Override
40 | public void punsubscribe(K... patterns) {
41 | final Span span = helper.buildSpan("punsubscribe");
42 | span.setTag("patterns", Arrays.toString(patterns));
43 | helper.decorate(span, () -> commands.punsubscribe(patterns));
44 | }
45 |
46 | @Override
47 | public void subscribe(K... channels) {
48 | final Span span = helper.buildSpan("subscribe");
49 | span.setTag("channels", Arrays.toString(channels));
50 | helper.decorate(span, () -> commands.subscribe(channels));
51 | }
52 |
53 | @Override
54 | public void unsubscribe(K... channels) {
55 | final Span span = helper.buildSpan("unsubscribe");
56 | span.setTag("channels", Arrays.toString(channels));
57 | helper.decorate(span, () -> commands.unsubscribe(channels));
58 | }
59 |
60 | @Override
61 | public StatefulRedisPubSubConnection getStatefulConnection() {
62 | return new TracingStatefulRedisPubSubConnection<>(commands.getStatefulConnection(),
63 | tracingConfiguration);
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/opentracing-redis-lettuce-5.2/src/main/java/io/opentracing/contrib/redis/lettuce52/TracingRedisPubSubListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017-2020 The OpenTracing Authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the License
10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | * or implied. See the License for the specific language governing permissions and limitations under
12 | * the License.
13 | */
14 | package io.opentracing.contrib.redis.lettuce52;
15 |
16 | import static io.opentracing.contrib.redis.common.TracingHelper.nullable;
17 |
18 | import io.lettuce.core.pubsub.RedisPubSubListener;
19 | import io.opentracing.Span;
20 | import io.opentracing.contrib.redis.common.TracingConfiguration;
21 | import io.opentracing.contrib.redis.common.TracingHelper;
22 |
23 | public class TracingRedisPubSubListener implements RedisPubSubListener {
24 |
25 | private final RedisPubSubListener listener;
26 | private final TracingHelper helper;
27 |
28 | public TracingRedisPubSubListener(RedisPubSubListener listener,
29 | TracingConfiguration tracingConfiguration) {
30 | this.listener = listener;
31 | this.helper = new TracingHelper(tracingConfiguration);
32 | }
33 |
34 | @Override
35 | public void message(K channel, V message) {
36 | final Span span = helper.buildSpan("message");
37 | span.setTag("channel", nullable(channel));
38 | span.setTag("message", nullable(message));
39 | helper.decorate(span, () -> listener.message(channel, message));
40 | }
41 |
42 | @Override
43 | public void message(K pattern, K channel, V message) {
44 | final Span span = helper.buildSpan("message");
45 | span.setTag("pattern", nullable(pattern));
46 | span.setTag("channel", nullable(channel));
47 | span.setTag("message", nullable(message));
48 | helper.decorate(span, () -> listener.message(pattern, channel, message));
49 | }
50 |
51 | @Override
52 | public void subscribed(K channel, long count) {
53 | final Span span = helper.buildSpan("subscribed");
54 | span.setTag("channel", nullable(channel));
55 | span.setTag("count", count);
56 | helper.decorate(span, () -> listener.subscribed(channel, count));
57 | }
58 |
59 | @Override
60 | public void psubscribed(K pattern, long count) {
61 | final Span span = helper.buildSpan("psubscribed");
62 | span.setTag("pattern", nullable(pattern));
63 | span.setTag("count", count);
64 | helper.decorate(span, () -> listener.psubscribed(pattern, count));
65 | }
66 |
67 | @Override
68 | public void unsubscribed(K channel, long count) {
69 | final Span span = helper.buildSpan("unsubscribed");
70 | span.setTag("channel", nullable(channel));
71 | span.setTag("count", count);
72 | helper.decorate(span, () -> listener.unsubscribed(channel, count));
73 | }
74 |
75 | @Override
76 | public void punsubscribed(K pattern, long count) {
77 | final Span span = helper.buildSpan("punsubscribed");
78 | span.setTag("pattern", nullable(pattern));
79 | span.setTag("count", count);
80 | helper.decorate(span, () -> listener.punsubscribed(pattern, count));
81 | }
82 |
83 | @Override
84 | public boolean equals(Object obj) {
85 | return listener.equals(obj);
86 | }
87 |
88 | @Override
89 | public int hashCode() {
90 | return listener.hashCode();
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/opentracing-redis-lettuce-5.2/src/main/java/io/opentracing/contrib/redis/lettuce52/TracingStatefulRedisConnection.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017-2020 The OpenTracing Authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the License
10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | * or implied. See the License for the specific language governing permissions and limitations under
12 | * the License.
13 | */
14 | package io.opentracing.contrib.redis.lettuce52;
15 |
16 | import io.lettuce.core.ClientOptions;
17 | import io.lettuce.core.api.StatefulRedisConnection;
18 | import io.lettuce.core.api.async.RedisAsyncCommands;
19 | import io.lettuce.core.api.reactive.RedisReactiveCommands;
20 | import io.lettuce.core.api.sync.RedisCommands;
21 | import io.lettuce.core.protocol.RedisCommand;
22 | import io.lettuce.core.resource.ClientResources;
23 | import io.opentracing.contrib.redis.common.TracingConfiguration;
24 | import java.time.Duration;
25 | import java.util.Collection;
26 | import java.util.concurrent.CompletableFuture;
27 | import java.util.concurrent.TimeUnit;
28 |
29 | public class TracingStatefulRedisConnection implements StatefulRedisConnection {
30 |
31 | private final StatefulRedisConnection connection;
32 | final TracingConfiguration tracingConfiguration;
33 |
34 | /**
35 | * @param connection redis connection
36 | * @param tracingConfiguration tracing configuration
37 | */
38 | public TracingStatefulRedisConnection(StatefulRedisConnection connection,
39 | TracingConfiguration tracingConfiguration) {
40 | this.connection = connection;
41 | this.tracingConfiguration = tracingConfiguration;
42 | }
43 |
44 | @Override
45 | public boolean isMulti() {
46 | return connection.isMulti();
47 | }
48 |
49 | @Override
50 | public RedisCommands sync() {
51 | return new TracingRedisCommands<>(connection.sync(), tracingConfiguration);
52 | }
53 |
54 | @Override
55 | public RedisAsyncCommands async() {
56 | return new TracingRedisAsyncCommands<>(connection.async(), tracingConfiguration);
57 | }
58 |
59 | @Override
60 | public RedisReactiveCommands reactive() {
61 | return connection.reactive();
62 | }
63 |
64 | @Override
65 | public void setTimeout(Duration timeout) {
66 | connection.setTimeout(timeout);
67 | }
68 |
69 | @Override
70 | @Deprecated
71 | public void setTimeout(long timeout, TimeUnit unit) {
72 | connection.setTimeout(timeout, unit);
73 | }
74 |
75 | @Override
76 | public Duration getTimeout() {
77 | return connection.getTimeout();
78 | }
79 |
80 | @Override
81 | public RedisCommand dispatch(
82 | RedisCommand command) {
83 | return connection.dispatch(command);
84 | }
85 |
86 | @Override
87 | public Collection> dispatch(
88 | Collection extends RedisCommand> redisCommands) {
89 | return connection.dispatch(redisCommands);
90 | }
91 |
92 | @Override
93 | public void close() {
94 | connection.close();
95 | }
96 |
97 | @Override
98 | public CompletableFuture closeAsync() {
99 | return connection.closeAsync();
100 | }
101 |
102 | @Override
103 | public boolean isOpen() {
104 | return connection.isOpen();
105 | }
106 |
107 | @Override
108 | public ClientOptions getOptions() {
109 | return connection.getOptions();
110 | }
111 |
112 | @Override
113 | public ClientResources getResources() {
114 | return connection.getResources();
115 | }
116 |
117 | @Override
118 | public void reset() {
119 | connection.reset();
120 | }
121 |
122 | @Override
123 | public void setAutoFlushCommands(boolean autoFlush) {
124 | connection.setAutoFlushCommands(autoFlush);
125 | }
126 |
127 | @Override
128 | public void flushCommands() {
129 | connection.flushCommands();
130 | }
131 | }
132 |
--------------------------------------------------------------------------------
/opentracing-redis-lettuce-5.2/src/main/java/io/opentracing/contrib/redis/lettuce52/TracingStatefulRedisPubSubConnection.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017-2020 The OpenTracing Authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the License
10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | * or implied. See the License for the specific language governing permissions and limitations under
12 | * the License.
13 | */
14 | package io.opentracing.contrib.redis.lettuce52;
15 |
16 | import io.lettuce.core.pubsub.RedisPubSubListener;
17 | import io.lettuce.core.pubsub.StatefulRedisPubSubConnection;
18 | import io.lettuce.core.pubsub.api.async.RedisPubSubAsyncCommands;
19 | import io.lettuce.core.pubsub.api.reactive.RedisPubSubReactiveCommands;
20 | import io.lettuce.core.pubsub.api.sync.RedisPubSubCommands;
21 | import io.opentracing.contrib.redis.common.TracingConfiguration;
22 |
23 | public class TracingStatefulRedisPubSubConnection extends
24 | TracingStatefulRedisConnection implements
25 | StatefulRedisPubSubConnection {
26 |
27 | private final StatefulRedisPubSubConnection connection;
28 |
29 | public TracingStatefulRedisPubSubConnection(
30 | StatefulRedisPubSubConnection connection,
31 | TracingConfiguration tracingConfiguration) {
32 | super(connection, tracingConfiguration);
33 | this.connection = connection;
34 | }
35 |
36 | @Override
37 | public RedisPubSubCommands sync() {
38 | return new TracingRedisPubSubCommands<>(connection.sync(), tracingConfiguration);
39 | }
40 |
41 | @Override
42 | public RedisPubSubAsyncCommands async() {
43 | return new TracingRedisPubSubAsyncCommands<>(connection.async(), tracingConfiguration);
44 | }
45 |
46 | @Override
47 | public RedisPubSubReactiveCommands reactive() {
48 | return connection.reactive();
49 | }
50 |
51 | @Override
52 | public void addListener(RedisPubSubListener listener) {
53 | connection.addListener(new TracingRedisPubSubListener<>(listener, tracingConfiguration));
54 | }
55 |
56 | @Override
57 | public void removeListener(RedisPubSubListener listener) {
58 | connection.removeListener(listener);
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/opentracing-redis-redisson/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 | opentracing-redis-parent
20 | io.opentracing.contrib
21 | 0.1.17-SNAPSHOT
22 |
23 | 4.0.0
24 |
25 | opentracing-redis-redisson
26 | OpenTracing Instrumentation for Redisson
27 | OpenTracing Instrumentation for Redisson
28 |
29 |
30 |
31 |
32 | io.opentracing.contrib
33 | opentracing-redis-common
34 | ${project.version}
35 |
36 |
37 |
38 | org.redisson
39 | redisson
40 | 3.12.2
41 | provided
42 |
43 |
44 |
45 | com.github.kstyrc
46 | embedded-redis
47 | test
48 |
49 |
50 |
51 | org.awaitility
52 | awaitility
53 | test
54 |
55 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/opentracing-redis-redisson/src/main/java/io/opentracing/contrib/redis/redisson/CompletableRFuture.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017-2020 The OpenTracing Authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the License
10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | * or implied. See the License for the specific language governing permissions and limitations under
12 | * the License.
13 | */
14 | package io.opentracing.contrib.redis.redisson;
15 |
16 | import java.util.concurrent.CompletableFuture;
17 | import java.util.concurrent.TimeUnit;
18 | import java.util.function.BiConsumer;
19 | import org.redisson.api.RFuture;
20 |
21 | public class CompletableRFuture extends CompletableFuture implements RFuture {
22 | private RFuture wrappedFuture;
23 |
24 | public CompletableRFuture(RFuture wrappedFuture) {
25 | this.wrappedFuture = wrappedFuture;
26 | }
27 |
28 | @Override
29 | public boolean isSuccess() {
30 | return wrappedFuture.isSuccess();
31 | }
32 |
33 | @Override
34 | public Throwable cause() {
35 | return wrappedFuture.cause();
36 | }
37 |
38 | @Override
39 | public T getNow() {
40 | return wrappedFuture.getNow();
41 | }
42 |
43 | @Override
44 | public boolean await(long timeout, TimeUnit unit) throws InterruptedException {
45 | return wrappedFuture.await(timeout, unit);
46 | }
47 |
48 | @Override
49 | public boolean await(long timeoutMillis) throws InterruptedException {
50 | return wrappedFuture.await(timeoutMillis);
51 | }
52 |
53 | @Override
54 | public RFuture sync() throws InterruptedException {
55 | return wrappedFuture.sync();
56 | }
57 |
58 | @Override
59 | public RFuture syncUninterruptibly() {
60 | return wrappedFuture.syncUninterruptibly();
61 | }
62 |
63 | @Override
64 | public RFuture await() throws InterruptedException {
65 | return wrappedFuture.await();
66 | }
67 |
68 | @Override
69 | public RFuture awaitUninterruptibly() {
70 | return wrappedFuture.awaitUninterruptibly();
71 | }
72 |
73 | @Override
74 | public boolean awaitUninterruptibly(long timeout, TimeUnit unit) {
75 | return wrappedFuture.awaitUninterruptibly(timeout, unit);
76 | }
77 |
78 | @Override
79 | public boolean awaitUninterruptibly(long timeoutMillis) {
80 | return wrappedFuture.awaitUninterruptibly(timeoutMillis);
81 | }
82 |
83 | @Override
84 | public void onComplete(BiConsumer super T, ? super Throwable> biConsumer) {
85 | wrappedFuture.onComplete(biConsumer);
86 | }
87 | }
--------------------------------------------------------------------------------
/opentracing-redis-redisson/src/main/java/io/opentracing/contrib/redis/redisson/TracingRBoundedBlockingQueue.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017-2020 The OpenTracing Authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the License
10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | * or implied. See the License for the specific language governing permissions and limitations under
12 | * the License.
13 | */
14 | package io.opentracing.contrib.redis.redisson;
15 |
16 |
17 | import static io.opentracing.contrib.redis.common.TracingHelper.nullable;
18 |
19 | import io.opentracing.Span;
20 | import java.util.concurrent.TimeUnit;
21 | import org.redisson.api.RBoundedBlockingQueue;
22 | import org.redisson.api.RFuture;
23 |
24 | public class TracingRBoundedBlockingQueue extends TracingRBlockingQueue implements
25 | RBoundedBlockingQueue {
26 | private final RBoundedBlockingQueue queue;
27 | private final TracingRedissonHelper tracingRedissonHelper;
28 |
29 | public TracingRBoundedBlockingQueue(RBoundedBlockingQueue queue,
30 | TracingRedissonHelper tracingRedissonHelper) {
31 | super(queue, tracingRedissonHelper);
32 | this.queue = queue;
33 | this.tracingRedissonHelper = tracingRedissonHelper;
34 | }
35 |
36 | @Override
37 | public boolean trySetCapacity(int capacity) {
38 | Span span = tracingRedissonHelper.buildSpan("trySetCapacity", queue);
39 | span.setTag("capacity", capacity);
40 | return tracingRedissonHelper.decorate(span, () -> queue.trySetCapacity(capacity));
41 | }
42 |
43 | @Override
44 | public RFuture trySetCapacityAsync(int capacity) {
45 | Span span = tracingRedissonHelper.buildSpan("trySetCapacityAsync", queue);
46 | span.setTag("capacity", capacity);
47 | return tracingRedissonHelper.prepareRFuture(span, () -> queue.trySetCapacityAsync(capacity));
48 | }
49 |
50 | @Override
51 | public RFuture offerAsync(V e, long timeout, TimeUnit unit) {
52 | Span span = tracingRedissonHelper.buildSpan("offerAsync", queue);
53 | span.setTag("element", nullable(e));
54 | span.setTag("timeout", timeout);
55 | span.setTag("unit", nullable(unit));
56 | return tracingRedissonHelper.prepareRFuture(span, () -> queue.offerAsync(e, timeout, unit));
57 | }
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/opentracing-redis-redisson/src/main/java/io/opentracing/contrib/redis/redisson/TracingRBuckets.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017-2020 The OpenTracing Authors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the License
10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | * or implied. See the License for the specific language governing permissions and limitations under
12 | * the License.
13 | */
14 | package io.opentracing.contrib.redis.redisson;
15 |
16 | import static io.opentracing.contrib.redis.common.TracingHelper.nullable;
17 |
18 | import io.opentracing.Span;
19 | import java.util.Arrays;
20 | import java.util.Map;
21 | import org.redisson.api.RBuckets;
22 | import org.redisson.api.RFuture;
23 |
24 | public class TracingRBuckets implements RBuckets {
25 | private final RBuckets buckets;
26 | private final TracingRedissonHelper tracingRedissonHelper;
27 |
28 | public TracingRBuckets(RBuckets buckets,
29 | TracingRedissonHelper tracingRedissonHelper) {
30 | this.buckets = buckets;
31 | this.tracingRedissonHelper = tracingRedissonHelper;
32 | }
33 |
34 | @Override
35 | public Map get(String... keys) {
36 | Span span = tracingRedissonHelper.buildSpan("get");
37 | span.setTag("keys", Arrays.toString(keys));
38 | return tracingRedissonHelper.decorate(span, () -> buckets.get(keys));
39 | }
40 |
41 | @Override
42 | public boolean trySet(Map buckets) {
43 | Span span = tracingRedissonHelper.buildSpan("trySet");
44 | span.setTag("buckets", nullable(buckets));
45 | return tracingRedissonHelper.decorate(span, () -> this.buckets.trySet(buckets));
46 | }
47 |
48 | @Override
49 | public void set(Map buckets) {
50 | Span span = tracingRedissonHelper.buildSpan("set");
51 | span.setTag("buckets", nullable(buckets));
52 | tracingRedissonHelper.decorate(span, () -> this.buckets.set(buckets));
53 | }
54 |
55 | @Override
56 | public long delete(String... keys) {
57 | Span span = tracingRedissonHelper.buildSpan("delete");
58 | span.setTag("keys", Arrays.toString(keys));
59 | return tracingRedissonHelper.decorate(span, () -> buckets.delete(keys));
60 | }
61 |
62 | @Override
63 | public RFuture