Addressed comments.

Signed-off-by: Bartek Plotka <bwplotka@gmail.com>
This commit is contained in:
Bartek Plotka 2019-06-28 19:50:39 +01:00
parent e7185d440d
commit c054896aac
3 changed files with 54 additions and 73 deletions

View file

@ -26,28 +26,20 @@ const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
type ReadRequest_ResponseType int32
const (
// Server will return a ReadResponse with raw samples.
//
// Response headers:
// Content-Type: "application/x-protobuf"
// Content-Encoding: "snappy"
ReadRequest_SAMPLES ReadRequest_ResponseType = 0
// Server will stream a varint delimited ChunkedReadResponse message that contains XOR encoded chunks for a single series.
//
// Response headers:
// Content-Type: "application/x-streamed-protobuf; proto=prometheus.ChunkedReadResponse"
// Content-Encoding: ""
ReadRequest_STREAMED_XOR_CHUNKS ReadRequest_ResponseType = 1
ReadRequest_STREAMED_XOR_CHUNKS ReadRequest_ResponseType = 0
)
var ReadRequest_ResponseType_name = map[int32]string{
0: "SAMPLES",
1: "STREAMED_XOR_CHUNKS",
0: "STREAMED_XOR_CHUNKS",
}
var ReadRequest_ResponseType_value = map[string]int32{
"SAMPLES": 0,
"STREAMED_XOR_CHUNKS": 1,
"STREAMED_XOR_CHUNKS": 0,
}
func (x ReadRequest_ResponseType) String() string {
@ -109,9 +101,14 @@ func (m *WriteRequest) GetTimeseries() []TimeSeries {
type ReadRequest struct {
Queries []*Query `protobuf:"bytes,1,rep,name=queries,proto3" json:"queries,omitempty"`
// accepted_response_types allows negotiating the content type of the response.
// Response types are taken from the list in the FIFO order. If no response type is implemented by server, error is returned.
// For servers that do not support this field, the SAMPLES response type is used strictly.
// If field is empty, the server should assume SAMPLES response type is accepted by the caller.
//
// Response types are taken from the list in the FIFO order. If no response type in `accepted_response_types` is
// implemented by server, error is returned.
// For request that do not support `accepted_response_types` field the non streamed, raw samples response is used.
// In such case response headers are as follows:
//
// Content-Type: "application/x-protobuf"
// Content-Encoding: "snappy"
AcceptedResponseTypes []ReadRequest_ResponseType `protobuf:"varint,2,rep,packed,name=accepted_response_types,json=acceptedResponseTypes,proto3,enum=prometheus.ReadRequest_ResponseType" json:"accepted_response_types,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
@ -339,7 +336,7 @@ func (m *QueryResult) GetTimeseries() []*TimeSeries {
// be sent for previous one.
type ChunkedReadResponse struct {
ChunkedSeries []*ChunkedSeries `protobuf:"bytes,1,rep,name=chunked_series,json=chunkedSeries,proto3" json:"chunked_series,omitempty"`
// query_index representsa an index of the query from ReadRequest.queries this results relates to.
// query_index represents an index of the query from ReadRequest.queries this results relates to.
QueryIndex int64 `protobuf:"varint,2,opt,name=query_index,json=queryIndex,proto3" json:"query_index,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
@ -406,37 +403,36 @@ func init() {
func init() { proto.RegisterFile("remote.proto", fileDescriptor_eefc82927d57d89b) }
var fileDescriptor_eefc82927d57d89b = []byte{
// 466 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x93, 0xcf, 0x6e, 0xd3, 0x40,
0x10, 0xc6, 0xbb, 0x4d, 0xdb, 0xa0, 0x71, 0x88, 0xc2, 0xb6, 0x25, 0xa6, 0x87, 0x34, 0xb2, 0x38,
0x58, 0x2a, 0x0a, 0x22, 0x54, 0x9c, 0x38, 0x90, 0x96, 0x48, 0x45, 0x24, 0xfc, 0x59, 0x07, 0x81,
0x10, 0x92, 0xe5, 0xd8, 0xa3, 0xc6, 0xa2, 0xfe, 0xd3, 0xdd, 0xb5, 0xd4, 0xbc, 0x1e, 0xa7, 0x9e,
0x10, 0x4f, 0x80, 0x50, 0x9e, 0x04, 0xed, 0xda, 0x0e, 0x1b, 0xb8, 0x70, 0x5b, 0x7f, 0xdf, 0x37,
0x3f, 0xef, 0x8c, 0xc7, 0xd0, 0xe2, 0x98, 0x64, 0x12, 0x07, 0x39, 0x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x9a, 0xb6, 0x6b, 0xcd, 0x43, 0x03,
0x00, 0x00,
// 454 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x92, 0xdf, 0x6e, 0xd3, 0x30,
0x14, 0xc6, 0xe7, 0x75, 0x7f, 0xd0, 0x49, 0xa9, 0x8a, 0xb7, 0xd1, 0xb0, 0x8b, 0xae, 0x8a, 0x90,
0x88, 0x34, 0x54, 0x44, 0x41, 0x5c, 0x71, 0xc1, 0x36, 0x2a, 0x0d, 0xb1, 0x82, 0x70, 0x8b, 0x40,
0x08, 0xc9, 0x4a, 0x93, 0xa3, 0x35, 0x62, 0x49, 0x3c, 0xdb, 0x91, 0xd6, 0xc7, 0x83, 0xab, 0x5d,
0xf2, 0x04, 0x08, 0xf5, 0x49, 0x90, 0x9d, 0x66, 0xb8, 0x70, 0xb3, 0x3b, 0xe7, 0xfb, 0x7e, 0xe7,
0x8b, 0xcf, 0xf1, 0x81, 0xa6, 0xc4, 0xac, 0xd0, 0xd8, 0x17, 0xb2, 0xd0, 0x05, 0x05, 0x21, 0x8b,
0x0c, 0xf5, 0x0c, 0x4b, 0xb5, 0xef, 0xe9, 0xb9, 0x40, 0x55, 0x19, 0xfb, 0xbb, 0xe7, 0xc5, 0x79,
0x61, 0x8f, 0x4f, 0xcc, 0xa9, 0x52, 0x83, 0x33, 0x68, 0x7e, 0x92, 0xa9, 0x46, 0x86, 0x97, 0x25,
0x2a, 0x4d, 0x5f, 0x02, 0xe8, 0x34, 0x43, 0x85, 0x32, 0x45, 0xe5, 0x93, 0x5e, 0x23, 0xf4, 0x06,
0xf7, 0xfb, 0x7f, 0x33, 0xfb, 0x93, 0x34, 0xc3, 0xb1, 0x75, 0x8f, 0x37, 0xae, 0x7f, 0x1d, 0xac,
0x31, 0x87, 0x0f, 0xbe, 0x13, 0xf0, 0x18, 0x46, 0x49, 0x9d, 0x76, 0x08, 0xdb, 0x97,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 0xab, 0x98, 0x60, 0x08, 0x9e, 0xd3, 0x1c, 0x7d, 0x71, 0xfb,
0xc5, 0x58, 0x59, 0x89, 0x2b, 0xd8, 0x39, 0x99, 0x95, 0xf9, 0x37, 0xf3, 0x1e, 0xce, 0x54, 0x5f,
0x41, 0x2b, 0xae, 0x64, 0xbe, 0x12, 0xf9, 0xc0, 0x8d, 0x5c, 0x16, 0x2e, 0x53, 0xef, 0xc6, 0xee,
0x27, 0x3d, 0x00, 0xcf, 0x6c, 0xce, 0x9c, 0xa7, 0x79, 0x82, 0x57, 0xcb, 0x39, 0x81, 0x95, 0xde,
0x18, 0xe5, 0x78, 0xf7, 0x7a, 0xd1, 0x25, 0x3f, 0x17, 0x5d, 0xf2, 0x7b, 0xd1, 0x25, 0x5f, 0xb6,
0x4c, 0xae, 0x98, 0x4e, 0xb7, 0xec, 0xde, 0x3f, 0xfb, 0x13, 0x00, 0x00, 0xff, 0xff, 0x94, 0xd0,
0x75, 0xe3, 0x36, 0x03, 0x00, 0x00,
}
func (m *WriteRequest) Marshal() (dAtA []byte, err error) {

View file

@ -28,25 +28,23 @@ message ReadRequest {
repeated Query queries = 1;
enum ResponseType {
// Server will return a ReadResponse with raw samples.
//
// Response headers:
// Content-Type: "application/x-protobuf"
// Content-Encoding: "snappy"
SAMPLES = 0;
// Server will stream a varint delimited ChunkedReadResponse message that contains XOR encoded chunks for a single series.
//
// Response headers:
// Content-Type: "application/x-streamed-protobuf; proto=prometheus.ChunkedReadResponse"
// Content-Encoding: ""
STREAMED_XOR_CHUNKS = 1;
STREAMED_XOR_CHUNKS = 0;
}
// accepted_response_types allows negotiating the content type of the response.
// Response types are taken from the list in the FIFO order. If no response type is implemented by server, error is returned.
// For servers that do not support this field, the SAMPLES response type is used strictly.
// If field is empty, the server should assume SAMPLES response type is accepted by the caller.
//
// Response types are taken from the list in the FIFO order. If no response type in `accepted_response_types` is
// implemented by server, error is returned.
// For request that do not support `accepted_response_types` field the non streamed, raw samples response is used.
// In such case response headers are as follows:
//
// Content-Type: "application/x-protobuf"
// Content-Encoding: "snappy"
repeated ResponseType accepted_response_types = 2;
}
@ -75,6 +73,6 @@ message QueryResult {
message ChunkedReadResponse {
repeated prometheus.ChunkedSeries chunked_series = 1;
// query_index representsa an index of the query from ReadRequest.queries this results relates to.
// query_index represents an index of the query from ReadRequest.queries this results relates to.
int64 query_index = 2;
}

View file

@ -837,20 +837,6 @@ func (api *API) serveFlags(r *http.Request) apiFuncResult {
return apiFuncResult{api.flagsMap, nil, nil, nil}
}
func containsSamplesResponseType(accepted []prompb.ReadRequest_ResponseType) bool {
if len(accepted) == 0 {
// Default value is [SAMPLES]
return true
}
for _, resType := range accepted {
if resType == prompb.ReadRequest_SAMPLES {
return true
}
}
return false
}
func (api *API) remoteRead(w http.ResponseWriter, r *http.Request) {
if err := api.remoteReadGate.Start(r.Context()); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
@ -867,7 +853,8 @@ func (api *API) remoteRead(w http.ResponseWriter, r *http.Request) {
return
}
if ok := containsSamplesResponseType(req.AcceptedResponseTypes); !ok {
// Empty req.AcceptedResponseTypes means non streamed, raw samples response.
if len(req.AcceptedResponseTypes) > 0 {
http.Error(w, fmt.Sprintf("none of requested response types are implemented: %v", req.AcceptedResponseTypes), http.StatusNotImplemented)
return
}