Skip to content

Commit

Permalink
feat(xattribute): add Duration to pass duration attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
tdakkota committed Jun 7, 2024
1 parent b8b29ff commit 8c3dad8
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 9 deletions.
8 changes: 4 additions & 4 deletions internal/chstorage/querier_traces.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
),
Expand Down Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion internal/logql/logqlengine/engine_literal_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
))
Expand Down
2 changes: 1 addition & 1 deletion internal/logql/logqlengine/engine_log_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
))
Expand Down
2 changes: 1 addition & 1 deletion internal/logql/logqlengine/engine_metric_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
))
Expand Down
4 changes: 2 additions & 2 deletions internal/traceql/traceqlengine/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
5 changes: 5 additions & 0 deletions internal/xattribute/xattribute.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}

0 comments on commit 8c3dad8

Please sign in to comment.