feat: Allow users to search spans with status code regex (#249)

This commit is contained in:
Abhishek Sehgal 2021-08-02 15:38:18 +05:30 committed by GitHub
parent 3acef9c86a
commit b5b0725cc4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 3 deletions

View File

@ -481,6 +481,7 @@ const _TraceFilter = (props: TraceFilterProps) => {
<Select style={{ width: 120, textAlign: "center" }}>
<Option value="equals">EQUAL</Option>
<Option value="contains">CONTAINS</Option>
<Option value="regex">REGEX</Option>
</Select>
</FormItem>

View File

@ -4,7 +4,7 @@ import { ActionTypes } from "./types";
export interface TagItem {
key: string;
value: string;
operator: "equals" | "contains";
operator: "equals" | "contains" | "regex";
}
export interface LatencyValue {

View File

@ -244,11 +244,14 @@ func (r *ClickHouseReader) SearchSpans(ctx context.Context, queryParams *model.S
if item.Operator == "equals" {
query = query + " AND has(tags, ?)"
args = append(args, fmt.Sprintf("%s:%s", item.Key, item.Value))
} else if item.Operator == "contains" {
query = query + " AND tagsValues[indexOf(tagsKeys, ?)] ILIKE ?"
args = append(args, item.Key)
args = append(args, fmt.Sprintf("%%%s%%", item.Value))
} else if item.Operator == "regex" {
query = query + " AND match(tagsValues[indexOf(tagsKeys, ?)], ?)"
args = append(args, item.Key)
args = append(args, item.Value)
} else if item.Operator == "isnotnull" {
query = query + " AND has(tagsKeys, ?)"
args = append(args, item.Key)
@ -674,11 +677,14 @@ func (r *ClickHouseReader) SearchSpansAggregate(ctx context.Context, queryParams
if item.Operator == "equals" {
query = query + " AND has(tags, ?)"
args = append(args, fmt.Sprintf("%s:%s", item.Key, item.Value))
} else if item.Operator == "contains" {
query = query + " AND tagsValues[indexOf(tagsKeys, ?)] ILIKE ?"
args = append(args, item.Key)
args = append(args, fmt.Sprintf("%%%s%%", item.Value))
} else if item.Operator == "regex" {
query = query + " AND match(tagsValues[indexOf(tagsKeys, ?)], ?)"
args = append(args, item.Key)
args = append(args, item.Value)
} else if item.Operator == "isnotnull" {
query = query + " AND has(tagsKeys, ?)"
args = append(args, item.Key)