Coverage for src/prisma/_metrics.py: 100%
25 statements
« prev ^ index » next coverage.py v7.2.7, created at 2024-08-27 18:25 +0000
« prev ^ index » next coverage.py v7.2.7, created at 2024-08-27 18:25 +0000
1# copied from https://github.com/prisma/prisma/blob/23d5ef0672372035a84552b6b457197ca19f486d/packages/client/src/runtime/core/engines/common/types/Metrics.ts
2from __future__ import annotations
4from typing import Dict, List, Generic, TypeVar, NamedTuple
6from pydantic import BaseModel
8from ._compat import GenericModel, model_rebuild
10__all__ = (
11 'Metrics',
12 'Metric',
13 'MetricHistogram',
14)
17_T = TypeVar('_T')
20# TODO: check if int / float is right
23class Metrics(BaseModel):
24 counters: List[Metric[int]]
25 gauges: List[Metric[float]]
26 histograms: List[Metric[MetricHistogram]]
29class Metric(GenericModel, Generic[_T]):
30 key: str
31 value: _T
32 labels: Dict[str, str]
33 description: str
36class MetricHistogram(BaseModel):
37 sum: float
38 count: int
39 buckets: List[HistogramBucket]
42class HistogramBucket(NamedTuple):
43 max_value: float
44 total_count: int
47model_rebuild(Metric)
48model_rebuild(Metrics)
49model_rebuild(MetricHistogram)