From 61ede82f3655ad5d257634fbb69bfb9aaea077d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn-Michael=20Miehe?= <40151420+ldericher@users.noreply.github.com> Date: Sat, 2 Sep 2023 15:13:49 +0000 Subject: [PATCH 1/3] default values for lists in SETTINGS --- kiwi_simple_metrics/settings/metric.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/kiwi_simple_metrics/settings/metric.py b/kiwi_simple_metrics/settings/metric.py index d1b5b68..9b3f71b 100644 --- a/kiwi_simple_metrics/settings/metric.py +++ b/kiwi_simple_metrics/settings/metric.py @@ -1,8 +1,8 @@ import math from typing import Any, Literal -from pydantic import (BaseModel, DirectoryPath, Field, FieldValidationInfo, - FilePath, field_validator) +from pydantic import (BaseModel, DirectoryPath, FieldValidationInfo, FilePath, + field_validator) class MetricSettings(BaseModel): @@ -81,7 +81,7 @@ class DiskMS(MetricSettings): count: int | None = 1 # paths to check for disk space - paths: list[DirectoryPath] = Field(default_factory=list) + paths: list[DirectoryPath] = [DirectoryPath("/")] class ExternalMS(MetricSettings): @@ -89,7 +89,7 @@ class ExternalMS(MetricSettings): threshold: float = 0 # path to executable files - executables: list[FilePath] = Field(default_factory=list) + executables: list[FilePath] = [] # wait at most this many seconds for each executable timeout: int = 60 From ec322276ddf84d15e8941134f5c7eb66486d4ae0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn-Michael=20Miehe?= <40151420+ldericher@users.noreply.github.com> Date: Sat, 2 Sep 2023 15:16:42 +0000 Subject: [PATCH 2/3] handle empty aggregate reports correctly --- .vscode/launch.json | 1 - kiwi_simple_metrics/metrics/_report.py | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 3049ac8..f018c2c 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -12,7 +12,6 @@ "env": { "METRIC__INTERVAL": "5", "METRIC__LOG__ENABLED": "True", - "METRIC__DISK__PATHS": "[\"/var\", \"/\", \"/dev\"]", "METRIC__EXTERNAL__EXECUTABLES": "[\"${workspaceFolder}/dummy-metric\"]", }, "justMyCode": true diff --git a/kiwi_simple_metrics/metrics/_report.py b/kiwi_simple_metrics/metrics/_report.py index e974ab1..5cf4044 100644 --- a/kiwi_simple_metrics/metrics/_report.py +++ b/kiwi_simple_metrics/metrics/_report.py @@ -102,6 +102,9 @@ class Report: reports = [data.report for data in get_data()] + if not reports: + return None + return cls( result=settings.report_outer.format( name=settings.name, From 71b8fe745412c5668bbdf643c095866b60a3dd85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn-Michael=20Miehe?= <40151420+ldericher@users.noreply.github.com> Date: Sat, 2 Sep 2023 15:17:23 +0000 Subject: [PATCH 3/3] disable external metric by default --- .vscode/launch.json | 1 + kiwi_simple_metrics/settings/metric.py | 1 + 2 files changed, 2 insertions(+) diff --git a/.vscode/launch.json b/.vscode/launch.json index f018c2c..e1aebf7 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -12,6 +12,7 @@ "env": { "METRIC__INTERVAL": "5", "METRIC__LOG__ENABLED": "True", + "METRIC__EXTERNAL__ENABLED": "True", "METRIC__EXTERNAL__EXECUTABLES": "[\"${workspaceFolder}/dummy-metric\"]", }, "justMyCode": true diff --git a/kiwi_simple_metrics/settings/metric.py b/kiwi_simple_metrics/settings/metric.py index 9b3f71b..dc597b8 100644 --- a/kiwi_simple_metrics/settings/metric.py +++ b/kiwi_simple_metrics/settings/metric.py @@ -86,6 +86,7 @@ class DiskMS(MetricSettings): class ExternalMS(MetricSettings): name: str = "External Metric" + enabled: bool = False threshold: float = 0 # path to executable files