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.
TypeScript apmapplication-monitoringdistributed-tracinggogood-first-issuejaegerloglogsmetricsmonitoringnextjsobservabilityopen-sourceopentelemetryprometheusreactreactjsself-hostedtracingtypescript
fix(logs): stringify body_v2 in the v3 logs select (#12534)
Tushar Vats3d5aab744d5e
diff --git a/pkg/query-service/app/clickhouseReader/reader.go b/pkg/query-service/app/clickhouseReader/reader.goindex a8365308fd..b30390ee9c 100644--- a/pkg/query-service/app/clickhouseReader/reader.go+++ b/pkg/query-service/app/clickhouseReader/reader.go@@ -4135,10 +4135,6 @@ func (r *ClickHouseReader) GetTimeSeriesResultV3(ctx context.Context, query strireturn readRowsForTimeSeriesResult(rows, vars, columnNames, countOfNumberCols)}-func isJSONColumn(columnType driver.ColumnType) bool {- return strings.HasPrefix(strings.ToUpper(columnType.DatabaseTypeName()), "JSON")-}-// GetListResultV3 runs the query and returns list of rowsfunc (r *ClickHouseReader) GetListResultV3(ctx context.Context, query string) ([]*v3.Row, error) {ctx = ctxtypes.NewContextWithCommentVals(ctx, map[string]string{@@ -4163,12 +4159,6 @@ func (r *ClickHouseReader) GetListResultV3(ctx context.Context, query string) ([for rows.Next() {var vars = make([]interface{}, len(columnTypes))for i := range columnTypes {- if isJSONColumn(columnTypes[i]) {- // the driver fails to decode JSON into native Go values, so it is read as raw bytes- var raw []byte- vars[i] = &raw- continue- }vars[i] = reflect.New(columnTypes[i].ScanType()).Interface()}if err := rows.Scan(vars...); err != nil {@@ -4177,17 +4167,7 @@ func (r *ClickHouseReader) GetListResultV3(ctx context.Context, query string) ([row := map[string]interface{}{}var t time.Timefor idx, v := range vars {- if isJSONColumn(columnTypes[idx]) {- raw, ok := v.(*[]byte)- if !ok {- continue- }- var value map[string]interface{}- if err := json.Unmarshal(*raw, &value); err != nil {- return nil, errors.New(err.Error())- }- row[columnNames[idx]] = value- } else if columnNames[idx] == "timestamp" {+ if columnNames[idx] == "timestamp" {switch v := v.(type) {case *uint64:t = time.Unix(0, int64(*v))diff --git a/pkg/query-service/constants/constants.go b/pkg/query-service/constants/constants.goindex 0dbc9bf419..86c0eb4f97 100644--- a/pkg/query-service/constants/constants.go+++ b/pkg/query-service/constants/constants.go@@ -205,8 +205,9 @@ const ("scope_string "LogsSQLSelectV2 = logsSQLSelectV2Head + "body, " + logsSQLSelectV2Tail// Orgs on JSON bodies keep the body in body_v2 and have the body column written empty.- // Selected as JSON so the response carries the same body object v5 returns.- LogsSQLSelectV2WithBodyJSON = logsSQLSelectV2Head + "body_v2 as body, " + logsSQLSelectV2Tail+ // Stringified because filters emit a bare `body`, which ClickHouse resolves to this alias:+ // as JSON it fails every string comparison, as String it matches against the body text.+ LogsSQLSelectV2WithBodyJSON = logsSQLSelectV2Head + "toString(body_v2) as body, " + logsSQLSelectV2TailTracesExplorerViewSQLSelectWithSubQuery = "(SELECT traceID, durationNano, " +"serviceName, name FROM %s.%s WHERE parentSpanID = '' AND %s ORDER BY durationNano DESC LIMIT 1 BY traceID"TracesExplorerViewSQLSelectBeforeSubQuery = "SELECT subQuery.serviceName as `subQuery.serviceName`, subQuery.name as `subQuery.name`, count() AS " +