Skip to content

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

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.

slug class-attribute instance-attribute

slug = 'base'

verbose_name class-attribute instance-attribute

verbose_name = _('Analytics')

kind class-attribute instance-attribute

kind = _('Analytics')

max_period_days class-attribute instance-attribute

max_period_days = None

route_template class-attribute instance-attribute

route_template = ''

notices instance-attribute

notices = []

is_configured property

is_configured

configuration_help

configuration_help()

Shown on the onboarding screen when not configured.

configuration_warnings

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.

description

description()

Short data-source line for the dashboard header.

capabilities

capabilities()

add_notice

add_notice(message, level=NOTICE_INFO)

exceeds_limit

exceeds_limit(period)

Whether the requested range is longer than this source can serve.

limit_period

limit_period(period)

Clamp the period to this source's reach, leaving a notice.

get_overview

get_overview(period)

get_timeseries

get_timeseries(period)

get_path_stats

get_path_stats(period, limit=1500)

get_breakdown

get_breakdown(dimension, period, limit=12)

get_route_metrics

get_route_metrics(route, period)

route is a :class:django_prometric.routes.RouteInfo.

get_performance

get_performance(period)

Site-wide response-time percentiles, when available.

get_slowest_routes

get_slowest_routes(period, limit=10)

Routes ordered by p95 response time, slowest first.

get_top_issues

get_top_issues(period, limit=10)

Most frequent grouped application errors.

get_security

get_security(period)

Firewall mitigations: total plus actions/sources/countries/paths breakdowns (lists of :class:BreakdownItem).

get_bots

get_bots(period)

Human vs automated traffic: total requests, humans, bots, and a categories breakdown of the automated share.

get_seo

get_seo(period)

Search-engine crawler activity: total crawler requests, engines breakdown, and the most crawled paths.

get_network

get_network(period)

Protocol mix: http_versions and tls breakdowns (lists of :class:BreakdownItem).

get_audience

get_audience(period)

Real users' clients — bots excluded where the source can tell: browsers, os and devices breakdowns.

get_slowest_queries

get_slowest_queries(period, limit=8)

Database queries ordered by total time spent, worst first.

get_database_stats

get_database_stats(period)

Database-level health: size, connections and lifetime counters.

get_table_stats

get_table_stats(period, limit=10)

The largest user tables, biggest first.

get_index_stats

get_index_stats(period, limit=10)

Unused and most-used indexes: {"unused": [...], "used": [...]}.

get_backend

get_backend(period)

Where application time goes: an ops breakdown of total time (values in ms) across database, templates, upstream calls, …

get_insights

get_insights(period)

Actionable findings this source can derive from its own data.

get_route_context

get_route_context(route, period)

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

invalidate_cache()

Drop any cached upstream responses (used by the refresh button).

User-presentable errors

django_prometric.providers.base.ProviderError

ProviderError(message, kind='error')

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

message instance-attribute

message = message

kind instance-attribute

kind = kind

Time windows

django_prometric.providers.base.Period dataclass

Period(key, label, start, end)

key instance-attribute

key

label instance-attribute

label

start instance-attribute

start

end instance-attribute

end

days property

days

is_custom property

is_custom

last_day property

last_day

The inclusive final day of the window, as shown in date inputs.

from_key classmethod

from_key(key)

from_request classmethod

from_request(params)

Build from GET/POST params: a preset period key, or a free from/to date range (period=custom).

custom classmethod

custom(start, end)

as_query

as_query()

URL query fragment that reproduces this period.

clamped_to

clamped_to(max_days)

The most recent max_days slice of this period.

choices classmethod

choices()

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.TimeseriesPoint dataclass

TimeseriesPoint(label, requests=0)

django_prometric.providers.base.PathStat dataclass

PathStat(path, requests=0, bandwidth_bytes=0, visits=0)

django_prometric.providers.base.BreakdownItem dataclass

BreakdownItem(label, value=0, share=0.0)

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

QueryStat(query, calls=0, avg_ms=None, total_ms=None)

One database query aggregated across its calls, slowest first.

django_prometric.providers.base.IssueStat dataclass

IssueStat(title, culprit='', events=0, users=0, permalink='')

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

TableStat(name, size_bytes=0, rows=0, dead_rows=0, seq_scans=0, idx_scans=0, last_autovacuum=None)

One user table's size, row estimates and scan activity.

django_prometric.providers.base.IndexStat dataclass

IndexStat(name, table='', size_bytes=0, scans=0)

One index's size and use. scans == 0 means it was never used.

django_prometric.providers.base.Cumulative dataclass

Cumulative(value=None, since=None)

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

Insight(severity, title, detail='', action='')

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

Notice(message, level=NOTICE_INFO)

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.