MCPcopy
hub / github.com/prometheus/prometheus / createOverlappingSeriesHandler

Function createOverlappingSeriesHandler

storage/remote/client_test.go:1060–1096  ·  view source on GitHub ↗

createOverlappingSeriesHandler creates responses with same series from multiple queries.

(t *testing.T, queries []*prompb.Query)

Source from the content-addressed store, hash-verified

1058
1059// createOverlappingSeriesHandler creates responses with same series from multiple queries.
1060func createOverlappingSeriesHandler(t *testing.T, queries []*prompb.Query) http.HandlerFunc {
1061 return http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
1062 w.Header().Set("Content-Type", "application/x-streamed-protobuf; proto=prometheus.ChunkedReadResponse")
1063
1064 flusher, ok := w.(http.Flusher)
1065 require.True(t, ok)
1066
1067 cw := NewChunkedWriter(w, flusher)
1068
1069 // Same series labels for both queries (will be merged)
1070 commonLabels := []prompb.Label{
1071 {Name: "__name__", Value: "up"},
1072 {Name: "job", Value: "prometheus"},
1073 }
1074
1075 // Send response for each query with the same series
1076 for queryIndex := range queries {
1077 chunk := buildTestChunks(t)[0] // Use first chunk with 5 samples
1078
1079 cSeries := prompb.ChunkedSeries{
1080 Labels: commonLabels,
1081 Chunks: []prompb.Chunk{chunk},
1082 }
1083
1084 readResp := prompb.ChunkedReadResponse{
1085 ChunkedSeries: []*prompb.ChunkedSeries{&cSeries},
1086 QueryIndex: int64(queryIndex),
1087 }
1088
1089 b, err := proto.Marshal(&readResp)
1090 require.NoError(t, err)
1091
1092 _, err = cw.Write(b)
1093 require.NoError(t, err)
1094 }
1095 })
1096}

Callers

nothing calls this directly

Calls 6

WriteMethod · 0.95
NewChunkedWriterFunction · 0.85
buildTestChunksFunction · 0.85
HeaderMethod · 0.80
SetMethod · 0.65
MarshalMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…