Skip to content

Commit f40fc96

Browse files
committed
Update expectedData.yaml and RedisChannelWriterInterceptor for improved tracing of Lettuce commands
1 parent 11bc1a3 commit f40fc96

File tree

3 files changed

+68
-32
lines changed

3 files changed

+68
-32
lines changed

apm-sniffer/apm-sdk-plugin/lettuce-plugins/lettuce-common/src/main/java/org/apache/skywalking/apm/plugin/lettuce/common/RedisChannelWriterInterceptor.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,16 +86,16 @@ public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allAr
8686
operationName = operationName + "BATCH_WRITE";
8787
command = "BATCH_WRITE";
8888
}
89-
AbstractSpan span = ContextManager.createExitSpan(operationName, peer);
9089

9190
if (redisCommandEnhanceInfo.getSnapshot() != null) {
92-
if (!ContextManager.isActive()) {
93-
AbstractSpan localSpan = ContextManager.createLocalSpan("RedisReactive/local");
94-
localSpan.setComponent(ComponentsDefine.LETTUCE);
95-
}
91+
AbstractSpan localSpan = ContextManager.createLocalSpan("RedisReactive/local");
92+
localSpan.setComponent(ComponentsDefine.LETTUCE);
93+
SpanLayer.asCache(localSpan);
9694
ContextManager.continued(redisCommandEnhanceInfo.getSnapshot());
9795
}
98-
96+
97+
AbstractSpan span = ContextManager.createExitSpan(operationName, peer);
98+
9999
span.setComponent(ComponentsDefine.LETTUCE);
100100
Tags.CACHE_TYPE.set(span, "Redis");
101101
if (StringUtil.isNotEmpty(key)) {
@@ -106,6 +106,11 @@ public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allAr
106106
SpanLayer.asCache(span);
107107
span.prepareForAsync();
108108
ContextManager.stopSpan();
109+
110+
if (redisCommandEnhanceInfo.getSnapshot() != null) {
111+
ContextManager.stopSpan();
112+
}
113+
109114
enhancedCommand.setSkyWalkingDynamicField(redisCommandEnhanceInfo.setSpan(span));
110115
}
111116

test/plugin/scenarios/lettuce-webflux-5x-scenario/config/expectedData.yaml

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ segmentItems:
3737
- segmentId: not null
3838
spans:
3939
- operationName: Lettuce/GET
40-
parentSpanId: -1
41-
spanId: 0
40+
parentSpanId: 0
41+
spanId: 1
4242
spanLayer: Cache
4343
startTime: not null
4444
endTime: not null
@@ -52,15 +52,20 @@ segmentItems:
5252
- {key: cache.key, value: key}
5353
- {key: cache.cmd, value: GET}
5454
- {key: cache.op, value: read}
55+
- operationName: RedisReactive/local
56+
parentSpanId: -1
57+
spanId: 0
58+
isError: false
59+
spanType: Local
5560
refs:
5661
- { parentEndpoint: /case/lettuce-case, networkAddress: '', refType: CrossThread,
5762
parentSpanId: 0, parentTraceSegmentId: not null, parentServiceInstance: not
5863
null, parentService: not null, traceId: not null }
5964
- segmentId: not null
6065
spans:
6166
- operationName: Lettuce/SET
62-
parentSpanId: -1
63-
spanId: 0
67+
parentSpanId: 0
68+
spanId: 1
6469
spanLayer: Cache
6570
startTime: not null
6671
endTime: not null
@@ -74,15 +79,20 @@ segmentItems:
7479
- { key: cache.key, value: key0 }
7580
- { key: cache.cmd, value: SET }
7681
- { key: cache.op, value: write }
82+
- operationName: RedisReactive/local
83+
parentSpanId: -1
84+
spanId: 0
85+
isError: false
86+
spanType: Local
7787
refs:
7888
- { parentEndpoint: /case/lettuce-case, networkAddress: '', refType: CrossThread,
7989
parentSpanId: 0, parentTraceSegmentId: not null, parentServiceInstance: not
8090
null, parentService: not null, traceId: not null }
8191
- segmentId: not null
8292
spans:
8393
- operationName: Lettuce/SET
84-
parentSpanId: -1
85-
spanId: 0
94+
parentSpanId: 0
95+
spanId: 1
8696
spanLayer: Cache
8797
startTime: not null
8898
endTime: not null
@@ -96,10 +106,15 @@ segmentItems:
96106
- { key: cache.key, value: key1 }
97107
- { key: cache.cmd, value: SET }
98108
- { key: cache.op, value: write }
109+
- operationName: RedisReactive/local
110+
parentSpanId: -1
111+
spanId: 0
112+
isError: false
113+
spanType: Local
99114
refs:
100115
- { parentEndpoint: /case/lettuce-case, networkAddress: '', refType: CrossThread,
101116
parentSpanId: 0, parentTraceSegmentId: not null, parentServiceInstance: not
102-
null, parentService: not null, traceId: not null }
117+
null, parentService: not null, traceId: not null }
103118
- segmentId: not null
104119
spans:
105120
- operationName: /case/lettuce-case

test/plugin/scenarios/lettuce-webflux-6x-scenario/config/expectedData.yaml

Lines changed: 35 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ segmentItems:
3131
peer: ''
3232
skipAnalysis: false
3333
tags:
34-
- {key: url, value: 'http://localhost:8080/case/healthCheck'}
35-
- {key: http.method, value: HEAD}
36-
- {key: http.status_code, value: '200'}
34+
- { key: url, value: 'http://localhost:8080/case/healthCheck' }
35+
- { key: http.method, value: HEAD }
36+
- { key: http.status_code, value: '200' }
3737
- segmentId: not null
3838
spans:
3939
- operationName: Lettuce/GET
40-
parentSpanId: -1
41-
spanId: 0
40+
parentSpanId: 0
41+
spanId: 1
4242
spanLayer: Cache
4343
startTime: not null
4444
endTime: not null
@@ -48,19 +48,24 @@ segmentItems:
4848
peer: not null
4949
skipAnalysis: false
5050
tags:
51-
- {key: cache.type, value: Redis}
52-
- {key: cache.key, value: key}
53-
- {key: cache.cmd, value: GET}
54-
- {key: cache.op, value: read}
51+
- { key: cache.type, value: Redis }
52+
- { key: cache.key, value: key }
53+
- { key: cache.cmd, value: GET }
54+
- { key: cache.op, value: read }
55+
- operationName: RedisReactive/local
56+
parentSpanId: -1
57+
spanId: 0
58+
isError: false
59+
spanType: Local
5560
refs:
5661
- { parentEndpoint: /case/lettuce-case, networkAddress: '', refType: CrossThread,
5762
parentSpanId: 0, parentTraceSegmentId: not null, parentServiceInstance: not
5863
null, parentService: not null, traceId: not null }
5964
- segmentId: not null
60-
spans:
65+
spans:
6166
- operationName: Lettuce/SET
62-
parentSpanId: -1
63-
spanId: 0
67+
parentSpanId: 0
68+
spanId: 1
6469
spanLayer: Cache
6570
startTime: not null
6671
endTime: not null
@@ -74,15 +79,20 @@ segmentItems:
7479
- { key: cache.key, value: key0 }
7580
- { key: cache.cmd, value: SET }
7681
- { key: cache.op, value: write }
82+
- operationName: RedisReactive/local
83+
parentSpanId: -1
84+
spanId: 0
85+
isError: false
86+
spanType: Local
7787
refs:
7888
- { parentEndpoint: /case/lettuce-case, networkAddress: '', refType: CrossThread,
7989
parentSpanId: 0, parentTraceSegmentId: not null, parentServiceInstance: not
8090
null, parentService: not null, traceId: not null }
8191
- segmentId: not null
82-
spans:
92+
spans:
8393
- operationName: Lettuce/SET
84-
parentSpanId: -1
85-
spanId: 0
94+
parentSpanId: 0
95+
spanId: 1
8696
spanLayer: Cache
8797
startTime: not null
8898
endTime: not null
@@ -96,12 +106,17 @@ segmentItems:
96106
- { key: cache.key, value: key1 }
97107
- { key: cache.cmd, value: SET }
98108
- { key: cache.op, value: write }
109+
- operationName: RedisReactive/local
110+
parentSpanId: -1
111+
spanId: 0
112+
isError: false
113+
spanType: Local
99114
refs:
100115
- { parentEndpoint: /case/lettuce-case, networkAddress: '', refType: CrossThread,
101116
parentSpanId: 0, parentTraceSegmentId: not null, parentServiceInstance: not
102117
null, parentService: not null, traceId: not null }
103118
- segmentId: not null
104-
spans:
119+
spans:
105120
- operationName: /case/lettuce-case
106121
parentSpanId: -1
107122
spanId: 0
@@ -114,6 +129,7 @@ segmentItems:
114129
peer: ''
115130
skipAnalysis: false
116131
tags:
117-
- {key: url, value: 'http://localhost:8080/case/lettuce-case'}
118-
- {key: http.method, value: GET}
119-
- {key: http.status_code, value: '200'}
132+
- { key: url, value: 'http://localhost:8080/case/lettuce-case' }
133+
- { key: http.method, value: GET }
134+
- { key: http.status_code, value: '200' }
135+

0 commit comments

Comments
 (0)