Skip to content

Commit be495f7

Browse files
authored
[grpc][v2] Move gRPC API from jaeger to jaeger-idl (#168)
## Which problem is this PR solving? - Towards jaegertracing/jaeger#7089 ## Description of the changes - This PR copies the gRPC API definitions from `jaeger` to this repository. In a follow-up PR, the proto definitions will be removed from `jaeger` and will point to this repo instead. ## How was this change tested? - CI ## Checklist - [x] I have read https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md - [x] I have signed all commits - [x] I have added unit tests for the new functionality - [x] I have run lint and test steps successfully - for `jaeger`: `make lint test` - for `jaeger-ui`: `npm run lint` and `npm run test` --------- Signed-off-by: Mahad Zaryab <[email protected]>
1 parent d32b1f7 commit be495f7

File tree

3 files changed

+221
-1
lines changed

3 files changed

+221
-1
lines changed

Makefile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ test-ci:
252252
proto: proto-prepare proto-api-v2 proto-prototest
253253

254254
# proto-all target is used to generate code for all languages as a validation step.
255-
proto-all: proto-prepare-all proto-api-v2-all proto-api-v3-all
255+
proto-all: proto-prepare-all proto-api-v2-all proto-api-v3-all proto-storage-all
256256

257257
.PHONY: proto-prepare-all
258258
proto-prepare-all:
@@ -313,6 +313,14 @@ proto-api-v3-all:
313313
protoc-gen-swagger/options/openapiv2.proto \
314314
gogoproto/gogo.proto
315315

316+
317+
.PHONY: proto-storage-all
318+
proto-storage-all:
319+
$(PROTOC_WITH_GRPC) \
320+
proto/storage/v2/trace_storage.proto
321+
$(PROTOC_WITH_GRPC) \
322+
proto/storage/v2/dependency_storage.proto
323+
316324
.PHONY: proto-zipkin
317325
proto-zipkin: proto-prepare-all
318326
$(PROTOC_WITHOUT_GRPC) \
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
syntax = "proto3";
2+
3+
package jaeger.storage.v2;
4+
5+
import "google/protobuf/timestamp.proto";
6+
7+
option go_package = "storage";
8+
9+
message GetDependenciesRequest {
10+
// start_time is the start of the time interval to search for the dependencies.
11+
google.protobuf.Timestamp start_time = 1;
12+
// end_time is the end of the time interval to search for the dependencies.
13+
google.protobuf.Timestamp end_time = 2;
14+
}
15+
16+
// Dependency represents a relationship between two services.
17+
message Dependency {
18+
// parent is the name of the caller service.
19+
string parent = 1;
20+
21+
// child is the name of the service being called.
22+
string child = 2;
23+
24+
// call_count is the number of times the parent service called the child service.
25+
uint64 call_count = 3;
26+
27+
// source contains the origin from where the dependency was extracted.
28+
string source = 4;
29+
}
30+
31+
message GetDependenciesResponse {
32+
repeated Dependency dependencies = 1;
33+
}
34+
35+
service DependencyReader {
36+
// GetDependencies loads service dependencies from storage.
37+
rpc GetDependencies(GetDependenciesRequest) returns (GetDependenciesResponse);
38+
}

proto/storage/v2/trace_storage.proto

Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
syntax = "proto3";
2+
3+
package jaeger.storage.v2;
4+
5+
import "google/protobuf/duration.proto";
6+
import "google/protobuf/timestamp.proto";
7+
import "opentelemetry/proto/trace/v1/trace.proto";
8+
9+
option go_package = "storage";
10+
11+
// GetTraceParams represents the query for a single trace from the storage backend.
12+
message GetTraceParams {
13+
// trace_id is a 16 byte array containing the unique identifier for the trace to query.
14+
bytes trace_id = 1;
15+
16+
// start_time is the start of the time interval to search for the trace_id.
17+
//
18+
// This field is optional.
19+
google.protobuf.Timestamp start_time = 2;
20+
21+
// end_time is the end of the time interval to search for the trace_id.
22+
//
23+
// This field is optional.
24+
google.protobuf.Timestamp end_time = 3;
25+
}
26+
27+
// GetTracesRequest represents a request to retrieve multiple traces.
28+
message GetTracesRequest {
29+
repeated GetTraceParams query = 1;
30+
}
31+
32+
// GetServicesRequest represents a request to get service names.
33+
message GetServicesRequest {}
34+
35+
// GetServicesResponse represents the response for GetServicesRequest.
36+
message GetServicesResponse {
37+
repeated string services = 1;
38+
}
39+
40+
// GetOperationsRequest represents a request to get operation names.
41+
message GetOperationsRequest {
42+
// service is the name of the service for which to get operation names.
43+
//
44+
// This field is required.
45+
string service = 1;
46+
47+
// span_kind is the type of span which is used to distinguish between
48+
// spans generated in a particular context.
49+
//
50+
// This field is optional.
51+
string span_kind = 2;
52+
}
53+
54+
// Operation contains information about an operation for a given service.
55+
message Operation {
56+
string name = 1;
57+
string span_kind = 2;
58+
}
59+
60+
// GetOperationsResponse represents the response for GetOperationsRequest.
61+
message GetOperationsResponse {
62+
repeated Operation operations = 1;
63+
}
64+
65+
// KeyValue and all its associated types are copied from opentelemetry-proto/common/v1/common.proto
66+
// (https://github.com/open-telemetry/opentelemetry-proto/blob/main/opentelemetry/proto/common/v1/common.proto).
67+
// This type is used to store attributes in traces.
68+
message KeyValue {
69+
string key = 1;
70+
AnyValue value = 2;
71+
}
72+
73+
message AnyValue {
74+
oneof value {
75+
string string_value = 1;
76+
bool bool_value = 2;
77+
int64 int_value = 3;
78+
double double_value = 4;
79+
ArrayValue array_value = 5;
80+
KeyValueList kvlist_value = 6;
81+
bytes bytes_value = 7;
82+
}
83+
}
84+
85+
message KeyValueList {
86+
repeated KeyValue values = 1;
87+
}
88+
89+
message ArrayValue {
90+
repeated AnyValue values = 1;
91+
}
92+
93+
// TraceQueryParameters contains query parameters to find traces. For a detailed
94+
// definition of each field in this message, refer to `TraceQueryParameters` in `jaeger.api_v3`
95+
// (https://github.com/jaegertracing/jaeger-idl/blob/main/proto/api_v3/query_service.proto).
96+
message TraceQueryParameters {
97+
string service_name = 1;
98+
string operation_name = 2;
99+
repeated KeyValue attributes = 3;
100+
google.protobuf.Timestamp start_time_min = 4;
101+
google.protobuf.Timestamp start_time_max = 5;
102+
google.protobuf.Duration duration_min = 6;
103+
google.protobuf.Duration duration_max = 7;
104+
int32 search_depth = 8;
105+
}
106+
107+
// FindTracesRequest represents a request to find traces.
108+
// It can be used to retrieve the traces (FindTraces) or simply
109+
// the trace IDs (FindTraceIDs).
110+
message FindTracesRequest {
111+
TraceQueryParameters query = 1;
112+
}
113+
114+
// FoundTraceID is a wrapper around trace ID returned from FindTraceIDs
115+
// with an optional time range that may be used in GetTraces calls.
116+
//
117+
// The time range is provided as an optimization hint for some storage backends
118+
// that can perform more efficient queries when they know the approximate time range.
119+
// The value should not be used for precise time-based filtering or assumptions.
120+
// It is meant as a rough boundary and may not be populated in all cases.
121+
message FoundTraceID {
122+
bytes trace_id = 1;
123+
google.protobuf.Timestamp start = 2;
124+
google.protobuf.Timestamp end = 3;
125+
}
126+
127+
// FindTraceIDsResponse represents the response for FindTracesRequest.
128+
message FindTraceIDsResponse {
129+
repeated FoundTraceID trace_ids = 1;
130+
}
131+
132+
// TraceReader is a service that allows reading traces from storage.
133+
// Note that if you implement this service, you should also implement
134+
// OTEL's TraceService in package opentelemetry.proto.collector.trace.v1
135+
// to allow pushing traces to the storage backend
136+
// (https://github.com/open-telemetry/opentelemetry-proto/blob/main/opentelemetry/proto/collector/trace/v1/trace_service.proto)
137+
service TraceReader {
138+
// GetTraces returns a stream that retrieves all traces with given IDs.
139+
//
140+
// Chunking requirements:
141+
// - A single TracesData chunk MUST NOT contain spans from multiple traces.
142+
// - Large traces MAY be split across multiple, *consecutive* TracesData chunks.
143+
// - Each returned TracesData object MUST NOT be empty.
144+
//
145+
// Edge cases:
146+
// - If no spans are found for any given trace ID, the ID is ignored.
147+
// - If none of the trace IDs are found in the storage, an empty response is returned.
148+
rpc GetTraces(GetTracesRequest) returns (stream opentelemetry.proto.trace.v1.TracesData) {}
149+
150+
// GetServices returns all service names known to the backend from traces
151+
// within its retention period.
152+
rpc GetServices(GetServicesRequest) returns (GetServicesResponse) {}
153+
154+
// GetOperations returns all operation names for a given service
155+
// known to the backend from traces within its retention period.
156+
rpc GetOperations(GetOperationsRequest) returns (GetOperationsResponse) {}
157+
158+
// FindTraces returns a stream that retrieves traces matching query parameters.
159+
//
160+
// The chunking rules are the same as for GetTraces.
161+
//
162+
// If no matching traces are found, an empty stream is returned.
163+
rpc FindTraces(FindTracesRequest) returns (stream opentelemetry.proto.trace.v1.TracesData) {}
164+
165+
// FindTraceIDs returns a stream that retrieves IDs of traces matching query parameters.
166+
//
167+
// If no matching traces are found, an empty stream is returned.
168+
//
169+
// This call behaves identically to FindTraces, except that it returns only the list
170+
// of matching trace IDs. This is useful in some contexts, such as batch jobs, where a
171+
// large list of trace IDs may be queried first and then the full traces are loaded
172+
// in batches.
173+
rpc FindTraceIDs(FindTracesRequest) returns (FindTraceIDsResponse) {}
174+
}

0 commit comments

Comments
 (0)