Provider API reference¶
The provider base module is the stable import surface for integrations. It re-exports capability constants, time windows, result dataclasses, and snapshot types so provider packages do not need to depend on internal module locations.
Provider contract¶
django_prometric.providers.base.AnalyticsProvider ¶
Base class every analytics data source implements.
Subclasses should raise :class:ProviderError for anything the user needs to know about; other exceptions are treated as bugs.
configuration_warnings ¶
Startup warnings for a configured-but-under-scoped provider.
Returns a list of :class:django.core.checks.Warning, surfaced at server startup, for a provider that works yet reports an ambiguous scope — e.g. a whole Cloudflare zone, or a guessed Sentry project. Only consulted for providers that are :attr:is_configured.
exceeds_limit ¶
Whether the requested range is longer than this source can serve.
get_route_metrics ¶
route is a :class:django_prometric.routes.RouteInfo.
get_slowest_routes ¶
Routes ordered by p95 response time, slowest first.
get_security ¶
Firewall mitigations: total plus actions/sources/countries/paths breakdowns (lists of :class:BreakdownItem).
get_bots ¶
Human vs automated traffic: total requests, humans, bots, and a categories breakdown of the automated share.
get_seo ¶
Search-engine crawler activity: total crawler requests, engines breakdown, and the most crawled paths.
get_network ¶
Protocol mix: http_versions and tls breakdowns (lists of :class:BreakdownItem).
get_audience ¶
Real users' clients — bots excluded where the source can tell: browsers, os and devices breakdowns.
get_slowest_queries ¶
Database queries ordered by total time spent, worst first.
get_database_stats ¶
Database-level health: size, connections and lifetime counters.
get_index_stats ¶
Unused and most-used indexes: {"unused": [...], "used": [...]}.
get_backend ¶
Where application time goes: an ops breakdown of total time (values in ms) across database, templates, upstream calls, …
get_route_context ¶
Context for this provider's section on the route-detail page.
The default ships the full :class:RouteMetrics; providers with a different shape of per-route data override this together with route_template.
invalidate_cache ¶
Drop any cached upstream responses (used by the refresh button).
User-presentable errors¶
django_prometric.providers.base.ProviderError ¶
Bases: Exception
A user-presentable analytics failure.
kind lets the UI react appropriately: config – provider is not (fully) configured auth – credentials rejected network – upstream unreachable quota – plan/time-range limit hit plan – feature not included in the current plan error – anything else
Time windows¶
django_prometric.providers.base.Period dataclass ¶
from_request classmethod ¶
Build from GET/POST params: a preset period key, or a free from/to date range (period=custom).
Core result types¶
django_prometric.providers.base.OverviewStats dataclass ¶
OverviewStats(requests=0, unique_visitors=None, page_views=None, bandwidth_bytes=None, cached_requests=None, threats=None, errors=None, avg_response_ms=None)
django_prometric.providers.base.PathStat dataclass ¶
django_prometric.providers.base.PerformanceStats dataclass ¶
PerformanceStats(p50_ms=None, p75_ms=None, p95_ms=None, p99_ms=None, avg_ms=None, failure_rate=None, requests=None)
django_prometric.providers.base.RoutePerformance dataclass ¶
RoutePerformance(transaction, requests=0, p50_ms=None, p75_ms=None, p95_ms=None, p99_ms=None, failure_rate=None)
Response-time percentiles of one route/transaction, app-side.
django_prometric.providers.base.RouteMetrics dataclass ¶
RouteMetrics(requests=0, visits=None, bandwidth_bytes=None, errors=None, last_seen=None, countries=list(), statuses=list(), methods=list(), cache=list(), timeseries=list(), performance=None)
Application and database result types¶
django_prometric.providers.base.QueryStat dataclass ¶
One database query aggregated across its calls, slowest first.
django_prometric.providers.base.IssueStat dataclass ¶
One grouped application error.
django_prometric.providers.base.DatabaseStats dataclass ¶
DatabaseStats(size_bytes=0, table_count=0, index_count=0, row_estimate=0, dead_estimate=0, connections=dict(), max_connections=None, commits=None, rollbacks=None, cache_hit_ratio=None, deadlocks=None, temp_bytes=None)
Database-level health, mixing point-in-time state and lifetime counters.
Point-in-time fields are correct at read time. The counter fields are wrapped in :class:Cumulative by the provider so the UI can flag them as accumulated since the last statistics reset.
django_prometric.providers.base.TableStat dataclass ¶
One user table's size, row estimates and scan activity.
django_prometric.providers.base.IndexStat dataclass ¶
One index's size and use. scans == 0 means it was never used.
django_prometric.providers.base.Cumulative dataclass ¶
A counter accumulated since since, not scoped to the query window.
Providers wrap a value in this to tell the UI the number is a lifetime counter (last reset at since), not a per-period figure — so the UI can mark it with a "since …" badge (see components/_cumulative.html) rather than pretend it matches the selected period. When a provider later windows the counter (see :class:CounterSampler, Phase 2), it returns a plain number instead and the badge disappears with no template change.
django_prometric.providers.base.Insight dataclass ¶
One actionable finding a provider derived from its data.
title states what was found, detail backs it with numbers, and action says what to do about it. Good findings confirm health and carry no action.
django_prometric.providers.base.Notice dataclass ¶
A side note a provider left while answering — e.g. a clamped window.
warn notices flag that the data shown differs from what was asked for; info ones are purely informative.