Build your own MetricCollector plugins to extend pyqual with custom metrics.
performance_collector.py— Custom collector that reads benchmark/performance JSONcode_health_collector.py— Composite collector combining multiple code health signalspyqual.yaml— Pipeline config using custom plugin metrics
cd examples/custom_plugins
# Register the plugin (from project root)
python performance_collector.py # self-test mode
python code_health_collector.py # self-test mode- Subclass
MetricCollectorand implementcollect(workdir) -> dict[str, float] - Register with
PluginRegistry.register(YourCollector) - Add gate thresholds to
pyqual.yamlusing the metric names your collector produces
from pyqual.plugins import MetricCollector, PluginRegistry, PluginMetadata
class MyCollector(MetricCollector):
name = "my-tool"
metadata = PluginMetadata(
name="my-tool",
description="What it does",
version="1.0.0",
tags=["custom"],
)
def collect(self, workdir: Path) -> dict[str, float]:
# Read from workdir/.pyqual/<your-file>.json
# Return dict of metric_name -> float_value
return {}
PluginRegistry.register(MyCollector)| Metric | Description | Source |
|---|---|---|
perf_p50_ms |
Median latency (ms) | .pyqual/performance.json |
perf_p99_ms |
99th percentile latency (ms) | .pyqual/performance.json |
perf_rps |
Requests per second | .pyqual/performance.json |
perf_error_rate |
Error rate (%) | .pyqual/performance.json |
| Metric | Description | Source |
|---|---|---|
health_score |
Weighted composite score (0-100) | computed |
health_tech_debt_hours |
Estimated tech debt (hours) | .pyqual/code_health.json |
health_todo_count |
Open TODO count | .pyqual/code_health.json |
health_dead_code_pct |
Dead code percentage | .pyqual/code_health.json |
See pyqual.yaml for complete configuration with custom plugins.