Skip to content

Inconsistent metric status when collector is down #10328

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

Open
fniessink opened this issue Nov 20, 2024 · 1 comment
Open

Inconsistent metric status when collector is down #10328

fniessink opened this issue Nov 20, 2024 · 1 comment
Assignees

Comments

@fniessink
Copy link
Member

fniessink commented Nov 20, 2024

Describe the bug
When the collector is down, dashboard cards and subject tables may seem to be inconsistent.

When the collector is down, no new measurements are made. After a while the frontend will start to notice this and mark the status of metrics as unknown in the dashboard. However, in the subject table, the last know status of metrics will still be shown (e.g. a metric meeting its target is still green). The measurement value will get a red background and the popup will explain to the user why the measurement value has the red background.

Expected behaviour
When the above scenario happens, mark the metrics as unknown (white) in the subject table. Check that the popup explains that the collector hasn't measured the metric for more than 1 (2?) hours.

CC: @Sebastiaan127001

@fniessink fniessink added the Bug label Nov 20, 2024
@fniessink fniessink moved this from Inbox to To be refined in Quality-time backlog Nov 20, 2024
@fniessink fniessink moved this from Refinement in progress to Ready in Quality-time backlog Nov 21, 2024
@fniessink fniessink removed the Bug label Jan 17, 2025
@fniessink fniessink self-assigned this Apr 14, 2025
@fniessink fniessink moved this from Ready to Development in progress in Quality-time backlog Apr 14, 2025
@fniessink fniessink changed the title When the collector is down, dashboard cards and subject tables may seem to be inconsistent Inconsistent metric status when collector is down Apr 14, 2025
@fniessink
Copy link
Member Author

The dashboard (when showing one date) determines the status of metrics by looking up the latest measurement that has today's date:

export function measurementOnDate(date, measurements, metricUuid) {
    const isoDateString = date.toISOString().split("T")[0]
    return measurements?.find((m) => {
        return (
            m.metric_uuid === metricUuid &&
            m.start.split("T")[0] <= isoDateString &&
            isoDateString <= m.end.split("T")[0]
        )
    })
}

function metricStatusOnDate(metricUuid, metric, measurements, date, dataModel) {
    const measurement = measurementOnDate(date, measurements, metricUuid)
    const scale = getMetricScale(metric, dataModel)
    return measurement?.[scale]?.status ?? "unknown"
}

The subject table (when showing one date) determines the status of the metrics by looking at the metrics's status attribute which is set by the API-server based on the latest measurement when returning the report:

class Metric(dict):
    """Class representing a metric."""

    def status(self, last_measurement: Measurement | None) -> Status | None:
        """Determine the metric status."""
        if last_measurement and (status := last_measurement.status()):
            return status
        return "debt_target_met" if self.accept_debt() and not self.debt_end_date_passed() else None

    def summarize(self, measurements: list[Measurement], **kwargs) -> dict:
        """Add a summary of the metric to the report."""
        latest_measurement = measurements[-1] if measurements else None
        summary = dict(self)
        summary["scale"] = self.scale()
        summary["status"] = self.status(latest_measurement)
        summary["status_start"] = latest_measurement.status_start() if latest_measurement else None
        summary["latest_measurement"] = latest_measurement.summarize_latest() if latest_measurement else None
        summary["recent_measurements"] = [measurement.summarize() for measurement in measurements]
        if latest_measurement:
            summary["issue_status"] = self.issue_statuses(latest_measurement)
        summary.update(kwargs)
        return summary

This means that the metric status as reported by the dashboard and by the subject table will differ if the latest measurement's date is not today.

To prevent this discrepancy, the dashboard and subject table should determine the status in the same way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Development in progress
Development

When branches are created from issues, their pull requests are automatically linked.

1 participant