Skip to content

Commit e9ca6dd

Browse files
committed
fix: added support from version redisson_3.45.1
1 parent 3c0ec89 commit e9ca6dd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+10037
-1
lines changed

redisson_3.42/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ jar {
2929
}
3030

3131
verifyInstrumentation {
32-
passes 'org.redisson:redisson:[3.42.0,)'
32+
passes 'org.redisson:redisson:[3.42.0,3.45.1)'
3333
excludeRegex '.*-NR.*'
3434
}

redisson_3.45.1/build.gradle

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
2+
// Build.gradle generated for instrumentation module redisson_3.23.4
3+
4+
apply plugin: 'java'
5+
6+
dependencies {
7+
implementation 'org.redisson:redisson:3.45.1'
8+
9+
testImplementation 'junit:junit:4.12'
10+
testImplementation fileTree(include: ['*.jar'], dir: '../test-lib')
11+
testImplementation 'com.github.kstyrc:embedded-redis:0.6'
12+
testImplementation 'org.slf4j:slf4j-api:1.7.32'
13+
testImplementation 'org.slf4j:slf4j-simple:1.7.32'
14+
15+
// New Relic Labs Java Agent dependencies
16+
implementation 'com.newrelic.agent.java:newrelic-agent:6.4.1'
17+
implementation 'com.newrelic.agent.java:newrelic-api:6.4.1'
18+
implementation fileTree(include: ['*.jar'], dir: '../libs')
19+
implementation fileTree(include: ['*.jar'], dir: '../test-lib')
20+
}
21+
22+
jar {
23+
manifest {
24+
attributes 'Implementation-Title': 'com.newrelic.instrumentation.labs.redisson_3.45.1'
25+
attributes 'Implementation-Vendor': 'New Relic Labs'
26+
attributes 'Implementation-Vendor-Id': 'com.newrelic.labs'
27+
attributes 'Implementation-Version': 1.0
28+
}
29+
}
30+
31+
verifyInstrumentation {
32+
passes 'org.redisson:redisson:[3.45.1,)'
33+
excludeRegex '.*-NR.*'
34+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package com.newrelic.instrumentation.labs.redisson;
2+
3+
import java.util.function.BiConsumer;
4+
5+
import com.newrelic.api.agent.ExternalParameters;
6+
import com.newrelic.api.agent.NewRelic;
7+
import com.newrelic.api.agent.Segment;
8+
import com.newrelic.api.agent.Trace;
9+
10+
public class NRBiConsumer<T> implements BiConsumer<T, Throwable> {
11+
12+
private Segment segment = null;
13+
private ExternalParameters params = null;
14+
15+
16+
17+
public NRBiConsumer(Segment segment, ExternalParameters params) {
18+
super();
19+
this.segment = segment;
20+
this.params = params;
21+
}
22+
23+
24+
25+
@Override
26+
@Trace
27+
public void accept(T t, Throwable u) {
28+
if(u != null) {
29+
NewRelic.noticeError(u);
30+
}
31+
if(segment != null) {
32+
if(params != null) {
33+
segment.reportAsExternal(params);
34+
}
35+
segment.end();
36+
segment = null;
37+
}
38+
}
39+
40+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package com.newrelic.instrumentation.labs.redisson;
2+
3+
import java.util.function.Supplier;
4+
5+
import org.redisson.api.RFuture;
6+
7+
import com.newrelic.api.agent.DatastoreParameters;
8+
import com.newrelic.api.agent.NewRelic;
9+
import com.newrelic.api.agent.Segment;
10+
11+
public class NRSupplierWrapper<R> implements Supplier<RFuture<R>> {
12+
13+
private Supplier<RFuture<R>> delegate = null;
14+
private String cmdName = null;
15+
private String subName = null;
16+
private DatastoreParameters params = null;
17+
18+
19+
20+
public NRSupplierWrapper(Supplier<RFuture<R>> supplier, String cmd, String sub, DatastoreParameters p) {
21+
delegate = supplier;
22+
cmdName = cmd;
23+
subName = sub;
24+
params = p;
25+
}
26+
27+
@Override
28+
public RFuture<R> get() {
29+
RFuture<R> future = delegate.get();
30+
Segment segment = NewRelic.getAgent().getTransaction().startSegment(cmdName + "-" + subName);
31+
NRBiConsumer<R> action = new NRBiConsumer<R>(segment, params );
32+
33+
return (RFuture<R>) future.whenComplete(action);
34+
}
35+
36+
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
package com.newrelic.instrumentation.labs.redisson;
2+
3+
public class Utils {
4+
5+
static ThreadLocal<String> operation = new ThreadLocal<String>();
6+
static ThreadLocal<String> redissonType = new ThreadLocal<String>();
7+
static ThreadLocal<String> objectName = new ThreadLocal<String>();
8+
9+
10+
public static boolean operationIsSet() {
11+
String operationName = operation.get();
12+
return operationName != null && !operationName.isEmpty();
13+
}
14+
15+
public static String getOperation() {
16+
String operationName = operation.get();
17+
return operationName;
18+
}
19+
20+
public static void setOperation(String operationName) {
21+
operation.set(operationName);
22+
}
23+
24+
public static void unSetOperation() {
25+
operation.remove();
26+
}
27+
28+
public static boolean typeSet() {
29+
String type = redissonType.get();
30+
return type != null && !type.isEmpty();
31+
}
32+
33+
public static void setType(Object obj) {
34+
Class<?> clazz = obj.getClass();
35+
String classname = clazz.getSimpleName().replace("Redisson", "").replace("Reactive", "");
36+
37+
redissonType.set(classname);
38+
}
39+
40+
public static void setType(String type) {
41+
redissonType.set(type);
42+
}
43+
44+
public static String getType() {
45+
return redissonType.get();
46+
}
47+
48+
public static void unSetType() {
49+
redissonType.remove();
50+
}
51+
52+
public static boolean objectNameSet() {
53+
String oName = objectName.get();
54+
return oName != null && !oName.isEmpty();
55+
}
56+
57+
public static void setObjectName(String oName) {
58+
if(oName.startsWith("{")) return;
59+
objectName.set(oName);
60+
}
61+
62+
public static String getObjectName() {
63+
return objectName.get();
64+
}
65+
66+
public static void unSetObjectName() {
67+
objectName.remove();
68+
}
69+
70+
}

0 commit comments

Comments
 (0)