From 862e78eec0436ce5a767a11ac54cbb6c939d40a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn-Michael=20Miehe?= <40151420+ldericher@users.noreply.github.com> Date: Thu, 31 Aug 2023 22:25:18 +0000 Subject: [PATCH] Settings.separator --- .vscode/launch.json | 2 +- kiwi_simple_metrics/metrics/_report.py | 6 +++--- kiwi_simple_metrics/settings.py | 6 +++++- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 5872269..f702240 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -10,7 +10,7 @@ "request": "launch", "module": "kiwi_simple_metrics.main", "env": { - "METRIC_DISK__PATHS": "[\"/var\", \"/\", \"/dev\"]", + "METRIC__DISK__PATHS": "[\"/var\", \"/\", \"/dev\"]", }, "justMyCode": true } diff --git a/kiwi_simple_metrics/metrics/_report.py b/kiwi_simple_metrics/metrics/_report.py index 3ccb57b..c609f1b 100644 --- a/kiwi_simple_metrics/metrics/_report.py +++ b/kiwi_simple_metrics/metrics/_report.py @@ -1,7 +1,7 @@ from dataclasses import dataclass from typing import Any, Callable, Iterator, Self -from ..settings import MetricSettings +from ..settings import SETTINGS, MetricSettings @dataclass(slots=True, kw_only=True) @@ -43,7 +43,7 @@ class Report: ] return cls( - result=", ".join( + result=SETTINGS.separator.join( report.result for report in reports ), @@ -70,7 +70,7 @@ class Report: return cls( result=settings.report_outer.format( name=settings.name, - inner=", ".join( + inner=SETTINGS.separator.join( report.result for report in reports[:settings.count] ), diff --git a/kiwi_simple_metrics/settings.py b/kiwi_simple_metrics/settings.py index 96d8fc2..3d2bf11 100644 --- a/kiwi_simple_metrics/settings.py +++ b/kiwi_simple_metrics/settings.py @@ -84,10 +84,14 @@ class DiskMS(MetricSettings): class Settings(BaseSettings): model_config = SettingsConfigDict( - env_prefix="METRIC_", + env_prefix="METRIC__", env_nested_delimiter="__", ) + # separates metrics and values in reports + separator: str = ", " + + # metrics settings cpu: CpuMS = CpuMS() memory: MemoryMS = MemoryMS() disk: DiskMS = DiskMS()