Skip to content

Commit

Permalink
fix(chstorage): do not return empty label names in log series
Browse files Browse the repository at this point in the history
  • Loading branch information
tdakkota committed Jun 13, 2024
1 parent 9d3d55b commit a7e6f79
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions internal/chstorage/querier_logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ func (q *Querier) LabelValues(ctx context.Context, labelName string, opts logsto
}
query.Where(expr)
}
query.Order(chsql.Ident("value"), chsql.Asc).Limit(1000)
query.Order(chsql.Ident("value"), chsql.Asc).
Limit(1000)

if err := q.do(ctx, selectQuery{
Query: query,
Expand Down Expand Up @@ -267,6 +268,9 @@ func (q *Querier) getLabelMapping(ctx context.Context, labels []string) (_ map[s
}); err != nil {
return nil, err
}
span.AddEvent("mapping_fetched", trace.WithAttributes(
xattribute.StringMap("chstorage.mapping", out),
))

return out, nil
}
Expand Down Expand Up @@ -304,6 +308,10 @@ func (q *Querier) Series(ctx context.Context, opts logstorage.SeriesOptions) (re
defer func() {
if rerr != nil {
span.RecordError(rerr)
} else {
span.AddEvent("series_fetched", trace.WithAttributes(
attribute.Int("chstorage.total_series", len(result)),
))
}
span.End()
}()
Expand Down Expand Up @@ -345,9 +353,9 @@ func (q *Querier) Series(ctx context.Context, opts logstorage.SeriesOptions) (re
attrStringMap(colScope),
),
Data: series,
}).Where(
chsql.InTimeRange("timestamp", opts.Start, opts.End),
)
}).
Distinct(true).
Where(chsql.InTimeRange("timestamp", opts.Start, opts.End))
)
if sels := opts.Selectors; len(sels) > 0 {
// Gather all labels for mapping fetch.
Expand Down Expand Up @@ -385,6 +393,9 @@ func (q *Querier) Series(ctx context.Context, opts logstorage.SeriesOptions) (re
for i := 0; i < series.Rows(); i++ {
s := make(map[string]string)
forEachColMap(series, i, func(k, v string) {
if k == "" {
return
}
s[otelstorage.KeyToLabel(k)] = v
})
result = append(result, s)
Expand Down

0 comments on commit a7e6f79

Please sign in to comment.