mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-02-18 17:43:54 +08:00
* sunnylink: add statsd process and related telemetry logging infrastructure - Introduced `statsd_sp` process for handling Sunnylink-specific stats. - Enhanced metrics logging with improved directory structure and data handling. * sunnylink: re-enable and refine stat_handler for telemetry processing - Reactivated `stat_handler` thread with improved path handling. - Made `stat_handler` more flexible by allowing directory injection. * statsd: fix formatting issue in telemetry string generation - Corrected missing comma between `sunnylink_dongle_id` and `comma_dongle_id`. * update statsd_sp process configuration for enhanced readiness logic - Modified `statsd_sp` initialization to include `always_run` alongside `sunnylink_ready_shim`. - Ensures robust process activation conditions. * refactor(statsd): enhance and unify StatLogSP implementation - Replaced custom `StatLogSP` in sunnylink with centralized implementation from `system.statsd`. - Ensures consistent logic for StatLogSP handling across modules. * fix * refactor(statsd): add intercept parameter to StatLogSP for configurable logging - Introduced optional `intercept` parameter to `StatLogSP` to manage `comma_statlog` initialization. - Updated usage in `sunnylink` to disable interception where unnecessary. * Dont complain * feat(statsd): add raw metric type and SunnyPilot-specific stats collection - Introduced `METRIC_TYPE.RAW` for base64-encoded raw data metrics. - Added `sp_stats` thread to export SunnyPilot params as raw metrics. - Enhanced telemetry handling with decoding and serialization updates. * refactor(statsd): improve `sp_stats` error handling and param processing - Enhanced exception handling for `params.get` to prevent crashes. - Added support for nested dict values to be included in stats. * refactor(statsd): adjust imports and minor code formatting updates - Updated `Ratekeeper` import path for consistency with the `openpilot` module structure. - Fixed minor formatting for improved readability. * refactor(statsd): update typings and remove unused NoReturn annotation - Removed unnecessary `NoReturn` typing for `stats_main` to simplify function definition. - Adjusted `get_influxdb_line_raw` to refine typing for `value` parameter. * cleanup * init * init * slightly more * staticmethod * handle them all * get them models * log with route * more * car * Revert "car" This reverts commitfe1c90cf4d. * handle capnp * Revert "handle capnp" This reverts commitc5aea68803. * 1 more time * Revert "1 more time" This reverts commita364474fa5. * Cleaning to expose wider * feat(interfaces, statsd): log car params to stats system - Added `STATSLOGSP` import and logging to capture `carFingerprint` in metrics. - Improved error handling in `get_influxdb_line_raw` for robust metric generation. * refactor(interfaces): streamline car params logging to stats - Simplified logging by directly converting `CP` to a dictionary. - Removed legacy stats aggregation for clarity. * feat(sunnylink): enable compression for stats in SunnyLink - Added optional compression for stats payload to support large data. - Updated `stat_handler` to handle compression and base64 encoding. * fix(statsd): filter complex types in `get_influxdb_line_raw` - Skips unsupported types (dict, list, bytes) to prevent formatting errors. - Simplifies type annotation for `value` parameter. * fix(statsd): use `json.dumps` for string conversion in `get_influxdb_line_raw` - Ensures proper handling of special characters in values. - Prevents potential formatting issues with raw `str()` conversion. * refactor(interfaces, statsd): update parameter keys for stats logging - Renamed logged keys for better clarity (`sunnypilot_params` → `sunnypilot.car_params`, `device_params`). - Ensures consistency across data logs. * bet --------- Co-authored-by: Jason Wen <haibin.wen3@gmail.com>
98 lines
2.4 KiB
Python
98 lines
2.4 KiB
Python
import os
|
|
import platform
|
|
from pathlib import Path
|
|
|
|
from openpilot.system.hardware import PC
|
|
|
|
DEFAULT_DOWNLOAD_CACHE_ROOT = "/tmp/comma_download_cache"
|
|
|
|
class Paths:
|
|
@staticmethod
|
|
def comma_home() -> str:
|
|
return os.path.join(str(Path.home()), ".comma" + os.environ.get("OPENPILOT_PREFIX", ""))
|
|
|
|
@staticmethod
|
|
def log_root() -> str:
|
|
if os.environ.get('LOG_ROOT', False):
|
|
return os.environ['LOG_ROOT']
|
|
elif PC:
|
|
return str(Path(Paths.comma_home()) / "media" / "0" / "realdata")
|
|
else:
|
|
return '/data/media/0/realdata/'
|
|
|
|
@staticmethod
|
|
def log_root_external() -> str:
|
|
return '/mnt/external_realdata/'
|
|
|
|
@staticmethod
|
|
def swaglog_root() -> str:
|
|
if PC:
|
|
return os.path.join(Paths.comma_home(), "log")
|
|
else:
|
|
return "/data/log/"
|
|
|
|
@staticmethod
|
|
def swaglog_ipc() -> str:
|
|
return "ipc:///tmp/logmessage" + os.environ.get("OPENPILOT_PREFIX", "")
|
|
|
|
@staticmethod
|
|
def download_cache_root() -> str:
|
|
if os.environ.get('COMMA_CACHE', False):
|
|
return os.environ['COMMA_CACHE'] + "/"
|
|
return DEFAULT_DOWNLOAD_CACHE_ROOT + os.environ.get("OPENPILOT_PREFIX", "") + "/"
|
|
|
|
@staticmethod
|
|
def persist_root() -> str:
|
|
if PC:
|
|
return os.path.join(Paths.comma_home(), "persist")
|
|
else:
|
|
return "/persist/"
|
|
|
|
@staticmethod
|
|
def stats_root() -> str:
|
|
if PC:
|
|
return str(Path(Paths.comma_home()) / "stats")
|
|
else:
|
|
return "/data/stats/"
|
|
|
|
@staticmethod
|
|
def stats_sp_root() -> str:
|
|
if PC:
|
|
return str(Path(Paths.comma_home()) / "stats")
|
|
else:
|
|
return "/data/stats_sp/"
|
|
|
|
@staticmethod
|
|
def config_root() -> str:
|
|
if PC:
|
|
return Paths.comma_home()
|
|
else:
|
|
return "/tmp/.comma"
|
|
|
|
@staticmethod
|
|
def shm_path() -> str:
|
|
if PC and platform.system() == "Darwin":
|
|
return "/tmp" # This is not really shared memory on macOS, but it's the closest we can get
|
|
return "/dev/shm"
|
|
|
|
@staticmethod
|
|
def model_root() -> str:
|
|
if PC:
|
|
return str(Path(Paths.comma_home()) / "media" / "0" / "models")
|
|
else:
|
|
return "/data/media/0/models"
|
|
|
|
@staticmethod
|
|
def crash_log_root() -> str:
|
|
if PC:
|
|
return str(Path(Paths.comma_home()) / "community" / "crashes")
|
|
else:
|
|
return "/data/community/crashes"
|
|
|
|
@staticmethod
|
|
def mapd_root() -> str:
|
|
if PC:
|
|
return str(Path(Paths.comma_home()) / "media" / "0" / "osm")
|
|
else:
|
|
return "/data/media/0/osm"
|