io.opentracing.contrib.redis.redisson.TracingRBucket Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of opentracing-redis-redisson Show documentation
Show all versions of opentracing-redis-redisson Show documentation
OpenTracing Instrumentation for Redisson
/*
* Copyright 2017-2019 The OpenTracing Authors
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package io.opentracing.contrib.redis.redisson;
import static io.opentracing.contrib.redis.common.TracingHelper.nullable;
import io.opentracing.Span;
import java.util.concurrent.TimeUnit;
import org.redisson.api.RBucket;
import org.redisson.api.RFuture;
public class TracingRBucket extends TracingRExpirable implements RBucket {
private final RBucket bucket;
private final TracingRedissonHelper tracingRedissonHelper;
public TracingRBucket(RBucket bucket,
TracingRedissonHelper tracingRedissonHelper) {
super(bucket, tracingRedissonHelper);
this.bucket = bucket;
this.tracingRedissonHelper = tracingRedissonHelper;
}
@Override
public long size() {
Span span = tracingRedissonHelper.buildSpan("size", bucket);
return tracingRedissonHelper.decorate(span, bucket::size);
}
@Override
public V get() {
Span span = tracingRedissonHelper.buildSpan("get", bucket);
return tracingRedissonHelper.decorate(span, bucket::get);
}
@Override
public V getAndDelete() {
Span span = tracingRedissonHelper.buildSpan("getAndDelete", bucket);
return tracingRedissonHelper.decorate(span, bucket::getAndDelete);
}
@Override
public boolean trySet(V value) {
Span span = tracingRedissonHelper.buildSpan("trySet", bucket);
span.setTag("value", nullable(value));
return tracingRedissonHelper.decorate(span, () -> bucket.trySet(value));
}
@Override
public boolean trySet(V value, long timeToLive, TimeUnit timeUnit) {
Span span = tracingRedissonHelper.buildSpan("trySet", bucket);
span.setTag("value", nullable(value));
span.setTag("timeToLive", timeToLive);
span.setTag("timeUnit", nullable(timeUnit));
return tracingRedissonHelper.decorate(span, () -> bucket.trySet(value, timeToLive, timeUnit));
}
@Override
public boolean compareAndSet(V expect, V update) {
Span span = tracingRedissonHelper.buildSpan("compareAndSet", bucket);
span.setTag("expect", nullable(expect));
span.setTag("update", nullable(update));
return tracingRedissonHelper.decorate(span, () -> bucket.compareAndSet(expect, update));
}
@Override
public V getAndSet(V newValue) {
Span span = tracingRedissonHelper.buildSpan("getAndSet", bucket);
span.setTag("newValue", nullable(newValue));
return tracingRedissonHelper.decorate(span, () -> bucket.getAndSet(newValue));
}
@Override
public V getAndSet(V value, long timeToLive, TimeUnit timeUnit) {
Span span = tracingRedissonHelper.buildSpan("getAndSet", bucket);
span.setTag("value", nullable(value));
span.setTag("timeToLive", timeToLive);
span.setTag("timeUnit", nullable(timeUnit));
return tracingRedissonHelper
.decorate(span, () -> bucket.getAndSet(value, timeToLive, timeUnit));
}
@Override
public void set(V value) {
Span span = tracingRedissonHelper.buildSpan("set", bucket);
span.setTag("value", nullable(value));
tracingRedissonHelper.decorate(span, () -> bucket.set(value));
}
@Override
public void set(V value, long timeToLive, TimeUnit timeUnit) {
Span span = tracingRedissonHelper.buildSpan("set", bucket);
span.setTag("value", nullable(value));
span.setTag("timeToLive", timeToLive);
span.setTag("timeUnit", nullable(timeUnit));
tracingRedissonHelper.decorate(span, () -> bucket.set(value, timeToLive, timeUnit));
}
@Override
public RFuture sizeAsync() {
Span span = tracingRedissonHelper.buildSpan("sizeAsync", bucket);
return tracingRedissonHelper.prepareRFuture(span, bucket::sizeAsync);
}
@Override
public RFuture getAsync() {
Span span = tracingRedissonHelper.buildSpan("getAsync", bucket);
return tracingRedissonHelper.prepareRFuture(span, bucket::getAsync);
}
@Override
public RFuture getAndDeleteAsync() {
Span span = tracingRedissonHelper.buildSpan("getAndDeleteAsync", bucket);
return tracingRedissonHelper.prepareRFuture(span, bucket::getAndDeleteAsync);
}
@Override
public RFuture trySetAsync(V value) {
Span span = tracingRedissonHelper.buildSpan("trySetAsync", bucket);
span.setTag("value", nullable(value));
return tracingRedissonHelper.prepareRFuture(span, () -> bucket.trySetAsync(value));
}
@Override
public RFuture trySetAsync(V value, long timeToLive, TimeUnit timeUnit) {
Span span = tracingRedissonHelper.buildSpan("trySetAsync", bucket);
span.setTag("value", nullable(value));
span.setTag("timeToLive", timeToLive);
span.setTag("timeUnit", nullable(timeUnit));
return tracingRedissonHelper
.prepareRFuture(span, () -> bucket.trySetAsync(value, timeToLive, timeUnit));
}
@Override
public RFuture compareAndSetAsync(V expect, V update) {
Span span = tracingRedissonHelper.buildSpan("compareAndSetAsync", bucket);
span.setTag("expect", nullable(expect));
span.setTag("update", nullable(update));
return tracingRedissonHelper
.prepareRFuture(span, () -> bucket.compareAndSetAsync(expect, update));
}
@Override
public RFuture getAndSetAsync(V newValue) {
Span span = tracingRedissonHelper.buildSpan("getAndSetAsync", bucket);
span.setTag("newValue", nullable(newValue));
return tracingRedissonHelper.prepareRFuture(span, () -> bucket.getAndSetAsync(newValue));
}
@Override
public RFuture getAndSetAsync(V value, long timeToLive, TimeUnit timeUnit) {
Span span = tracingRedissonHelper.buildSpan("getAndSetAsync", bucket);
span.setTag("value", nullable(value));
span.setTag("timeToLive", timeToLive);
span.setTag("timeUnit", nullable(timeUnit));
return tracingRedissonHelper
.prepareRFuture(span, () -> bucket.getAndSetAsync(value, timeToLive, timeUnit));
}
@Override
public RFuture setAsync(V value) {
Span span = tracingRedissonHelper.buildSpan("setAsync", bucket);
span.setTag("value", nullable(value));
return tracingRedissonHelper.prepareRFuture(span, () -> bucket.setAsync(value));
}
@Override
public RFuture setAsync(V value, long timeToLive, TimeUnit timeUnit) {
Span span = tracingRedissonHelper.buildSpan("setAsync", bucket);
span.setTag("value", nullable(value));
span.setTag("timeToLive", timeToLive);
span.setTag("timeUnit", nullable(timeUnit));
return tracingRedissonHelper
.prepareRFuture(span, () -> bucket.setAsync(value, timeToLive, timeUnit));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy