Skip to content

Instantly share code, notes, and snippets.

@yurishkuro
Created April 15, 2018 16:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yurishkuro/d2220a386a82c91f07c13bcb664f4165 to your computer and use it in GitHub Desktop.
Save yurishkuro/d2220a386a82c91f07c13bcb664f4165 to your computer and use it in GitHub Desktop.
Experimental protobuf model for Jaeger using gogoprotobuf extensions
/* Jaeger test
Cf. https://github.com/gogo/protobuf/blob/master/extensions.md
Based on https://github.com/gogo/grpc-example
The JSON is generated with the help of "github.com/cockroachdb/cockroach/pkg/util/protoutil"
with `EmitDefaults: false` setting
jsonpb := &protoutil.JSONPb{
EmitDefaults: false,
Indent: " ",
}
The lack of pointers in the generated structs is due to using this extension: `(gogoproto.nullable) = false`
*/
message TraceId {
uint64 low = 1;
uint64 high = 2;
}
// experiment with `oneof`
/*
message KeyValue {
string key = 1;
oneof value {
string vStr = 2;
double vDouble = 3;
bool vBool = 4;
int64 vLong = 5;
bytes vBinary = 6;
}
}
*/
message KeyValue {
enum Type {
STRING = 0;
DOUBLE = 1;
BOOL = 2;
LONG = 3;
BINARY = 4;
};
string key = 1;
Type vType = 2;
string vStr = 3;
double vDouble = 4;
bool vBool = 5;
int64 vLong = 6;
bytes vBinary = 7;
}
message Log {
google.protobuf.Timestamp timestamp = 1 [
(gogoproto.stdtime) = true,
(gogoproto.nullable) = false
];
repeated KeyValue fields = 2 [
(gogoproto.nullable) = false
];
}
message SpanRef {
enum Type {
CHILD_OF = 0;
FOLLOWS_FROM = 1;
};
Type type = 1;
TraceId trace_id = 2 [
(gogoproto.nullable) = false
];
uint64 span_id = 3;
}
message Process {
string service_name = 1;
repeated KeyValue tags = 2 [
(gogoproto.nullable) = false
];
}
message Span {
TraceId trace_id = 1 [
(gogoproto.nullable) = false
];
uint64 span_id = 2;
uint64 parent_span_id = 3;
string operation_name = 4;
repeated SpanRef references = 5 [
(gogoproto.nullable) = false
];
uint32 flags = 6;
google.protobuf.Timestamp startTime = 7 [
(gogoproto.stdtime) = true,
(gogoproto.nullable) = false
];
google.protobuf.Duration duration = 8 [
(gogoproto.stdduration) = true,
(gogoproto.nullable) = false
];
repeated KeyValue tags = 9 [
(gogoproto.nullable) = false
];
repeated Log logs = 10 [
(gogoproto.nullable) = false
];
repeated string warnings = 11;
Process process = 12;
}
message Trace {
repeated Span spans = 1 [
(gogoproto.nullable) = false
];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment