Skip to content

Commit d8dcc79

Browse files
xu1009litexu
andauthored
fix jedis 2.x plugin bug and add test for redis cluster (#580)
* fix bug and add test for redist cluster * add test to flow --------- Co-authored-by: litexu <litexu@tencent.com>
1 parent c9a6170 commit d8dcc79

15 files changed

Lines changed: 773 additions & 0 deletions

File tree

.github/workflows/plugins-test.1.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ jobs:
6767
- jedis-3.1.x-plus-scenario
6868
- jedis-4.x-scenario
6969
- jedis-3.3.x-plus-scenario
70+
- jedis-2.x-3.x-cluster-scenario
7071
- jetty-scenario
7172
- kafka-scenario
7273
- kotlin-coroutine-scenario

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Release Notes.
1212
access name, method cache value field. All names are under `sw$` name trait. They are predictable and unchanged after
1313
re-transform.
1414
* Fix witness class in springmvc-annotation-5.x-plugin to avoid falling into v3 use cases.
15+
* Fix Jedis-2.x plugin bug and add test for redis cluster scene
1516

1617
```
1718
* SWAuxiliaryTypeNamingStrategy
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.skywalking.apm.plugin.jedis.v3;
19+
20+
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
21+
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceConstructorInterceptor;
22+
import redis.clients.jedis.HostAndPort;
23+
24+
public class JedisClusterConstructorWithHostAndPortArgInterceptor implements InstanceConstructorInterceptor {
25+
@Override
26+
public void onConstruct(EnhancedInstance objInst, Object[] allArguments) throws Throwable {
27+
HostAndPort hostAndPort = (HostAndPort) allArguments[0];
28+
objInst.setSkyWalkingDynamicField(hostAndPort.getHost() + ":" + hostAndPort.getPort());
29+
}
30+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
#
3+
# Licensed to the Apache Software Foundation (ASF) under one
4+
# or more contributor license agreements. See the NOTICE file
5+
# distributed with this work for additional information
6+
# regarding copyright ownership. The ASF licenses this file
7+
# to you under the Apache License, Version 2.0 (the
8+
# "License"); you may not use this file except in compliance
9+
# with the License. You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS,
15+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
# See the License for the specific language governing permissions and
17+
# limitations under the License.
18+
19+
home="$(cd "$(dirname $0)"; pwd)"
20+
21+
java -jar ${agent_opts} -Dredis.cluster=${REDIS_CLUSTER_SERVER} ${home}/../libs/jedis-2.x-3.x-cluster-scenario.jar &
Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
segmentItems:
17+
- serviceName: jedis-2.x-3.x-cluster-scenario
18+
segmentSize: ge 1
19+
segments:
20+
- segmentId: not null
21+
spans:
22+
- operationName: Jedis/echo
23+
operationId: 0
24+
parentSpanId: 0
25+
spanId: 1
26+
spanLayer: Cache
27+
startTime: gt 0
28+
endTime: gt 0
29+
componentId: 30
30+
isError: false
31+
spanType: Exit
32+
peer: redis-server3:6379;redis-server2:6379;redis-server1:6379;
33+
skipAnalysis: false
34+
tags:
35+
- {key: cache.type, value: Redis}
36+
- {key: cache.cmd, value: echo}
37+
- {key: cache.key, value: Test}
38+
- operationName: Jedis/set
39+
operationId: 0
40+
parentSpanId: 0
41+
spanId: 2
42+
spanLayer: Cache
43+
startTime: gt 0
44+
endTime: gt 0
45+
componentId: 30
46+
isError: false
47+
spanType: Exit
48+
peer: redis-server3:6379;redis-server2:6379;redis-server1:6379;
49+
skipAnalysis: false
50+
tags:
51+
- {key: cache.type, value: Redis}
52+
- {key: cache.cmd, value: set}
53+
- {key: cache.key, value: a}
54+
- {key: cache.op, value: write}
55+
- operationName: Jedis/get
56+
operationId: 0
57+
parentSpanId: 0
58+
spanId: 3
59+
spanLayer: Cache
60+
startTime: gt 0
61+
endTime: gt 0
62+
componentId: 30
63+
isError: false
64+
spanType: Exit
65+
peer: redis-server3:6379;redis-server2:6379;redis-server1:6379;
66+
skipAnalysis: false
67+
tags:
68+
- {key: cache.type, value: Redis}
69+
- {key: cache.cmd, value: get}
70+
- {key: cache.key, value: a}
71+
- {key: cache.op, value: read}
72+
- operationName: Jedis/del
73+
operationId: 0
74+
parentSpanId: 0
75+
spanId: 4
76+
spanLayer: Cache
77+
startTime: gt 0
78+
endTime: gt 0
79+
componentId: 30
80+
isError: false
81+
spanType: Exit
82+
peer: redis-server3:6379;redis-server2:6379;redis-server1:6379;
83+
skipAnalysis: false
84+
tags:
85+
- {key: cache.type, value: Redis}
86+
- {key: cache.cmd, value: del}
87+
- {key: cache.key, value: a}
88+
- {key: cache.op, value: write}
89+
- operationName: Jedis/echo
90+
operationId: 0
91+
parentSpanId: 0
92+
spanId: 5
93+
spanLayer: Cache
94+
startTime: gt 0
95+
endTime: gt 0
96+
componentId: 30
97+
isError: false
98+
spanType: Exit
99+
peer: redis-server3:6379
100+
skipAnalysis: false
101+
tags:
102+
- {key: cache.type, value: Redis}
103+
- {key: cache.cmd, value: echo}
104+
- {key: cache.key, value: Test}
105+
- operationName: Jedis/set
106+
operationId: 0
107+
parentSpanId: 0
108+
spanId: 6
109+
spanLayer: Cache
110+
startTime: gt 0
111+
endTime: gt 0
112+
componentId: 30
113+
isError: false
114+
spanType: Exit
115+
peer: redis-server3:6379
116+
skipAnalysis: false
117+
tags:
118+
- {key: cache.type, value: Redis}
119+
- {key: cache.cmd, value: set}
120+
- {key: cache.key, value: b}
121+
- {key: cache.op, value: write}
122+
- operationName: Jedis/get
123+
operationId: 0
124+
parentSpanId: 0
125+
spanId: 7
126+
spanLayer: Cache
127+
startTime: gt 0
128+
endTime: gt 0
129+
componentId: 30
130+
isError: false
131+
spanType: Exit
132+
peer: redis-server3:6379
133+
skipAnalysis: false
134+
tags:
135+
- {key: cache.type, value: Redis}
136+
- {key: cache.cmd, value: get}
137+
- {key: cache.key, value: b}
138+
- {key: cache.op, value: read}
139+
- operationName: Jedis/del
140+
operationId: 0
141+
parentSpanId: 0
142+
spanId: 8
143+
spanLayer: Cache
144+
startTime: gt 0
145+
endTime: gt 0
146+
componentId: 30
147+
isError: false
148+
spanType: Exit
149+
peer: redis-server3:6379
150+
skipAnalysis: false
151+
tags:
152+
- {key: cache.type, value: Redis}
153+
- {key: cache.cmd, value: del}
154+
- {key: cache.key, value: b}
155+
- {key: cache.op, value: write}
156+
- operationName: GET:/jedis-2.x-3.x-cluster-scenario/case/jedis-2.x-3.x-cluster-scenario
157+
operationId: 0
158+
parentSpanId: -1
159+
spanId: 0
160+
spanLayer: Http
161+
startTime: gt 0
162+
endTime: gt 0
163+
componentId: 1
164+
isError: false
165+
spanType: Entry
166+
peer: ''
167+
skipAnalysis: false
168+
tags:
169+
- {key: url, value: 'http://localhost:8080/jedis-2.x-3.x-cluster-scenario/case/jedis-2.x-3.x-cluster-scenario'}
170+
- {key: http.method, value: GET}
171+
- {key: http.status_code, value: '200'}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
type: jvm
18+
entryService: http://localhost:8080/jedis-2.x-3.x-cluster-scenario/case/jedis-2.x-3.x-cluster-scenario
19+
healthCheck: http://localhost:8080/jedis-2.x-3.x-cluster-scenario/case/healthCheck
20+
startScript: ./bin/startup.sh
21+
environment:
22+
- REDIS_CLUSTER_SERVER=redis-server1:6379,redis-server2:6379,redis-server3:6379
23+
- SW_PLUGIN_JEDIS_TRACE_REDIS_PARAMETERS=true
24+
dependencies:
25+
redis-server1:
26+
image: bitnami/redis-cluster:7.0
27+
hostname: redis-server1
28+
environment:
29+
- ALLOW_EMPTY_PASSWORD=true
30+
- REDIS_NODES=redis-server1 redis-server2 redis-server3
31+
redis-server2:
32+
image: bitnami/redis-cluster:7.0
33+
hostname: redis-server2
34+
environment:
35+
- ALLOW_EMPTY_PASSWORD=true
36+
- REDIS_NODES=redis-server1 redis-server2 redis-server3
37+
redis-server3:
38+
image: bitnami/redis-cluster:7.0
39+
hostname: redis-server3
40+
depends_on:
41+
- redis-server1
42+
- redis-server2
43+
environment:
44+
- ALLOW_EMPTY_PASSWORD=true
45+
- REDIS_CLUSTER_REPLICAS=0
46+
- REDIS_NODES=redis-server1 redis-server2 redis-server3
47+
- REDIS_CLUSTER_CREATOR=yes
48+

0 commit comments

Comments
 (0)