Skip to content

Commit 3fa8fa0

Browse files
authored
Add tracing (#846)
Signed-off-by: andylokandy <andylokandy@hotmail.com>
1 parent 7a8280c commit 3fa8fa0

File tree

9 files changed

+2492
-1531
lines changed

9 files changed

+2492
-1531
lines changed

pkg/coprocessor/coprocessor.pb.go

Lines changed: 60 additions & 120 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/coprocessor_v2/coprocessor_v2.pb.go

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

pkg/kvrpcpb/kvrpcpb.pb.go

Lines changed: 571 additions & 509 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/pdpb/pdpb.pb.go

Lines changed: 92 additions & 92 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/trace/trace.pb.go

Lines changed: 1711 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

proto/coprocessor.proto

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import "kvrpcpb.proto";
66
import "gogoproto/gogo.proto";
77
import "rustproto.proto";
88
import "metapb.proto";
9-
import "span.proto";
109

1110
option (gogoproto.marshaler_all) = true;
1211
option (gogoproto.sizer_all) = true;
@@ -57,7 +56,8 @@ message Response {
5756
bool is_cache_hit = 7;
5857
uint64 cache_last_version = 8;
5958
bool can_be_cached = 9;
60-
repeated span.SpanSet spans = 10;
59+
60+
reserved 10;
6161
}
6262

6363
message RegionInfo {

proto/kvrpcpb.proto

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import "errorpb.proto";
66
import "gogoproto/gogo.proto";
77
import "rustproto.proto";
88
import "deadlock.proto";
9+
import "trace.proto";
910

1011
option (gogoproto.marshaler_all) = true;
1112
option (gogoproto.sizer_all) = true;
@@ -712,6 +713,9 @@ message Context {
712713
// Read request should read through locks belonging to these transactions because these
713714
// transactions are committed and theirs commit_ts <= read request's start_ts.
714715
repeated uint64 committed_locks = 22;
716+
717+
// The informantion to trace a request to TiKV.
718+
trace.TraceContext trace_context = 23;
715719
}
716720

717721
// The API version the server and the client is using.

proto/span.proto

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

proto/trace.proto

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
syntax = "proto3";
2+
package trace;
3+
4+
service TraceRecordPubSub {
5+
// Subscribe the tracing records generated on this service. The service will periodically (e.g. per minute)
6+
// publishes tracing records to clients via gRPC stream.
7+
rpc Subscribe(TraceRecordRequest) returns (stream TraceRecord) {}
8+
}
9+
10+
message TraceRecordRequest {}
11+
12+
// The necessary information to trace a request.
13+
// Setting any field to 0 will disable tracing on the RPC server.
14+
message TraceContext {
15+
// The id that is able to identify a unique request. It's usually a UUID.
16+
uint64 trace_id = 1;
17+
// The span that represents the caller's calling procedural.
18+
uint64 parent_id = 2;
19+
}
20+
21+
message TraceRecord {
22+
oneof record_oneof {
23+
SpanSet spans = 1;
24+
}
25+
}
26+
27+
// The spans for a request on a service.
28+
message SpanSet {
29+
// The id that is able to identify a unique request.
30+
uint64 trace_id = 1;
31+
// The span that represents the caller's calling procedural.
32+
// Set to 0 when reporting to indicate that it's the root service of the entire trace.
33+
uint64 parent_id = 2;
34+
repeated Span spans = 3;
35+
}
36+
37+
message Span {
38+
// The unique span id within a `SpanSet`.
39+
uint32 span_id = 1;
40+
// The parent span within a `SpanSet`.
41+
// Set to 0 to indicate that it's the root span within a `SpanSet`.
42+
uint32 parent_id = 2;
43+
uint64 begin_unix_ns = 3;
44+
uint64 duration_ns = 4;
45+
string event = 5;
46+
repeated Property properties = 6;
47+
}
48+
49+
message Property {
50+
string key = 1;
51+
string value = 2;
52+
}

0 commit comments

Comments
 (0)