Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store metrics queueTime in seconds #5052

Merged
merged 2 commits into from
Jan 6, 2022
Merged

Conversation

ssncferreira
Copy link
Contributor

@ssncferreira ssncferreira commented Jan 5, 2022

What this PR does / why we need it:

metrics.go statistic queueTime was introduced in #4949. In this PR, the metric was stored in nanoseconds as int64:

QueueTime int64 `protobuf:"varint,6,opt,name=queueTime,proto3" json:"queueTime"`

However, the statistics result struct:

type Result struct {
Summary Summary `protobuf:"bytes,1,opt,name=summary,proto3" json:"summary"`
Querier Querier `protobuf:"bytes,2,opt,name=querier,proto3" json:"querier"`
Ingester Ingester `protobuf:"bytes,3,opt,name=ingester,proto3" json:"ingester"`
}

is used both for internal calculations and for API responses. Grafana uses these returned statistics from the API and expects time values to be returned in seconds as float. This PR converts the queueTime metric to be stored in seconds as float.
By storing time values in seconds as float64, the minimum value second we can store is 2.2E-308 (range for float64), which is 2.2E-299 nanoseconds. This means that we won’t lose precision when logging values less than a second or when sending the API response.

Special notes for your reviewer:

Checklist

  • Documentation updated
  • Tests updated
  • Add an entry in the CHANGELOG.md about the changes.

@ssncferreira ssncferreira self-assigned this Jan 5, 2022
@ssncferreira ssncferreira marked this pull request as ready for review January 5, 2022 18:26
@ssncferreira ssncferreira requested review from KMiller-Grafana and a team as code owners January 5, 2022 18:26
@ssncferreira ssncferreira requested a review from owen-d January 5, 2022 18:26
Copy link
Contributor

@dannykopping dannykopping left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍
Left a non-blocking question; if you'd prefer to not implement what I suggested, let me know and I'll merge

pkg/logqlmodel/stats/context.go Outdated Show resolved Hide resolved
* Helper function to convert seconds to nanoseconds
@ssncferreira ssncferreira force-pushed the metrics_queue_time_seconds branch from c35ac90 to d90902a Compare January 6, 2022 11:23
@dannykopping dannykopping merged commit 191a8a6 into main Jan 6, 2022
@dannykopping dannykopping deleted the metrics_queue_time_seconds branch January 6, 2022 11:46
@ssncferreira ssncferreira linked an issue Jan 7, 2022 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Log time in queue per request (metrics.go?)
2 participants