Callback-based SDK metrics helpers.
Metrics are opt-in. Public constructors that accept metrics or auth_metrics expect either an object with callback methods or a mapping whose values are callback functions. Python snake_case names are preferred and camelCase aliases are accepted for parity with the TypeScript SDK.
Full SDK/config metrics may implement:
- config_load(metric: ConfigMetric)
- credentials_resolve(metric: ConfigMetric)
Auth metrics may implement:
- token_acquire(metric: TokenAcquireMetric)
- token_lifetime(metric: TokenLifetimeMetric)
- token_refresh(metric: TokenRefreshMetric)
- cache_hit(metric: CacheMetric)
- cache_miss(metric: CacheMetric)
- cache_store(metric: CacheMetric)
- cache_refresh(metric: CacheMetric)
- cache_invalidate(metric: CacheMetric)
Callbacks may be synchronous or asynchronous. Awaitable callback results are bounded by a short timeout; they are scheduled when emitted from a running event loop and waited for when emitted from synchronous code. Callback exceptions are swallowed so metrics collection never changes request or authentication behavior.
| Class | |
Small mutable auth metrics recorder with a fixed provider label. |
| Class | |
Authentication cache metric payload. |
| Class | |
Config-reader metric payload. |
| Class | |
Optional metric callbacks with bounded awaitable callback execution. |
| Class | |
Token acquisition metric payload. |
| Class | |
Token lifetime metric payload. |
| Class | |
Token refresh metric payload. |
| Function | auth |
Return an auth provider label from a bearer hook. |
| Function | auth |
Create an auth metrics recorder, preserving shared callback cells. |
| Function | bind |
Attach auth metrics to bearer or return an instrumented wrapper. |
| Function | emit |
Call a metric callback if present and swallow callback failures. |
| Function | metric |
Return elapsed seconds since start. |
| Function | metric |
Return a monotonic start timestamp for metric duration measurement. |
| Function | record |
Emit a config-reader metric. |
| Function | sanitize |
Return a finite metric callback timeout bounded to SDK limits. |
| Constant | DEFAULT |
Default wall-clock cap for awaitable metric callback results. |
| Constant | MAX |
Highest accepted wall-clock cap for awaitable metric callback results. |
| Constant | METRIC |
Undocumented |
| Constant | METRIC |
Undocumented |
| Constant | MIN |
Lowest accepted wall-clock cap for awaitable metric callback results. |
| Type Alias | |
Synchronous or asynchronous metric callback. |
| Type Alias | |
Undocumented |
| Variable | |
Object or mapping with optional auth metric callbacks. |
| Variable | |
Object or mapping with optional config and auth metric callbacks. |
| Class | _ |
Undocumented |
| Class | _ |
No class docstring; 3/3 properties, 0/2 instance variable, 3/4 methods documented |
| Class | _ |
No class docstring; 1/1 property, 0/3 instance variable, 2/4 methods documented |
| Function | _apply |
Undocumented |
| Function | _metric |
Undocumented |
| Function | _metric |
Undocumented |
| Function | _metric |
Undocumented |
| Function | _metric |
Undocumented |
| Function | _run |
Undocumented |
| Function | _schedule |
Undocumented |
| Async Function | _swallow |
Undocumented |
| Constant | _CALLBACK |
Undocumented |
| Variable | _metric |
Undocumented |
AuthMetricsLike, provider: str) -> AuthMetricsRecorder:
(source)
¶
Create an auth metrics recorder, preserving shared callback cells.
MetricsLike, kind: Literal[ 'config_load', 'credentials_resolve'], source: str, result: MetricResult, duration_seconds: float):
(source)
¶
Emit a config-reader metric.
object, metrics: AuthMetricsLike, seen: set[ int] | None = None) -> bool:
(source)
¶
Undocumented
object | None, names: tuple[ str, str]) -> Callable[ [ object], object] | None:
(source)
¶
Undocumented
Awaitable[ object], timeout: object = DEFAULT_METRIC_CALLBACK_TIMEOUT_SECONDS):
(source)
¶
Undocumented