Skip to content

Commit 87709be

Browse files
committed
fix e2e and queryByTraceIdWithInstanceId
1 parent 5cee3d1 commit 87709be

File tree

8 files changed

+47
-97
lines changed

8 files changed

+47
-97
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ IBatchDAO.class, new BanyanDBBatchDAO(client, config.getGlobal().getMaxBulkSize(
155155
));
156156
this.registerServiceImplementation(StorageDAO.class, new BanyanDBStorageDAO(client));
157157
this.registerServiceImplementation(INetworkAddressAliasDAO.class, new BanyanDBNetworkAddressAliasDAO(client, this.config));
158-
this.registerServiceImplementation(ITraceQueryDAO.class, new BanyanDBTraceQueryDAO(client, this.config.getGlobal().getSegmentQueryMaxSize()));
158+
this.registerServiceImplementation(ITraceQueryDAO.class, new BanyanDBTraceQueryDAO(client, this.config.getGlobal().getSegmentQueryMaxSize(), getManager()));
159159
this.registerServiceImplementation(IBrowserLogQueryDAO.class, new BanyanDBBrowserLogQueryDAO(client));
160160
this.registerServiceImplementation(IMetadataQueryDAO.class, new BanyanDBMetadataQueryDAO(client, this.config));
161161
this.registerServiceImplementation(IAlarmQueryDAO.class, new BanyanDBAlarmQueryDAO(client));

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

Lines changed: 34 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,20 @@
1818

1919
package org.apache.skywalking.oap.server.storage.plugin.banyandb.trace;
2020

21-
import com.google.common.collect.ImmutableSet;
2221
import javax.annotation.Nullable;
2322
import org.apache.skywalking.apm.network.language.agent.v3.SegmentObject;
2423
import org.apache.skywalking.apm.network.language.agent.v3.SpanObject;
24+
import org.apache.skywalking.apm.network.language.agent.v3.SpanType;
2525
import org.apache.skywalking.banyandb.v1.client.AbstractQuery;
2626
import org.apache.skywalking.banyandb.v1.client.TimestampRange;
2727
import org.apache.skywalking.banyandb.v1.client.TraceQuery;
2828
import org.apache.skywalking.banyandb.v1.client.TraceQueryResponse;
29+
import org.apache.skywalking.oap.server.core.Const;
30+
import org.apache.skywalking.oap.server.core.CoreModule;
2931
import org.apache.skywalking.oap.server.core.analysis.IDManager;
3032
import org.apache.skywalking.oap.server.core.analysis.manual.searchtag.Tag;
3133
import org.apache.skywalking.oap.server.core.analysis.manual.segment.SegmentRecord;
34+
import org.apache.skywalking.oap.server.core.config.NamingControl;
3235
import org.apache.skywalking.oap.server.core.query.PaginationUtils;
3336
import org.apache.skywalking.oap.server.core.query.input.Duration;
3437
import org.apache.skywalking.oap.server.core.query.input.TraceQueryCondition;
@@ -41,6 +44,7 @@
4144
import org.apache.skywalking.oap.server.core.storage.query.ITraceQueryV2DAO;
4245
import org.apache.skywalking.oap.server.core.storage.query.proto.Source;
4346
import org.apache.skywalking.oap.server.core.storage.query.proto.SpanWrapper;
47+
import org.apache.skywalking.oap.server.library.module.ModuleManager;
4448
import org.apache.skywalking.oap.server.library.util.BooleanUtils;
4549
import org.apache.skywalking.oap.server.library.util.CollectionUtils;
4650
import org.apache.skywalking.oap.server.library.util.StringUtil;
@@ -50,34 +54,17 @@
5054
import java.util.ArrayList;
5155
import java.util.Collections;
5256
import java.util.List;
53-
import java.util.Set;
5457
import org.apache.skywalking.oap.server.storage.plugin.banyandb.stream.AbstractBanyanDBDAO;
5558

5659
public class BanyanDBTraceQueryDAO extends AbstractBanyanDBDAO implements ITraceQueryV2DAO {
57-
private static final Set<String> BASIC_TAGS = ImmutableSet.of(SegmentRecord.TRACE_ID,
58-
SegmentRecord.IS_ERROR,
59-
SegmentRecord.SERVICE_ID,
60-
SegmentRecord.SERVICE_INSTANCE_ID,
61-
SegmentRecord.ENDPOINT_ID,
62-
SegmentRecord.LATENCY,
63-
SegmentRecord.START_TIME,
64-
SegmentRecord.TAGS
65-
);
66-
67-
private static final Set<String> TAGS = ImmutableSet.of(SegmentRecord.TRACE_ID,
68-
SegmentRecord.IS_ERROR,
69-
SegmentRecord.SERVICE_ID,
70-
SegmentRecord.SERVICE_INSTANCE_ID,
71-
SegmentRecord.ENDPOINT_ID,
72-
SegmentRecord.LATENCY,
73-
SegmentRecord.START_TIME,
74-
SegmentRecord.SEGMENT_ID,
75-
SegmentRecord.DATA_BINARY);
7660
private final int segmentQueryMaxSize;
61+
private final ModuleManager moduleManager;
62+
private NamingControl namingControl;
7763

78-
public BanyanDBTraceQueryDAO(BanyanDBStorageClient client, int segmentQueryMaxSize) {
64+
public BanyanDBTraceQueryDAO(BanyanDBStorageClient client, int segmentQueryMaxSize, ModuleManager moduleManager) {
7965
super(client);
8066
this.segmentQueryMaxSize = segmentQueryMaxSize;
67+
this.moduleManager = moduleManager;
8168
}
8269

8370
@Override
@@ -239,20 +226,34 @@ private List<SegmentRecord> buildRecords(TraceQueryResponse resp) throws IOExcep
239226
SegmentRecord segmentRecord = new SegmentRecord();
240227
segmentRecord.setSegmentId(segmentObject.getTraceSegmentId());
241228
segmentRecord.setTraceId(segmentObject.getTraceId());
242-
String serviceId = IDManager.ServiceID.buildId(segmentObject.getService(), true);
229+
String serviceName = Const.EMPTY_STRING;
230+
String instanceName = Const.EMPTY_STRING;
231+
String endpointName = Const.EMPTY_STRING;
232+
serviceName = getNamingControl().formatServiceName(segmentObject.getService());
233+
instanceName = getNamingControl().formatInstanceName(segmentObject.getServiceInstance());
234+
String serviceId = IDManager.ServiceID.buildId(serviceName, true);
243235
segmentRecord.setServiceId(serviceId);
244-
String serviceInstanceId = IDManager.ServiceInstanceID.buildId(serviceId, segmentObject.getServiceInstance());
236+
String serviceInstanceId = IDManager.ServiceInstanceID.buildId(serviceId, instanceName);
245237
segmentRecord.setServiceInstanceId(serviceInstanceId);
246238
long startTimestamp = 0;
247239
long endTimestamp = 0;
240+
248241
for (SpanObject span : segmentObject.getSpansList()) {
249242
if (startTimestamp == 0 || startTimestamp > span.getStartTime()) {
250243
startTimestamp = span.getStartTime();
251244
}
252245
if (span.getEndTime() > endTimestamp) {
253246
endTimestamp = span.getEndTime();
254247
}
248+
if (span.getSpanId() == 0) {
249+
endpointName = getNamingControl().formatEndpointName(serviceName, span.getOperationName());
250+
}
251+
if (SpanType.Entry.equals(span.getSpanType())) {
252+
endpointName = getNamingControl().formatEndpointName(serviceName, span.getOperationName());
253+
}
255254
}
255+
String endpointId = IDManager.EndpointID.buildId(serviceId, endpointName);
256+
segmentRecord.setEndpointId(endpointId);
256257
final long accurateDuration = endTimestamp - startTimestamp;
257258
int duration = accurateDuration > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int) accurateDuration;
258259
segmentRecord.setLatency(duration);
@@ -264,4 +265,13 @@ private List<SegmentRecord> buildRecords(TraceQueryResponse resp) throws IOExcep
264265
}
265266
return segmentRecords;
266267
}
268+
269+
private NamingControl getNamingControl() {
270+
if (namingControl == null) {
271+
this.namingControl = moduleManager.find(CoreModule.NAME)
272+
.provider()
273+
.getService(NamingControl.class);
274+
}
275+
return namingControl;
276+
}
267277
}

test/e2e-v2/cases/kafka/profile/e2e.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,5 @@ verify:
3434
interval: 3s
3535
cases:
3636
- includes:
37+
- ../../profiling/trace/profiling-cases-trace-v2.yaml
3738
- ../../profiling/trace/profiling-cases.yaml

test/e2e-v2/cases/profiling/ebpf/network/banyandb/e2e.yaml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,4 @@ verify:
9393
interval: 10s
9494
cases:
9595
- includes:
96-
- ../network-cases.yaml
97-
# slow traces
98-
- query: |
99-
traceid=$(swctl --display yaml --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql records list \
100-
--name=sampled_slow_trace_record --service-name service --instance-name test-instance --process-name service \
101-
--dest-service-name service --dest-instance-name test-instance --dest-process-name UNKNOWN_REMOTE 100 | yq e '. | map(select(.name == "skywalking-/provider")).[0].id' -);
102-
swctl --display yaml --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql tv2 $traceid
103-
expected: ../expected/skywalking-trace-v2.yml
96+
- ../network-cases.yaml

test/e2e-v2/cases/profiling/ebpf/network/expected/skywalking-trace-v2.yml

Lines changed: 0 additions & 60 deletions
This file was deleted.

test/e2e-v2/cases/profiling/ebpf/network/network-cases.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,13 @@ cases:
126126
--dest-service-name service --dest-instance-name test-instance --dest-process-name UNKNOWN_REMOTE \
127127
--expression=process_relation_http1_client_duration
128128
expected: expected/metrics-has-value.yml
129-
129+
# slow traces
130+
- query: |
131+
traceid=$(swctl --display yaml --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql records list \
132+
--name=sampled_slow_trace_record --service-name service --instance-name test-instance --process-name service \
133+
--dest-service-name service --dest-instance-name test-instance --dest-process-name UNKNOWN_REMOTE 100 | yq e '. | map(select(.name == "skywalking-/provider")).[0].id' -);
134+
swctl --display yaml --base-url=http://${service_skywalking_ui_host}:${service_skywalking_ui_80}/graphql trace $traceid
135+
expected: expected/skywalking-trace.yml
130136
# not founds
131137
- query: |
132138
curl -s -k http://${service_service_host}:${service_service_80}/consumer?type=notfound > /dev/null;

test/e2e-v2/cases/profiling/trace/expected/traces-v2-list.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ traces:
3232
serviceinstancename: {{ .serviceinstancename }}
3333
starttime: {{ gt .starttime 0 }}
3434
endtime: {{ gt .endtime 0 }}
35-
endpointname: POST:/profile/{name}
35+
endpointname: {{ .endpointname }}
3636
type: {{ .type }}
3737
peer: {{ .peer }}
3838
component: {{ .component }}

test/e2e-v2/cases/storage/banyandb/stages/docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ services:
5252
volumes:
5353
- ../data-generate/tmp/measure-data/measure:/tmp/measure
5454
- ../data-generate/tmp/stream-data/stream:/tmp/stream
55-
- ../data-generate/tmp/property/data:/tmp/property
56-
- ../data-generate/tmp/trace/data:/tmp/trace
55+
- ../data-generate/tmp/property:/tmp/property
56+
- ../data-generate/tmp/trace:/tmp/trace
5757
networks:
5858
- e2e
5959

0 commit comments

Comments
 (0)