MCPcopy
hub / github.com/prometheus/prometheus / sampledResponseHTTPHandler

Function sampledResponseHTTPHandler

storage/remote/client_test.go:429–467  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

427}
428
429func sampledResponseHTTPHandler(t *testing.T) http.HandlerFunc {
430 return func(w http.ResponseWriter, _ *http.Request) {
431 w.Header().Set("Content-Type", "application/x-protobuf")
432
433 resp := prompb.ReadResponse{
434 Results: []*prompb.QueryResult{
435 {
436 Timeseries: []*prompb.TimeSeries{
437 {
438 Labels: []prompb.Label{
439 {Name: "foo2", Value: "bar"},
440 },
441 Samples: []prompb.Sample{
442 {Value: float64(1), Timestamp: int64(0)},
443 {Value: float64(2), Timestamp: int64(5)},
444 },
445 Exemplars: []prompb.Exemplar{},
446 },
447 {
448 Labels: []prompb.Label{
449 {Name: "foo1", Value: "bar"},
450 },
451 Samples: []prompb.Sample{
452 {Value: float64(3), Timestamp: int64(0)},
453 {Value: float64(4), Timestamp: int64(5)},
454 },
455 Exemplars: []prompb.Exemplar{},
456 },
457 },
458 },
459 },
460 }
461 b, err := proto.Marshal(&resp)
462 require.NoError(t, err)
463
464 _, err = w.Write(snappy.Encode(nil, b))
465 require.NoError(t, err)
466 }
467}
468
469func delayedResponseHTTPHandler(t *testing.T, delay time.Duration) http.HandlerFunc {
470 return func(w http.ResponseWriter, _ *http.Request) {

Callers 1

TestReadClientFunction · 0.85

Calls 5

HeaderMethod · 0.80
SetMethod · 0.65
WriteMethod · 0.65
EncodeMethod · 0.65
MarshalMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…