MCPcopy Index your code
hub / github.com/uber/aresdb / HandleSQL

Method HandleSQL

broker/handler.go:48–89  ·  view source on GitHub ↗
(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

46}
47
48func (handler *QueryHandler) HandleSQL(w http.ResponseWriter, r *http.Request) {
49 utils.GetRootReporter().GetCounter(utils.SQLQueryReceivedBroker).Inc(1)
50 var queryReqeust BrokerSQLRequest
51
52 start := utils.Now()
53 var err error
54 defer func() {
55 duration := utils.Now().Sub(start)
56 utils.GetRootReporter().GetTimer(utils.QueryLatencyBroker).Record(duration)
57 if err != nil {
58 utils.GetRootReporter().GetCounter(utils.QueryFailedBroker).Inc(1)
59 utils.GetLogger().With(
60 "error", err,
61 "request", queryReqeust).Error("Error happened when processing request")
62 } else {
63 utils.GetRootReporter().GetCounter(utils.QuerySucceededBroker).Inc(1)
64 utils.GetLogger().With("request", queryReqeust).Info("Request succeeded")
65 }
66 }()
67
68 err = apiCom.ReadRequest(r, &queryReqeust)
69 if err != nil {
70 apiCom.RespondWithError(w, err)
71 return
72 }
73
74 sqlParseStart := utils.Now()
75 var aql *queryCom.AQLQuery
76 aql, err = sql.Parse(queryReqeust.Body.Query, utils.GetLogger())
77 utils.GetRootReporter().GetTimer(utils.SQLParsingLatencyBroker).Record(utils.Now().Sub(sqlParseStart))
78 if err != nil {
79 apiCom.RespondWithError(w, err)
80 return
81 }
82
83 err = handler.exec.Execute(context.Background(), handler.getReqestID(), aql, queryReqeust.Accept == utils.HTTPContentTypeHyperLogLog, w)
84 if err != nil {
85 apiCom.RespondWithError(w, err)
86 return
87 }
88 return
89}
90
91func (handler *QueryHandler) HandleAQL(w http.ResponseWriter, r *http.Request) {
92 var queryReqeust BrokerAQLRequest

Callers

nothing calls this directly

Calls 11

getReqestIDMethod · 0.95
GetRootReporterFunction · 0.92
NowFunction · 0.92
GetLoggerFunction · 0.92
ParseFunction · 0.92
GetCounterMethod · 0.80
GetTimerMethod · 0.80
ErrorMethod · 0.65
WithMethod · 0.65
InfoMethod · 0.65
ExecuteMethod · 0.65

Tested by

no test coverage detected