Skip to content

Commit

Permalink
Add tracing (#846)
Browse files Browse the repository at this point in the history
Signed-off-by: andylokandy <[email protected]>
  • Loading branch information
andylokandy authored Jan 6, 2022
1 parent 7a8280c commit 3fa8fa0
Show file tree
Hide file tree
Showing 9 changed files with 2,492 additions and 1,531 deletions.
180 changes: 60 additions & 120 deletions pkg/coprocessor/coprocessor.pb.go

Large diffs are not rendered by default.

779 changes: 0 additions & 779 deletions pkg/coprocessor_v2/coprocessor_v2.pb.go

This file was deleted.

1,080 changes: 571 additions & 509 deletions pkg/kvrpcpb/kvrpcpb.pb.go

Large diffs are not rendered by default.

184 changes: 92 additions & 92 deletions pkg/pdpb/pdpb.pb.go

Large diffs are not rendered by default.

1,711 changes: 1,711 additions & 0 deletions pkg/trace/trace.pb.go

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions proto/coprocessor.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import "kvrpcpb.proto";
import "gogoproto/gogo.proto";
import "rustproto.proto";
import "metapb.proto";
import "span.proto";

option (gogoproto.marshaler_all) = true;
option (gogoproto.sizer_all) = true;
Expand Down Expand Up @@ -57,7 +56,8 @@ message Response {
bool is_cache_hit = 7;
uint64 cache_last_version = 8;
bool can_be_cached = 9;
repeated span.SpanSet spans = 10;

reserved 10;
}

message RegionInfo {
Expand Down
4 changes: 4 additions & 0 deletions proto/kvrpcpb.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import "errorpb.proto";
import "gogoproto/gogo.proto";
import "rustproto.proto";
import "deadlock.proto";
import "trace.proto";

option (gogoproto.marshaler_all) = true;
option (gogoproto.sizer_all) = true;
Expand Down Expand Up @@ -712,6 +713,9 @@ message Context {
// Read request should read through locks belonging to these transactions because these
// transactions are committed and theirs commit_ts <= read request's start_ts.
repeated uint64 committed_locks = 22;

// The informantion to trace a request to TiKV.
trace.TraceContext trace_context = 23;
}

// The API version the server and the client is using.
Expand Down
29 changes: 0 additions & 29 deletions proto/span.proto

This file was deleted.

52 changes: 52 additions & 0 deletions proto/trace.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
syntax = "proto3";
package trace;

service TraceRecordPubSub {
// Subscribe the tracing records generated on this service. The service will periodically (e.g. per minute)
// publishes tracing records to clients via gRPC stream.
rpc Subscribe(TraceRecordRequest) returns (stream TraceRecord) {}
}

message TraceRecordRequest {}

// The necessary information to trace a request.
// Setting any field to 0 will disable tracing on the RPC server.
message TraceContext {
// The id that is able to identify a unique request. It's usually a UUID.
uint64 trace_id = 1;
// The span that represents the caller's calling procedural.
uint64 parent_id = 2;
}

message TraceRecord {
oneof record_oneof {
SpanSet spans = 1;
}
}

// The spans for a request on a service.
message SpanSet {
// The id that is able to identify a unique request.
uint64 trace_id = 1;
// The span that represents the caller's calling procedural.
// Set to 0 when reporting to indicate that it's the root service of the entire trace.
uint64 parent_id = 2;
repeated Span spans = 3;
}

message Span {
// The unique span id within a `SpanSet`.
uint32 span_id = 1;
// The parent span within a `SpanSet`.
// Set to 0 to indicate that it's the root span within a `SpanSet`.
uint32 parent_id = 2;
uint64 begin_unix_ns = 3;
uint64 duration_ns = 4;
string event = 5;
repeated Property properties = 6;
}

message Property {
string key = 1;
string value = 2;
}

0 comments on commit 3fa8fa0

Please sign in to comment.