diff --git a/internal/chstorage/querier_traces.go b/internal/chstorage/querier_traces.go index 8ff95a20..8cdbfabc 100644 --- a/internal/chstorage/querier_traces.go +++ b/internal/chstorage/querier_traces.go @@ -29,8 +29,8 @@ func (q *Querier) SearchTags(ctx context.Context, tags map[string]string, opts t xattribute.StringMap("chstorage.tags", tags), xattribute.UnixNano("chstorage.range.start", opts.Start), xattribute.UnixNano("chstorage.range.end", opts.End), - attribute.Int64("chstorage.min_duration", int64(opts.MinDuration)), - attribute.Int64("chstorage.max_duration", int64(opts.MaxDuration)), + xattribute.Duration("chstorage.min_duration", opts.MinDuration), + xattribute.Duration("chstorage.max_duration", opts.MaxDuration), attribute.String("chstorage.table", table), ), @@ -427,8 +427,8 @@ func (q *Querier) SelectSpansets(ctx context.Context, params traceqlengine.Selec xattribute.StringerSlice("traceql.matchers", params.Matchers), xattribute.UnixNano("traceql.range.start", params.Start), xattribute.UnixNano("traceql.range.end", params.End), - attribute.Int64("traceql.min_duration", int64(params.MinDuration)), - attribute.Int64("traceql.max_duration", int64(params.MaxDuration)), + xattribute.Duration("traceql.min_duration", params.MinDuration), + xattribute.Duration("traceql.max_duration", params.MaxDuration), attribute.Int("traceql.limit", params.Limit), attribute.String("chstorage.table", table), diff --git a/internal/logql/logqlengine/engine_literal_query.go b/internal/logql/logqlengine/engine_literal_query.go index d34b750c..ec825ccc 100644 --- a/internal/logql/logqlengine/engine_literal_query.go +++ b/internal/logql/logqlengine/engine_literal_query.go @@ -34,7 +34,7 @@ func (q *LiteralQuery) Eval(ctx context.Context, params EvalParams) (data lokiap _, span := q.tracer.Start(ctx, "logql.LiteralQuery", trace.WithAttributes( xattribute.UnixNano("logql.params.start", params.Start), xattribute.UnixNano("logql.params.end", params.End), - attribute.Int64("logql.params.step", int64(params.Step)), + xattribute.Duration("logql.params.step", params.Step), attribute.Stringer("logql.params.direction", params.Direction), attribute.Int("logql.params.limit", params.Limit), )) diff --git a/internal/logql/logqlengine/engine_log_query.go b/internal/logql/logqlengine/engine_log_query.go index 6467f9ee..361cc053 100644 --- a/internal/logql/logqlengine/engine_log_query.go +++ b/internal/logql/logqlengine/engine_log_query.go @@ -64,7 +64,7 @@ func (q *LogQuery) eval(ctx context.Context, params EvalParams) (data lokiapi.St ctx, span := q.tracer.Start(ctx, "logql.LogQuery", trace.WithAttributes( xattribute.UnixNano("logql.params.start", params.Start), xattribute.UnixNano("logql.params.end", params.End), - attribute.Int64("logql.params.step", int64(params.Step)), + xattribute.Duration("logql.params.step", params.Step), attribute.Stringer("logql.params.direction", params.Direction), attribute.Int("logql.params.limit", params.Limit), )) diff --git a/internal/logql/logqlengine/engine_metric_query.go b/internal/logql/logqlengine/engine_metric_query.go index 8f12f3f9..eed5f5c5 100644 --- a/internal/logql/logqlengine/engine_metric_query.go +++ b/internal/logql/logqlengine/engine_metric_query.go @@ -49,7 +49,7 @@ func (q *MetricQuery) eval(ctx context.Context, params EvalParams) (data lokiapi ctx, span := q.tracer.Start(ctx, "logql.MetricQuery", trace.WithAttributes( xattribute.UnixNano("logql.params.start", params.Start), xattribute.UnixNano("logql.params.end", params.End), - attribute.Int64("logql.params.step", int64(params.Step)), + xattribute.Duration("logql.params.step", params.Step), attribute.Stringer("logql.params.direction", params.Direction), attribute.Int("logql.params.limit", params.Limit), )) diff --git a/internal/traceql/traceqlengine/engine.go b/internal/traceql/traceqlengine/engine.go index d962f6f6..6c1a437e 100644 --- a/internal/traceql/traceqlengine/engine.go +++ b/internal/traceql/traceqlengine/engine.go @@ -62,8 +62,8 @@ func (e *Engine) Eval(ctx context.Context, query string, params EvalParams) (tra ctx, span := e.tracer.Start(ctx, "Eval", trace.WithAttributes( attribute.String("traceql.query", query), - attribute.Int64("traceql.params.min_duration", int64(params.MinDuration)), - attribute.Int64("traceql.params.max_duration", int64(params.MaxDuration)), + xattribute.Duration("traceql.params.min_duration", params.MinDuration), + xattribute.Duration("traceql.params.max_duration", params.MaxDuration), xattribute.UnixNano("traceql.params.start", params.Start), xattribute.UnixNano("traceql.params.end", params.End), attribute.Int("traceql.params.limit", params.Limit), diff --git a/internal/xattribute/xattribute.go b/internal/xattribute/xattribute.go index c265d93e..266b1bc0 100644 --- a/internal/xattribute/xattribute.go +++ b/internal/xattribute/xattribute.go @@ -63,3 +63,8 @@ func UnixNano(k string, t time.Time) attribute.KeyValue { } return attribute.Int64(k, v) } + +// Duration returns [time.Duration] as integer attribute. +func Duration(k string, d time.Duration) attribute.KeyValue { + return attribute.Int64(k, d.Nanoseconds()) +}