diff --git a/api/organisations/migrations/0062_add_usage_reporting_state.py b/api/organisations/migrations/0062_add_usage_reporting_state.py new file mode 100644 index 000000000000..aecf67c3fe4f --- /dev/null +++ b/api/organisations/migrations/0062_add_usage_reporting_state.py @@ -0,0 +1,37 @@ +# Generated by Django 5.2.18 on 2026-11-12 11:08 + +import django.db.models.deletion +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("organisations", "0061_add_user_organisation_is_active"), + ] + + operations = [ + migrations.CreateModel( + name="UsageReportingState", + fields=[ + ( + "id", + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("reported_until", models.DateTimeField()), + ( + "organisation", + models.OneToOneField( + on_delete=django.db.models.deletion.CASCADE, + related_name="usage_reporting_state", + to="organisations.organisation", + ), + ), + ], + ), + ] diff --git a/api/organisations/models.py b/api/organisations/models.py index c58f6907702c..834b63e195a3 100644 --- a/api/organisations/models.py +++ b/api/organisations/models.py @@ -698,3 +698,14 @@ class tracks the actual rounded count of API calls that are created_at = models.DateTimeField(null=True, auto_now_add=True) updated_at = models.DateTimeField(null=True, auto_now=True) + + +class UsageReportingState(models.Model): + """ + End of the last window pushed successfully + """ + + organisation = models.OneToOneField( + Organisation, on_delete=models.CASCADE, related_name="usage_reporting_state" + ) + reported_until = models.DateTimeField() diff --git a/api/organisations/tasks.py b/api/organisations/tasks.py index 503584f59f28..d5c783046eea 100644 --- a/api/organisations/tasks.py +++ b/api/organisations/tasks.py @@ -97,7 +97,7 @@ def update_organisation_subscription_information_cache_recurring() -> None: update_organisation_subscription_information_cache() -@register_recurring_task(run_every=timedelta(hours=1)) +@register_recurring_task(run_every=timedelta(hours=24)) def push_usage_to_control_plane() -> None: push_usage_snapshots() diff --git a/api/organisations/usage_reporting/mappers.py b/api/organisations/usage_reporting/mappers.py index cb12d567f6b0..2b885435585b 100644 --- a/api/organisations/usage_reporting/mappers.py +++ b/api/organisations/usage_reporting/mappers.py @@ -1,8 +1,7 @@ import base64 -from datetime import timedelta +from datetime import datetime from common.core.utils import get_version -from django.utils import timezone from app_analytics.analytics_db_service import get_usage_data_for_window from app_analytics.dataclasses import UsageData @@ -55,15 +54,15 @@ def map_project_usage_data_to_project_usage( return rows[:MAX_PROJECT_USAGE_ROWS] -def map_organisation_to_usage_snapshot(organisation: Organisation) -> UsageSnapshot: - hour_end = timezone.now().replace(minute=0, second=0, microsecond=0) - hour_start = hour_end - timedelta(hours=1) +def map_organisation_to_usage_snapshot( + organisation: Organisation, window_start: datetime, window_end: datetime +) -> UsageSnapshot: seat_count = organisation.num_seats instance_version = get_version() - usage_data = get_usage_data_for_window(organisation, hour_start, hour_end) + usage_data = get_usage_data_for_window(organisation, window_start, window_end) usage_data_by_project_id = { project.id: get_usage_data_for_window( - organisation, hour_start, hour_end, project_id=project.id + organisation, window_start, window_end, project_id=project.id ) for project in organisation.projects.all() } @@ -71,7 +70,7 @@ def map_organisation_to_usage_snapshot(organisation: Organisation) -> UsageSnaps # No data access past this point! return UsageSnapshot( - timestamp=hour_start, + timestamp=window_start, seat_count=seat_count, api_call_total=map_usage_data_to_total_api_calls(usage_data), api_call_breakdown=map_usage_data_to_api_call_breakdown(usage_data), diff --git a/api/organisations/usage_reporting/services.py b/api/organisations/usage_reporting/services.py index 7f5d41369d68..c8b39153774b 100644 --- a/api/organisations/usage_reporting/services.py +++ b/api/organisations/usage_reporting/services.py @@ -1,12 +1,16 @@ import dataclasses import json +from datetime import datetime, timedelta import requests import structlog from django.conf import settings from django.core.serializers.json import DjangoJSONEncoder +from django.utils import timezone +from requests.adapters import HTTPAdapter +from urllib3 import Retry -from organisations.models import Organisation +from organisations.models import Organisation, UsageReportingState from organisations.usage_reporting.dataclasses import UsageSnapshot from organisations.usage_reporting.mappers import ( map_organisation_to_usage_snapshot, @@ -17,16 +21,35 @@ USAGE_ENDPOINT_PATH = "/v1/public/usage" REQUEST_TIMEOUT_SECONDS = 30 +RETRY_POLICY = Retry( + total=3, + backoff_factor=1, + status_forcelist=(429, 500, 502, 503, 504), + allowed_methods={"POST"}, + raise_on_status=False, +) def get_licensed_organisations() -> list[Organisation]: if not settings.LICENSING_INSTALLED: return [] return list( - Organisation.objects.filter(licence__isnull=False).select_related("licence") + Organisation.objects.filter(licence__isnull=False).select_related( + "licence", "usage_reporting_state" + ) ) +def get_window_start(organisation: Organisation, window_end: datetime) -> datetime: + try: + return organisation.usage_reporting_state.reported_until + except UsageReportingState.DoesNotExist: + return UsageReportingState.objects.create( + organisation=organisation, + reported_until=window_end - timedelta(hours=24), + ).reported_until + + def push_snapshot( *, base_url: str, @@ -42,17 +65,14 @@ def push_snapshot( } body = json.dumps(dataclasses.asdict(snapshot), cls=DjangoJSONEncoder) - response = requests.post( - url, - data=body, - headers=headers, - timeout=REQUEST_TIMEOUT_SECONDS, - ) + with requests.Session() as session: + session.mount("https://", HTTPAdapter(max_retries=RETRY_POLICY)) + response = session.post( + url=url, data=body, headers=headers, timeout=REQUEST_TIMEOUT_SECONDS + ) - if response.ok: + response.raise_for_status() logger.info("snapshot.pushed", status_code=response.status_code) - else: - logger.warning("snapshot.push_failed", status_code=response.status_code) def push_usage_snapshots() -> None: @@ -63,13 +83,30 @@ def push_usage_snapshots() -> None: logger.debug("run.skipped", reason="no_licensed_organisations") return + window_end = timezone.now().replace(minute=0, second=0, microsecond=0) + for organisation in organisations: with structlog.contextvars.bound_contextvars(organisation__id=organisation.id): try: + window_start = get_window_start(organisation, window_end) + if window_start >= window_end: + # The control plane drops snapshots with a repeated timestamp, + # so an empty push would make the next window collide and be lost. + logger.debug("snapshot.skipped", reason="empty_window") + continue + push_snapshot( base_url=base_url, - snapshot=map_organisation_to_usage_snapshot(organisation), + snapshot=map_organisation_to_usage_snapshot( + organisation=organisation, + window_start=window_start, + window_end=window_end, + ), signature_b64=organisation.licence.signature, ) - except Exception: - logger.exception("snapshot.errored") + + UsageReportingState.objects.filter( + organisation=organisation, reported_until__lt=window_end + ).update(reported_until=window_end) + except Exception as e: + logger.exception("snapshot.errored", reason=e) diff --git a/api/tests/unit/organisations/usage_reporting/test_mappers.py b/api/tests/unit/organisations/usage_reporting/test_mappers.py index 8a3cb1c2ffcd..0a7d3c8f35a9 100644 --- a/api/tests/unit/organisations/usage_reporting/test_mappers.py +++ b/api/tests/unit/organisations/usage_reporting/test_mappers.py @@ -1,6 +1,5 @@ from datetime import datetime, timezone -import pytest from pytest_mock import MockerFixture from app_analytics.dataclasses import UsageData @@ -16,8 +15,10 @@ ) from projects.models import Project +WINDOW_START = datetime(2026, 6, 17, 9, 0, 0, tzinfo=timezone.utc) +WINDOW_END = datetime(2026, 6, 18, 9, 0, 0, tzinfo=timezone.utc) + -@pytest.mark.freeze_time("2026-06-18T09:30:00+00:00") def test_map_organisation_to_usage_snapshot__with_usage__returns_populated_snapshot( organisation: Organisation, project: Project, @@ -25,7 +26,7 @@ def test_map_organisation_to_usage_snapshot__with_usage__returns_populated_snaps ) -> None: # Given mocker.patch.object(mappers, "get_version", return_value="2.142.3") - mocker.patch.object( + mocked_get_usage_data = mocker.patch.object( mappers, "get_usage_data_for_window", return_value=[ @@ -40,11 +41,13 @@ def test_map_organisation_to_usage_snapshot__with_usage__returns_populated_snaps ) # When - snapshot = map_organisation_to_usage_snapshot(organisation) + snapshot = map_organisation_to_usage_snapshot( + organisation, window_start=WINDOW_START, window_end=WINDOW_END + ) # Then assert snapshot == UsageSnapshot( - timestamp=datetime(2026, 6, 18, 8, 0, 0, tzinfo=timezone.utc), + timestamp=WINDOW_START, seat_count=organisation.num_seats, api_call_total=10, api_call_breakdown=ApiCallBreakdown( @@ -54,9 +57,12 @@ def test_map_organisation_to_usage_snapshot__with_usage__returns_populated_snaps instance_version="2.142.3", project_usage=[ProjectUsage(project_id=project.id, api_call_count=10)], ) + mocked_get_usage_data.assert_any_call(organisation, WINDOW_START, WINDOW_END) + mocked_get_usage_data.assert_any_call( + organisation, WINDOW_START, WINDOW_END, project_id=project.id + ) -@pytest.mark.freeze_time("2026-06-18T09:30:00+00:00") def test_map_organisation_to_usage_snapshot__no_analytics__returns_zeroed_snapshot( organisation: Organisation, project: Project, @@ -67,11 +73,13 @@ def test_map_organisation_to_usage_snapshot__no_analytics__returns_zeroed_snapsh mocker.patch.object(mappers, "get_usage_data_for_window", return_value=[]) # When - snapshot = map_organisation_to_usage_snapshot(organisation) + snapshot = map_organisation_to_usage_snapshot( + organisation, window_start=WINDOW_START, window_end=WINDOW_END + ) # Then assert snapshot == UsageSnapshot( - timestamp=datetime(2026, 6, 18, 8, 0, 0, tzinfo=timezone.utc), + timestamp=WINDOW_START, seat_count=organisation.num_seats, api_call_total=0, api_call_breakdown=ApiCallBreakdown( @@ -105,7 +113,9 @@ def test_map_organisation_to_usage_snapshot__excess_projects__keeps_highest_usag mocker.patch.object(mappers, "MAX_PROJECT_USAGE_ROWS", 1) # When - snapshot = map_organisation_to_usage_snapshot(organisation) + snapshot = map_organisation_to_usage_snapshot( + organisation, window_start=WINDOW_START, window_end=WINDOW_END + ) # Then - only the highest-usage project survives the cap assert snapshot.project_usage == [ diff --git a/api/tests/unit/organisations/usage_reporting/test_services.py b/api/tests/unit/organisations/usage_reporting/test_services.py index f27cbd1e003b..ac65e426b6a9 100644 --- a/api/tests/unit/organisations/usage_reporting/test_services.py +++ b/api/tests/unit/organisations/usage_reporting/test_services.py @@ -1,24 +1,29 @@ import json from datetime import datetime, timezone +from unittest.mock import MagicMock import pytest +import requests from django.conf import settings as django_settings from pytest_django.fixtures import SettingsWrapper from pytest_mock import MockerFixture from pytest_structlog import StructuredLogCapture -from organisations.models import Organisation +from organisations.models import Organisation, UsageReportingState from organisations.usage_reporting.dataclasses import ( ApiCallBreakdown, ProjectUsage, UsageSnapshot, ) from organisations.usage_reporting.services import ( + RETRY_POLICY, get_licensed_organisations, push_snapshot, push_usage_snapshots, ) +REPORTED_LONG_AGO = datetime(2000, 1, 1, tzinfo=timezone.utc) + @pytest.fixture def snapshot() -> UsageSnapshot: @@ -35,6 +40,15 @@ def snapshot() -> UsageSnapshot: ) +@pytest.fixture +def mocked_post(mocker: MockerFixture) -> MagicMock: + mocked_session = mocker.patch( + "organisations.usage_reporting.services.requests.Session" + ) + post: MagicMock = mocked_session.return_value.__enter__.return_value.post + return post + + def test_get_licensed_organisations__licensing_not_installed__returns_empty( settings: SettingsWrapper, ) -> None: @@ -60,32 +74,21 @@ def test_get_licensed_organisations__organisation_without_licence__excluded( assert get_licensed_organisations() == [] -@pytest.mark.parametrize( - "status_code, event, level", - [ - (201, "snapshot.pushed", "info"), - (200, "snapshot.pushed", "info"), - (400, "snapshot.push_failed", "warning"), - (401, "snapshot.push_failed", "warning"), - (403, "snapshot.push_failed", "warning"), - (429, "snapshot.push_failed", "warning"), - (500, "snapshot.push_failed", "warning"), - (503, "snapshot.push_failed", "warning"), - (418, "snapshot.push_failed", "warning"), - ], -) -def test_push_snapshot__status_code__logs_expected_event( - mocker: MockerFixture, +def build_response(status_code: int) -> requests.Response: + response = requests.Response() + response.status_code = status_code + return response + + +@pytest.mark.parametrize("status_code", [200, 201]) +def test_push_snapshot__success_status_code__logs_pushed( + mocked_post: MagicMock, log: StructuredLogCapture, snapshot: UsageSnapshot, status_code: int, - event: str, - level: str, ) -> None: # Given - mocked_post = mocker.patch("organisations.usage_reporting.services.requests.post") - mocked_post.return_value.status_code = status_code - mocked_post.return_value.ok = status_code < 400 + mocked_post.return_value = build_response(status_code) # When push_snapshot( @@ -95,15 +98,62 @@ def test_push_snapshot__status_code__logs_expected_event( ) # Then - assert log.has(event, level=level, status_code=status_code) + assert log.has("snapshot.pushed", level="info", status_code=status_code) -def test_push_snapshot__valid_snapshot__sends_bearer_authed_post( +@pytest.mark.parametrize("status_code", [400, 401, 403, 418, 429, 500, 503]) +def test_push_snapshot__error_status_code__raises_http_error( + mocked_post: MagicMock, + log: StructuredLogCapture, + snapshot: UsageSnapshot, + status_code: int, +) -> None: + # Given + mocked_post.return_value = build_response(status_code) + + # When + with pytest.raises(requests.HTTPError) as exc_info: + push_snapshot( + base_url="https://cp.example.com/", + snapshot=snapshot, + signature_b64="c2ln", + ) + + # Then + assert exc_info.value.response.status_code == status_code + assert not log.has("snapshot.pushed") + + +def test_push_snapshot__valid_snapshot__mounts_retry_policy( mocker: MockerFixture, snapshot: UsageSnapshot, ) -> None: # Given - mocked_post = mocker.patch("organisations.usage_reporting.services.requests.post") + mocked_session = mocker.patch( + "organisations.usage_reporting.services.requests.Session" + ) + session = mocked_session.return_value.__enter__.return_value + session.post.return_value.ok = True + + # When + push_snapshot( + base_url="https://cp.example.com/", + snapshot=snapshot, + signature_b64="c2ln", + ) + + # Then + session.mount.assert_called_once() + prefix, adapter = session.mount.call_args.args + assert prefix == "https://" + assert adapter.max_retries is RETRY_POLICY + + +def test_push_snapshot__valid_snapshot__sends_bearer_authed_post( + mocked_post: MagicMock, + snapshot: UsageSnapshot, +) -> None: + # Given mocked_post.return_value.status_code = 201 signature_b64 = "++++ABE=" @@ -116,8 +166,8 @@ def test_push_snapshot__valid_snapshot__sends_bearer_authed_post( # Then mocked_post.assert_called_once() - (url,), kwargs = mocked_post.call_args - assert url == "https://cp.example.com/v1/public/usage" + kwargs = mocked_post.call_args.kwargs + assert kwargs["url"] == "https://cp.example.com/v1/public/usage" # The signature's raw bytes, unpadded base64url-encoded for the wire. assert kwargs["headers"]["Authorization"] == "Bearer ----ABE" assert kwargs["headers"]["Content-Type"] == "application/json" @@ -182,8 +232,16 @@ def test_push_usage_snapshots__licensed_organisations__pushes_each( ) -> None: # Given settings.CONTROL_PLANE_URL = "https://cp.example.com" - org_one = mocker.Mock(id=1, licence=mocker.Mock(signature="sig-1")) - org_two = mocker.Mock(id=2, licence=mocker.Mock(signature="sig-2")) + org_one = mocker.Mock( + id=1, + licence=mocker.Mock(signature="sig-1"), + usage_reporting_state=mocker.Mock(reported_until=REPORTED_LONG_AGO), + ) + org_two = mocker.Mock( + id=2, + licence=mocker.Mock(signature="sig-2"), + usage_reporting_state=mocker.Mock(reported_until=REPORTED_LONG_AGO), + ) mocker.patch( "organisations.usage_reporting.services.get_licensed_organisations", return_value=[org_one, org_two], @@ -207,6 +265,181 @@ def test_push_usage_snapshots__licensed_organisations__pushes_each( ) +@pytest.fixture +def mocked_map_for_licensed_organisation( + settings: SettingsWrapper, + mocker: MockerFixture, + organisation: Organisation, + snapshot: UsageSnapshot, +) -> MagicMock: + settings.CONTROL_PLANE_URL = "https://cp.example.com" + mocker.patch( + "organisations.usage_reporting.services.get_licensed_organisations", + return_value=[organisation], + ) + # The licence relation only exists with the optional licensing package. + mocker.patch.object( + Organisation, "licence", create=True, new=mocker.Mock(signature="sig-1") + ) + mocker.patch("organisations.usage_reporting.services.push_snapshot") + mocked_map: MagicMock = mocker.patch( + "organisations.usage_reporting.services.map_organisation_to_usage_snapshot", + return_value=snapshot, + ) + return mocked_map + + +@pytest.mark.freeze_time("2026-06-18T09:30:00+00:00") +def test_push_usage_snapshots__never_reported__maps_previous_24_hours( + organisation: Organisation, + mocked_map_for_licensed_organisation: MagicMock, +) -> None: + # Given - no UsageReportingState for the organisation + + # When + push_usage_snapshots() + + # Then - the window ends at the start of the current hour + mocked_map_for_licensed_organisation.assert_called_once_with( + organisation=organisation, + window_start=datetime(2026, 6, 17, 9, 0, 0, tzinfo=timezone.utc), + window_end=datetime(2026, 6, 18, 9, 0, 0, tzinfo=timezone.utc), + ) + + +@pytest.mark.freeze_time("2026-06-18T09:30:00+00:00") +def test_push_usage_snapshots__previously_reported__maps_from_reported_until( + organisation: Organisation, + mocked_map_for_licensed_organisation: MagicMock, +) -> None: + # Given - the last successful push ended three days ago + reported_until = datetime(2026, 6, 15, 9, 0, 0, tzinfo=timezone.utc) + UsageReportingState.objects.create( + organisation=organisation, reported_until=reported_until + ) + + # When + push_usage_snapshots() + + # Then - the unreported period is included in the window + mocked_map_for_licensed_organisation.assert_called_once_with( + organisation=organisation, + window_start=reported_until, + window_end=datetime(2026, 6, 18, 9, 0, 0, tzinfo=timezone.utc), + ) + + +@pytest.mark.freeze_time("2026-06-18T09:30:00+00:00") +def test_push_usage_snapshots__never_reported_push_succeeds__saves_reported_until( + organisation: Organisation, + mocked_map_for_licensed_organisation: MagicMock, +) -> None: + # Given - no UsageReportingState for the organisation + + # When + push_usage_snapshots() + + # Then + organisation.refresh_from_db() + assert organisation.usage_reporting_state.reported_until == datetime( + 2026, 6, 18, 9, 0, 0, tzinfo=timezone.utc + ) + + +@pytest.mark.freeze_time("2026-06-18T09:30:00+00:00") +def test_push_usage_snapshots__previously_reported_push_succeeds__moves_reported_until( + organisation: Organisation, + mocked_map_for_licensed_organisation: MagicMock, +) -> None: + # Given + state = UsageReportingState.objects.create( + organisation=organisation, + reported_until=datetime(2026, 6, 15, 9, 0, 0, tzinfo=timezone.utc), + ) + + # When + push_usage_snapshots() + + # Then + state.refresh_from_db() + assert state.reported_until == datetime(2026, 6, 18, 9, 0, 0, tzinfo=timezone.utc) + + +@pytest.mark.freeze_time("2026-06-18T09:30:00+00:00") +def test_push_usage_snapshots__already_reported_this_hour__skips_push( + mocker: MockerFixture, + log: StructuredLogCapture, + organisation: Organisation, + mocked_map_for_licensed_organisation: MagicMock, +) -> None: + # Given - the window up to the start of the current hour is already reported + UsageReportingState.objects.create( + organisation=organisation, + reported_until=datetime(2026, 6, 18, 9, 0, 0, tzinfo=timezone.utc), + ) + mocked_push = mocker.patch("organisations.usage_reporting.services.push_snapshot") + + # When + push_usage_snapshots() + + # Then + mocked_push.assert_not_called() + assert log.has("snapshot.skipped", level="debug", reason="empty_window") + + +@pytest.mark.freeze_time("2026-06-18T09:30:00+00:00") +def test_push_usage_snapshots__never_reported_push_fails__keeps_initial_boundary( + mocker: MockerFixture, + organisation: Organisation, + snapshot: UsageSnapshot, + mocked_map_for_licensed_organisation: MagicMock, +) -> None: + # Given - no UsageReportingState for the organisation + mocked_push = mocker.patch( + "organisations.usage_reporting.services.push_snapshot", + side_effect=requests.HTTPError("503 Server Error"), + ) + + # When + push_usage_snapshots() + + # Then - the push was attempted and failed + mocked_push.assert_called_once_with( + base_url="https://cp.example.com", snapshot=snapshot, signature_b64="sig-1" + ) + # The next run retries the window starting 24 hours ago + organisation.refresh_from_db() + assert organisation.usage_reporting_state.reported_until == datetime( + 2026, 6, 17, 9, 0, 0, tzinfo=timezone.utc + ) + + +@pytest.mark.freeze_time("2026-06-18T09:30:00+00:00") +def test_push_usage_snapshots__push_fails__keeps_reported_until( + mocker: MockerFixture, + log: StructuredLogCapture, + organisation: Organisation, + mocked_map_for_licensed_organisation: MagicMock, +) -> None: + # Given + reported_until = datetime(2026, 6, 15, 9, 0, 0, tzinfo=timezone.utc) + state = UsageReportingState.objects.create( + organisation=organisation, reported_until=reported_until + ) + mocker.patch( + "organisations.usage_reporting.services.push_snapshot", + side_effect=requests.HTTPError("503 Server Error"), + ) + + # When + push_usage_snapshots() + + # Then - the next run retries the same window + state.refresh_from_db() + assert state.reported_until == reported_until + assert log.has("snapshot.errored", level="error") + + def test_push_usage_snapshots__one_organisation_raises__continues( settings: SettingsWrapper, mocker: MockerFixture, @@ -215,8 +448,16 @@ def test_push_usage_snapshots__one_organisation_raises__continues( ) -> None: # Given settings.CONTROL_PLANE_URL = "https://cp.example.com" - org_one = mocker.Mock(id=1, licence=mocker.Mock(signature="sig-1")) - org_two = mocker.Mock(id=2, licence=mocker.Mock(signature="sig-2")) + org_one = mocker.Mock( + id=1, + licence=mocker.Mock(signature="sig-1"), + usage_reporting_state=mocker.Mock(reported_until=REPORTED_LONG_AGO), + ) + org_two = mocker.Mock( + id=2, + licence=mocker.Mock(signature="sig-2"), + usage_reporting_state=mocker.Mock(reported_until=REPORTED_LONG_AGO), + ) mocker.patch( "organisations.usage_reporting.services.get_licensed_organisations", return_value=[org_one, org_two], diff --git a/docs/docs/deployment-self-hosting/observability/_events-catalogue.md b/docs/docs/deployment-self-hosting/observability/_events-catalogue.md index 3a2cd944daea..6d3ae04fb0da 100644 --- a/docs/docs/deployment-self-hosting/observability/_events-catalogue.md +++ b/docs/docs/deployment-self-hosting/observability/_events-catalogue.md @@ -997,8 +997,8 @@ Attributes: ### `usage_reporting.run.skipped` Logged at `debug` from: - - `api/organisations/usage_reporting/services.py:60` - - `api/organisations/usage_reporting/services.py:63` + - `api/organisations/usage_reporting/services.py:80` + - `api/organisations/usage_reporting/services.py:83` Attributes: - `reason` @@ -1006,25 +1006,26 @@ Attributes: ### `usage_reporting.snapshot.errored` Logged at `exception` from: - - `api/organisations/usage_reporting/services.py:75` + - `api/organisations/usage_reporting/services.py:112` Attributes: + - `reason` -### `usage_reporting.snapshot.push_failed` +### `usage_reporting.snapshot.pushed` -Logged at `warning` from: - - `api/organisations/usage_reporting/services.py:55` +Logged at `info` from: + - `api/organisations/usage_reporting/services.py:75` Attributes: - `status_code` -### `usage_reporting.snapshot.pushed` +### `usage_reporting.snapshot.skipped` -Logged at `info` from: - - `api/organisations/usage_reporting/services.py:53` +Logged at `debug` from: + - `api/organisations/usage_reporting/services.py:95` Attributes: - - `status_code` + - `reason` ### `warehouse.connection.connected`