Skip to content

Commit 80da79e

Browse files
authored
BanyanDB: add topN cold stage data query. (#13259)
1 parent 5622cb9 commit 80da79e

File tree

12 files changed

+134
-23
lines changed

12 files changed

+134
-23
lines changed

.github/workflows/skywalking.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1021,7 +1021,7 @@ jobs:
10211021
# check if segment files exist
10221022
if docker exec $CONTAINER_ID sh -c '[ -n "$(ls /tmp/measure-data/measure/data/day/seg* 2>/dev/null)" ]'; then
10231023
echo "✅ found segment files"
1024-
sleep 30
1024+
sleep 180
10251025
# create and copy files
10261026
docker cp $CONTAINER_ID:/tmp ${BANYANDB_DATA_GENERATE_ROOT}
10271027
docker cp $CONTAINER_ID:/tmp/measure-data/measure/data/index ${BANYANDB_DATA_GENERATE_ROOT}

docs/en/changes/changes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
* Enhance the trace `List/Tree/Table` graph to support displaying multiple refs of spans and distinguishing different parents.
2727
* Fix: correct the same labels for metrics.
2828
* Refactor: use the Fetch API to instead of Axios.
29+
* Support cold stage data for metrics, trace and log.
2930

3031
#### Documentation
3132

oap-server-bom/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
<httpcore.version>4.4.16</httpcore.version>
7373
<httpasyncclient.version>4.1.5</httpasyncclient.version>
7474
<commons-compress.version>1.21</commons-compress.version>
75-
<banyandb-java-client.version>0.9.0-rc0</banyandb-java-client.version>
75+
<banyandb-java-client.version>0.9.0-rc2</banyandb-java-client.version>
7676
<kafka-clients.version>3.4.0</kafka-clients.version>
7777
<spring-kafka-test.version>2.4.6.RELEASE</spring-kafka-test.version>
7878
<consul.client.version>1.5.3</consul.client.version>

oap-server/server-query-plugin/promql-plugin/src/main/java/org/apache/skywalking/oap/query/promql/handler/PromQLApiHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ public HttpResponse query_range(
511511
@Get
512512
@Post
513513
@Path("/api/v1/format_query")
514-
public HttpResponse query_range(@Param("query") String query) throws IOException {
514+
public HttpResponse format_query(@Param("query") String query) throws IOException {
515515
QueryFormatRsp rsp = new QueryFormatRsp();
516516
rsp.setData(query.replaceAll("\\s", ""));
517517
return jsonResponse(rsp);

oap-server/server-storage-plugin/storage-banyandb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/banyandb/BanyanDBAggregationQueryDAO.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ public List<SelectedRecord> sortMetrics(TopNCondition condition, String valueCol
7878
return directMetricsTopN(isColdStage, condition, schema, valueColumnName, spec, getTimestampRange(duration), additionalConditions);
7979
}
8080

81-
//todo: query cold stage
8281
List<SelectedRecord> serverSideTopN(boolean isColdStage, TopNCondition condition, MetadataRegistry.Schema schema, MetadataRegistry.ColumnSpec valueColumnSpec,
8382
TimestampRange timestampRange, List<KeyValue> additionalConditions) throws IOException {
8483
TopNQueryResponse resp = null;

oap-server/server-storage-plugin/storage-banyandb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/banyandb/stream/AbstractBanyanDBDAO.java

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -139,22 +139,6 @@ protected StreamQueryResponse queryDebuggable(boolean isColdStage,
139139
}
140140
}
141141

142-
protected TopNQueryResponse topN(MetadataRegistry.Schema schema,
143-
TimestampRange timestampRange,
144-
int number,
145-
List<KeyValue> additionalConditions,
146-
List<AttrCondition> attributes) throws IOException {
147-
return topNQuery(schema, timestampRange, number, AbstractQuery.Sort.DESC, additionalConditions, attributes);
148-
}
149-
150-
protected TopNQueryResponse bottomN(MetadataRegistry.Schema schema,
151-
TimestampRange timestampRange,
152-
int number,
153-
List<KeyValue> additionalConditions,
154-
List<AttrCondition> attributes) throws IOException {
155-
return topNQuery(schema, timestampRange, number, AbstractQuery.Sort.ASC, additionalConditions, attributes);
156-
}
157-
158142
protected TopNQueryResponse topNQueryDebuggable(boolean isColdStage,
159143
MetadataRegistry.Schema schema,
160144
TimestampRange timestampRange,
@@ -185,7 +169,7 @@ protected TopNQueryResponse topNQueryDebuggable(boolean isColdStage,
185169
.append(isColdStage);
186170
span.setMsg(builder.toString());
187171
}
188-
TopNQueryResponse response = topNQuery(schema, timestampRange, number, sort, additionalConditions, attributes);
172+
TopNQueryResponse response = topNQuery(isColdStage, schema, timestampRange, number, sort, additionalConditions, attributes);
189173
if (traceContext != null && traceContext.isDumpStorageRsp()) {
190174
builder.append("\n").append(" Response: ").append(new Gson().toJson(response.getTopNLists()));
191175
span.setMsg(builder.toString());
@@ -198,7 +182,8 @@ protected TopNQueryResponse topNQueryDebuggable(boolean isColdStage,
198182
}
199183
}
200184

201-
private TopNQueryResponse topNQuery(MetadataRegistry.Schema schema,
185+
private TopNQueryResponse topNQuery(boolean isColdStage,
186+
MetadataRegistry.Schema schema,
202187
TimestampRange timestampRange,
203188
int number,
204189
AbstractQuery.Sort sort,
@@ -225,6 +210,9 @@ private TopNQueryResponse topNQuery(MetadataRegistry.Schema schema,
225210
});
226211
}
227212
q.setConditions(conditions);
213+
if (isColdStage) {
214+
q.setStages(List.of(BanyanDBStorageConfig.StageName.cold.name()));
215+
}
228216

229217
return getClient().query(q);
230218
}

test/e2e-v2/cases/storage/banyandb/stages/e2e.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,8 @@ verify:
6969
| yq e '.traces | select(.[].endpointnames[0]=="/dubbox-case/case/dubbox-rest/404-test") | .[2].traceids[0]' -
7070
) --start="-96h" --end="-48h" --cold=true
7171
expected: ../../expected/cold/trace-detail.yml
72+
## topN
73+
- query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics exec --expression="top_n(service_resp_time,3,des,attr0='GENERAL')" --start="-96h" --end="-48h" --cold=true --step=DAY
74+
expected: ../../expected/cold/topN-OP-service.yml
75+
- query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics exec --expression="top_n(endpoint_resp_time,3,des)" --start="-96h" --end="-48h" --cold=true --step=DAY
76+
expected: ../../expected/cold/topN-OP-endpoint.yml

test/e2e-v2/cases/storage/expected/cold/dependency-instance.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,6 @@ calls:
3737
targetcomponents: []
3838
id: {{ b64enc "mock_a_service" }}.1_{{ b64enc "mock_a_service_instance" }}-{{ b64enc "mock_b_service" }}.1_{{ b64enc "mock_b_service_instance" }}
3939
detectpoints:
40+
- CLIENT
4041
- SERVER
4142
{{- end }}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one or more
2+
# contributor license agreements. See the NOTICE file distributed with
3+
# this work for additional information regarding copyright ownership.
4+
# The ASF licenses this file to You under the Apache License, Version 2.0
5+
# (the "License"); you may not use this file except in compliance with
6+
# the License. You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
debuggingtrace: null
17+
type: SORTED_LIST
18+
results:
19+
- metric:
20+
labels: []
21+
values:
22+
- id: "mock_a_service - /dubbox-case/case/dubbox-rest/404-test"
23+
value: "{{ (index (index .results 0).values 0).value }}"
24+
traceid: null
25+
owner:
26+
scope: Endpoint
27+
serviceid: {{ b64enc "mock_a_service"}}.1
28+
servicename: mock_a_service
29+
normal: true
30+
serviceinstanceid: null
31+
serviceinstancename: null
32+
endpointid: {{ b64enc "mock_a_service" }}.1_{{ b64enc "/dubbox-case/case/dubbox-rest/404-test" }}
33+
endpointname: /dubbox-case/case/dubbox-rest/404-test
34+
- id: "mock_b_service - org.skywaking.apm.testcase.dubbo.services.GreetServiceImpl.doBusiness()"
35+
value: "{{ (index (index .results 0).values 1).value }}"
36+
traceid: null
37+
owner:
38+
scope: Endpoint
39+
serviceid: {{ b64enc "mock_b_service" }}.1
40+
servicename: mock_b_service
41+
normal: true
42+
serviceinstanceid: null
43+
serviceinstancename: null
44+
endpointid: {{ b64enc "mock_b_service" }}.1_{{ b64enc "org.skywaking.apm.testcase.dubbo.services.GreetServiceImpl.doBusiness()" }}
45+
endpointname: org.skywaking.apm.testcase.dubbo.services.GreetServiceImpl.doBusiness()
46+
- id: "mock_c_service - org.apache.skywalking.RocketMQ"
47+
value: "{{ (index (index .results 0).values 2).value }}"
48+
traceid: null
49+
owner:
50+
scope: Endpoint
51+
serviceid: {{ b64enc "mock_c_service" }}.1
52+
servicename: mock_c_service
53+
normal: true
54+
serviceinstanceid: null
55+
serviceinstancename: null
56+
endpointid: {{ b64enc "mock_c_service" }}.1_{{ b64enc "org.apache.skywalking.RocketMQ" }}
57+
endpointname: org.apache.skywalking.RocketMQ
58+
error: null

0 commit comments

Comments
 (0)