Repository navigation
fix: annotations with a null time_end or a partial overlap are not shown on time series charts - #10027
Conversation
…shown on time series charts When the annotation table has a `time_end` column, the runtime required both `time` and `time_end` to fall inside the queried time range, so point annotations with a null `time_end` and ranges that only partly overlap the range were dropped. The filter now selects every annotation that overlaps the range, the chart anchors a range that starts before the first data point to it, and the `MetricsViewAnnotations` handler no longer writes the offset into the limit.
| if ( | ||
| a.endTime && | ||
| bucketStart.toMillis() < dataStartMs && | ||
| a.endTime.toMillis() >= dataStartMs |
There was a problem hiding this comment.
Why is the end time check needed? Wouldnt just bucketStart.toMillis() < dataStartMs be enough? (Assuming query already returns annotations that overlap with time range)
If this is still needed as a safeguard then the check doesnt match with backend, end > range_start vs end >= range_start
There was a problem hiding this comment.
The annotations and the time series are fetched independently and both keep their previous data while refetching, so after a time range change the previous annotations can briefly be grouped against the new data. The existing bucket.bucketMs < dataStartMs check below already handles that for point annotations; without the end check, the anchoring would promote a stale range that ended before the new window to the first data point. I changed it to > to match the query and explained this in the comment.
| if annotation.HasTimeEnd { | ||
| b.WriteString(" AND time_end >= ? AND time_end < ?") | ||
| args = append(args, start, end) | ||
| b.WriteString("time < ? AND (time >= ? OR time_end > ?)") |
There was a problem hiding this comment.
nit: invert to (time >= ? OR time_end > ?) AND time < ? so that it reads similar to the other query.
| bucketStart.toMillis() < dataStartMs && | ||
| a.endTime.toMillis() >= dataStartMs | ||
| ) { | ||
| bucketStart = data[0].ts; |
There was a problem hiding this comment.
Doesnt this need startOf(unit)?
time_endcolumn, the runtime required bothtimeandtime_endto fall inside the queried time range. Point annotations with a nulltime_endwere dropped, and range annotations that start before or end after the range were dropped as well.time < end AND (time >= start OR time_end > start)), and the chart anchors a range that starts before the first data point to it so the visible part of the range is drawn.MetricsViewAnnotationswrote the request offset intolimit.time_endis a point annotation.Note on the original report: scheduled refreshes do not run in dev deployments, so in a cloud edit session annotations anchored to
now()can fall outside the (stale) preview data and nothing renders even with this fix. That behaviour is unchanged here.Steps to reproduce
time_endcolumn where some rows have a nulltime_end:annotations:and open its explore with a time range that covers both rows.Closes APP-951
Checklist: