| 2123 | } |
| 2124 | |
| 2125 | func addTraceQL(req *tempopb.SearchRequest) { |
| 2126 | // todo: traceql concepts are different than search concepts. this code maps key/value pairs |
| 2127 | // from search to traceql. we can clean this up after we drop old search and move these tests into |
| 2128 | // the tempodb package. |
| 2129 | traceqlConditions := []string{} |
| 2130 | for k, v := range req.Tags { |
| 2131 | traceqlKey := k |
| 2132 | switch traceqlKey { |
| 2133 | case "root.service.name": |
| 2134 | traceqlKey = ".service.name" |
| 2135 | case "root.name": |
| 2136 | traceqlKey = "name" |
| 2137 | case "name": |
| 2138 | case "status.code": |
| 2139 | traceqlKey = "status" |
| 2140 | default: |
| 2141 | traceqlKey = "." + traceqlKey |
| 2142 | } |
| 2143 | |
| 2144 | traceqlVal := v |
| 2145 | switch traceqlKey { |
| 2146 | case ".http.status_code": |
| 2147 | break |
| 2148 | case "status": |
| 2149 | break |
| 2150 | default: |
| 2151 | traceqlVal = fmt.Sprintf(`"%s"`, v) |
| 2152 | } |
| 2153 | traceqlConditions = append(traceqlConditions, fmt.Sprintf("%s=%s", traceqlKey, traceqlVal)) |
| 2154 | } |
| 2155 | if req.MaxDurationMs != 0 { |
| 2156 | traceqlConditions = append(traceqlConditions, fmt.Sprintf("duration < %dms", req.MaxDurationMs)) |
| 2157 | } |
| 2158 | if req.MinDurationMs != 0 { |
| 2159 | traceqlConditions = append(traceqlConditions, fmt.Sprintf("duration > %dms", req.MinDurationMs)) |
| 2160 | } |
| 2161 | |
| 2162 | req.Query = "{" + strings.Join(traceqlConditions, "&&") + "}" |
| 2163 | } |
| 2164 | |
| 2165 | // searchTestSuite returns a set of search test cases that ensure |
| 2166 | // search behavior is consistent across block types and modules. |