module documentation
Callback-based SDK metrics helpers.
Metrics are optional. The metrics and auth_metrics parameters accept an object with callback methods or a mapping of callback functions. Use Python snake_case names. camelCase aliases support compatibility 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 can be synchronous or asynchronous. A short timeout limits awaitable callback results. A running event loop schedules these callbacks. Synchronous code waits for them. The SDK ignores callback exceptions, so metrics do not change 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 | _discard |
Remove a completed fallback metric task from global tracking. |
| Function | _metric |
Undocumented |
| Function | _metric |
Undocumented |
| Function | _metric |
Undocumented |
| Function | _metric |
Undocumented |
| Function | _reset |
Drop inherited fallback tasks and replace a possibly locked lock. |
| Function | _run |
Undocumented |
| Function | _schedule |
Undocumented |
| Async Function | _swallow |
Undocumented |
| Constant | _CALLBACK |
Undocumented |
| Variable | _metric |
Undocumented |
| Variable | _metric |
Undocumented |
def auth_metrics_recorder(metrics:
AuthMetricsLike, provider: str) -> AuthMetricsRecorder:
(source)
¶
Create an auth metrics recorder, preserving shared callback cells.
def record_config_metric(metrics:
MetricsLike, kind: Literal[ 'config_load', 'credentials_resolve'], source: str, result: MetricResult, duration_seconds: float):
(source)
¶
Emit a config-reader metric.
def _apply_metrics_setter(bearer:
object, metrics: AuthMetricsLike, seen: set[ int] | None = None) -> bool:
(source)
¶
Undocumented
def _metric_callback(metrics:
object | None, names: tuple[ str, str]) -> Callable[ [ object], object] | None:
(source)
¶
Undocumented
def _schedule_metric_awaitable(awaitable:
Awaitable[ object], timeout: object = DEFAULT_METRIC_CALLBACK_TIMEOUT_SECONDS):
(source)
¶
Undocumented