Skip to content

SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.

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

Abhishek Sehgalb5b0725cc41e
diff --git a/frontend/src/modules/Traces/TraceFilter.tsx b/frontend/src/modules/Traces/TraceFilter.tsx
index 216ea8ad0e..446ddf4754 100644
--- a/frontend/src/modules/Traces/TraceFilter.tsx
+++ b/frontend/src/modules/Traces/TraceFilter.tsx
@@ -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>
diff --git a/frontend/src/store/actions/traceFilters.ts b/frontend/src/store/actions/traceFilters.ts
index 79b634eb11..3f59bd7706 100644
--- a/frontend/src/store/actions/traceFilters.ts
+++ b/frontend/src/store/actions/traceFilters.ts
@@ -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 {
diff --git a/pkg/query-service/app/clickhouseReader/reader.go b/pkg/query-service/app/clickhouseReader/reader.go
index 2124ad8935..b9c5ea6442 100644
--- a/pkg/query-service/app/clickhouseReader/reader.go
+++ b/pkg/query-service/app/clickhouseReader/reader.go
@@ -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)