Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace api_v3.SpansResponseChunk with opentelemetry.proto.trace.v1.TracesData #103

Merged
merged 4 commits into from
Jan 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 14 additions & 22 deletions proto/api_v3/query_service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,6 @@ message GetTraceRequest {
];
}

// Response object with spans.
message SpansResponseChunk {
// A list of OpenTelemetry ResourceSpans.
// In case of JSON format the ids (trace_id, span_id, parent_id) are encoded in base64 even though OpenTelemetry specification
// mandates to use hex encoding [2].
// Base64 is chosen to keep compatibility with JSONPb codec.
// [1]: https://github.com/open-telemetry/opentelemetry-proto/blob/main/opentelemetry/proto/trace/v1/trace.proto
// [2]: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/otlp.md#otlphttp
repeated opentelemetry.proto.trace.v1.ResourceSpans resource_spans = 1;
}

// Query parameters to find traces. Except for num_traces, all fields should be treated
// as forming a conjunction, e.g., "service_name='X' AND operation_name='Y' AND ...".
// All fields are matched against individual spans, not at the trace level.
Expand Down Expand Up @@ -118,11 +107,11 @@ service QueryService {
// It means that the JSON response cannot be directly unmarshalled using JSONPb.
// This can be fixed by first parsing into user-defined envelope with standard JSON library
// or string manipulation to remove the envelope. Alternatively generate objects using OpenAPI.
rpc GetTrace(GetTraceRequest) returns (stream SpansResponseChunk) {}
rpc GetTrace(GetTraceRequest) returns (stream opentelemetry.proto.trace.v1.TracesData) {}

// FindTraces searches for traces.
// See GetTrace for JSON unmarshalling.
rpc FindTraces(FindTracesRequest) returns (stream SpansResponseChunk) {}
rpc FindTraces(FindTracesRequest) returns (stream opentelemetry.proto.trace.v1.TracesData) {}

// GetServices returns service names.
rpc GetServices(GetServicesRequest) returns (GetServicesResponse) {}
Expand All @@ -131,10 +120,9 @@ service QueryService {
rpc GetOperations(GetOperationsRequest) returns (GetOperationsResponse) {}
}

// Below are some helper types when using APIv3 via HTTP endpoints implemented via grpc-gateway.
// Below are some helper types when using APIv3 via HTTP endpoints.

// GRPCGatewayError is the type returned when GRPC server returns an error.
// Note that for streaming responses it would be wrapped in GRPCGatewayWrapper below.
// Example: {"error":{"grpcCode":2,"httpCode":500,"message":"...","httpStatus":"text..."}}.
message GRPCGatewayError {
message GRPCGatewayErrorDetails {
Expand All @@ -147,13 +135,17 @@ message GRPCGatewayError {
GRPCGatewayErrorDetails error = 1;
}

// GRPCGatewayWrapper is a type returned when GRPC service returns a stream.
// For some unknown reason grpc-gateway/v1 wraps chunk responses in {"result": {actual output}}.
// GRPCGatewayWrapper wraps streaming responses from GetTrace/FindTraces for HTTP.
// Today there is always only one response because internally the HTTP server gets
// data from QueryService that does not support multiple responses. But in the
// future the server may return multiple responeses using Transfer-Encoding: chunked.
// In case of errors, GRPCGatewayError above is used.
//
// Example:
// {"result": {"resourceSpans": ...}}
//
// See https://github.com/grpc-ecosystem/grpc-gateway/issues/2189
// TODO: it's not clear what happens when the server returns more than one chunk.
// The gateway will presumably combine then into a single HTTP response.
// Currently this is not possible because even though APIv3 GRPC Service is using output stream,
// its implementation reads all spans from QueryService at once and forms only a single chunk.
//
message GRPCGatewayWrapper {
SpansResponseChunk result = 1;
opentelemetry.proto.trace.v1.TracesData result = 1;
}
Loading