MCPcopy
hub / github.com/grafana/tempo / SearchHandler

Method SearchHandler

modules/querier/http.go:127–172  ·  view source on GitHub ↗
(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

125}
126
127func (q *Querier) SearchHandler(w http.ResponseWriter, r *http.Request) {
128 isSearchBlock := api.IsSearchBlock(r)
129
130 // Enforce the query timeout while querying backends
131 ctx, cancel := context.WithDeadline(r.Context(), time.Now().Add(q.cfg.Search.QueryTimeout))
132 defer cancel()
133
134 ctx, span := tracer.Start(ctx, "Querier.SearchHandler")
135 defer span.End()
136
137 span.SetAttributes(attribute.String("requestURI", r.RequestURI))
138 span.SetAttributes(attribute.Bool("isSearchBlock", isSearchBlock))
139
140 var resp *tempopb.SearchResponse
141 if !isSearchBlock {
142 req, err := api.ParseSearchRequest(r)
143 if err != nil {
144 http.Error(w, err.Error(), http.StatusBadRequest)
145 return
146 }
147
148 span.SetAttributes(attribute.String("SearchRequest", req.String()))
149
150 resp, err = q.SearchRecent(ctx, req)
151 if err != nil {
152 handleError(w, err)
153 return
154 }
155 } else {
156 req, err := api.ParseSearchBlockRequest(r)
157 if err != nil {
158 http.Error(w, err.Error(), http.StatusBadRequest)
159 return
160 }
161
162 span.SetAttributes(attribute.String("SearchRequestBlock", req.String()))
163
164 resp, err = q.SearchBlock(ctx, req)
165 if err != nil {
166 handleError(w, err)
167 return
168 }
169 }
170
171 writeFormattedContentForRequest(w, r, resp, span)
172}
173
174func (q *Querier) SearchTagsHandler(w http.ResponseWriter, r *http.Request) {
175 isSearchBlock := api.IsSearchBlock(r)

Callers

nothing calls this directly

Calls 14

SearchRecentMethod · 0.95
SearchBlockMethod · 0.95
IsSearchBlockFunction · 0.92
ParseSearchRequestFunction · 0.92
ParseSearchBlockRequestFunction · 0.92
handleErrorFunction · 0.85
BoolMethod · 0.80
ContextMethod · 0.65
AddMethod · 0.65
NowMethod · 0.65
StartMethod · 0.65

Tested by

no test coverage detected