Skip to content

Commit 0b24362

Browse files
authored
Trace model support specify spanId and Trace query support internal debugging. (#13533)
1 parent f415bab commit 0b24362

File tree

15 files changed

+82
-43
lines changed

15 files changed

+82
-43
lines changed

docs/en/debugging/query-tracing.md

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,7 @@ childSpans:
189189
|--------------------|---------------------------------------------------------------------------|----------|
190190
| startTime | The start time of the query | Yes |
191191
| endTime | The end time of the query | Yes |
192-
| step | The query step | Yes |
193-
| coldStage | Only for BanyanDB, the flag to query from cold stage, default is false. | No |
192+
| step | The query step | Yes |
194193
| service | The service name | Yes |
195194
| serviceLayer | The service layer name | No |
196195
| serviceInstance | The service instance name | No |
@@ -222,13 +221,16 @@ debuggingTrace:
222221
- URL: HTTP GET `http://{core restHost}:{core restPort}/debugging/query/trace/queryTrace?{parameters}`.
223222
- Parameters
224223

225-
| Field | Description | Required |
226-
|-------------------|---------------------|--------------------|
227-
| traceId | The ID of the trace | Yes |
224+
| Field | Description | Required |
225+
|-----------------|----------------------------------|-----------------|
226+
| traceId | The ID of the trace | Yes |
227+
| startTime | The start time of the query | Yes |
228+
| endTime | The end time of the query | Yes |
229+
| step | The query step | Yes |
228230

229231
- Example
230232
```shell
231-
curl -X GET 'http://127.0.0.1:12800/debugging/query/trace/queryTrace?traceId=8211a1d1-de0f-4485-8766-c88866a8f034'
233+
curl -X GET 'http://127.0.0.1:12800/debugging/query/trace/queryTrace?traceId=8211a1d1-de0f-4485-8766-c88866a8f034&startTime=2025-09-28&endTime=2025-09-28%200915&step=DAY'
232234
```
233235

234236
Response will include query result and the debuggingTrace information, the debuggingTrace information is the same as the MQE query tracing:
@@ -240,19 +242,6 @@ debuggingTrace:
240242
...
241243
```
242244

243-
#### Tracing SkyWalking API queryTraceFromColdStage
244-
Only for BanyanDB, can be used to query the trace in the cold stage.
245-
246-
- URL: HTTP GET `http://{core restHost}:{core restPort}/debugging/query/trace/queryTraceFromColdStage?{parameters}`.
247-
- Parameters
248-
249-
| Field | Description | Required |
250-
|-----------------|----------------------------------|-----------------|
251-
| traceId | The ID of the trace | Yes |
252-
| startTime | The start time of the query | Yes |
253-
| endTime | The end time of the query | Yes |
254-
| step | The query step | Yes |
255-
256245
### Tracing Zipkin Trace Query
257246

258247
#### Tracing Zipkin API /api/v2/traces

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</banyandb-java-client.version>
75+
<banyandb-java-client.version>0.9.1</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-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/segment/SegmentRecord.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
@SQLDatabase.ExtraColumn4AdditionalEntity(additionalTable = SegmentRecord.ADDITIONAL_TAG_TABLE, parentColumn = TIME_BUCKET)
4949
@BanyanDB.TimestampColumn(SegmentRecord.START_TIME)
5050
@BanyanDB.Trace.TraceIdColumn(SegmentRecord.TRACE_ID)
51+
@BanyanDB.Trace.SpanIdColumn(SegmentRecord.SEGMENT_ID)
5152
@BanyanDB.Trace.IndexRule(name = SegmentRecord.START_TIME, columns = {
5253
SegmentRecord.SERVICE_ID,
5354
SegmentRecord.IS_ERROR,

oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/spanattach/SWSpanAttachedEventRecord.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import lombok.Setter;
2424
import org.apache.skywalking.oap.server.core.analysis.Stream;
2525
import org.apache.skywalking.oap.server.core.analysis.manual.segment.SegmentRecord;
26+
import org.apache.skywalking.oap.server.core.storage.StorageData;
2627
import org.apache.skywalking.oap.server.core.storage.model.BanyanDBTrace;
2728
import org.apache.skywalking.oap.server.core.analysis.record.Record;
2829
import org.apache.skywalking.oap.server.core.analysis.worker.RecordStreamProcessor;
@@ -45,6 +46,7 @@
4546
@Stream(name = SWSpanAttachedEventRecord.INDEX_NAME, scopeId = SW_SPAN_ATTACHED_EVENT, builder = SWSpanAttachedEventRecord.Builder.class, processor = RecordStreamProcessor.class)
4647
@BanyanDB.TimestampColumn(SWSpanAttachedEventRecord.TIMESTAMP)
4748
@BanyanDB.Trace.TraceIdColumn(SWSpanAttachedEventRecord.RELATED_TRACE_ID)
49+
@BanyanDB.Trace.SpanIdColumn(StorageData.ID)
4850
@BanyanDB.Group(traceGroup = BanyanDB.TraceGroup.TRACE)
4951
public class SWSpanAttachedEventRecord extends Record implements BanyanDBTrace, BanyanDBTrace.MergeTable {
5052

@@ -133,6 +135,16 @@ public long getTimestampColumnValue() {
133135
return timestamp;
134136
}
135137

138+
@Override
139+
public String getMergeSpanIdColumnName() {
140+
return SegmentRecord.SEGMENT_ID;
141+
}
142+
143+
@Override
144+
public String getSpanIdColumnValue() {
145+
return id().build();
146+
}
147+
136148
public static class Builder implements StorageBuilder<SWSpanAttachedEventRecord> {
137149
@Override
138150
public SWSpanAttachedEventRecord storage2Entity(Convert2Entity converter) {

oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/spanattach/SpanAttachedEventRecord.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.apache.skywalking.oap.server.core.analysis.record.Record;
2626
import org.apache.skywalking.oap.server.core.analysis.worker.RecordStreamProcessor;
2727
import org.apache.skywalking.oap.server.core.source.ScopeDeclaration;
28+
import org.apache.skywalking.oap.server.core.storage.StorageData;
2829
import org.apache.skywalking.oap.server.core.storage.StorageID;
2930
import org.apache.skywalking.oap.server.core.storage.annotation.BanyanDB;
3031
import org.apache.skywalking.oap.server.core.storage.annotation.Column;
@@ -45,6 +46,7 @@
4546
@Stream(name = SpanAttachedEventRecord.INDEX_NAME, scopeId = SPAN_ATTACHED_EVENT, builder = SpanAttachedEventRecord.Builder.class, processor = RecordStreamProcessor.class)
4647
@BanyanDB.TimestampColumn(SpanAttachedEventRecord.TIMESTAMP)
4748
@BanyanDB.Trace.TraceIdColumn(SpanAttachedEventRecord.RELATED_TRACE_ID)
49+
@BanyanDB.Trace.SpanIdColumn(StorageData.ID)
4850
@BanyanDB.Group(traceGroup = BanyanDB.TraceGroup.ZIPKIN_TRACE)
4951
public class SpanAttachedEventRecord extends Record implements BanyanDBTrace, BanyanDBTrace.MergeTable {
5052

@@ -131,6 +133,16 @@ public long getTimestampColumnValue() {
131133
return timestamp;
132134
}
133135

136+
@Override
137+
public String getMergeSpanIdColumnName() {
138+
return ZipkinSpanRecord.SPAN_ID;
139+
}
140+
141+
@Override
142+
public String getSpanIdColumnValue() {
143+
return id().build();
144+
}
145+
134146
public static class Builder implements StorageBuilder<SpanAttachedEventRecord> {
135147
@Override
136148
public SpanAttachedEventRecord storage2Entity(Convert2Entity converter) {

oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/annotation/BanyanDB.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,12 @@ enum IndexType {
170170
String value();
171171
}
172172

173+
@Target({ElementType.TYPE})
174+
@Retention(RetentionPolicy.RUNTIME)
175+
@interface SpanIdColumn {
176+
String value();
177+
}
178+
173179
/**
174180
* IndexRule is used to define a composite index in BanyanDB.
175181
* Notice, the order of columns is significant, the columns in front have a higher priority

oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/model/BanyanDBModelExtension.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,16 @@ public class BanyanDBModelExtension {
5050
@Setter
5151
private String traceIdColumn;
5252

53+
54+
/**
55+
* spanIdColumn is to identify which column in the Trace model is used as the span ID.
56+
*
57+
* @since 10.3.0
58+
*/
59+
@Getter
60+
@Setter
61+
private String spanIdColumn;
62+
5363
/**
5464
* traceIndexRules is to identify which columns in the Trace model are used as the indexRule.
5565
* BanyanDB Trace model requires at least one traceIndexRules.

oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/model/BanyanDBTrace.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,9 @@ interface MergeTable {
3434
String getMergeTimestampColumnName();
3535

3636
long getTimestampColumnValue();
37+
38+
String getMergeSpanIdColumnName();
39+
40+
String getSpanIdColumnValue();
3741
}
3842
}

oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/model/StorageModels.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,15 @@ public Model add(Class<?> aClass, int scopeId, Storage storage) throws StorageEx
114114
banyanDBModelExtension.setTraceIdColumn(traceIdColumn);
115115
}
116116

117+
if (aClass.isAnnotationPresent(BanyanDB.Trace.SpanIdColumn.class)) {
118+
String spanIdColumn = aClass.getAnnotation(BanyanDB.Trace.SpanIdColumn.class).value();
119+
if (StringUtil.isBlank(spanIdColumn)) {
120+
throw new IllegalStateException(
121+
"Model[trace." + storage.getModelName() + "] missing defined @BanyanDB.SpanIdColumn");
122+
}
123+
banyanDBModelExtension.setSpanIdColumn(spanIdColumn);
124+
}
125+
117126
// Add index rules for BanyanDB trace model
118127
if (aClass.isAnnotationPresent(BanyanDB.Trace.TraceIdColumn.class) ||
119128
aClass.isAnnotationPresent(BanyanDB.Trace.IndexRule.List.class)) {

oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/zipkin/ZipkinSpanRecord.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
@SQLDatabase.ExtraColumn4AdditionalEntity(additionalTable = ZipkinSpanRecord.ADDITIONAL_QUERY_TABLE, parentColumn = TIME_BUCKET)
5757
@BanyanDB.TimestampColumn(ZipkinSpanRecord.TIMESTAMP_MILLIS)
5858
@BanyanDB.Trace.TraceIdColumn(ZipkinSpanRecord.TRACE_ID)
59+
@BanyanDB.Trace.SpanIdColumn(ZipkinSpanRecord.SPAN_ID)
5960
@BanyanDB.Trace.IndexRule(name = ZipkinSpanRecord.TIMESTAMP_MILLIS, columns = {
6061
ZipkinSpanRecord.LOCAL_ENDPOINT_SERVICE_NAME,
6162
}, orderByColumn = ZipkinSpanRecord.TIMESTAMP_MILLIS)

0 commit comments

Comments
 (0)