Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split up organizations across metrics exporters (WIP) #5127

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion engine/apps/metrics_exporter/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import random
import typing

from django.conf import settings
from django.core.cache import cache
from django.utils import timezone

Expand Down Expand Up @@ -50,7 +51,10 @@ def get_organization_ids():
if not organizations_ids:
organizations_ids = get_organization_ids_from_db()
cache.set(organizations_ids, METRICS_ORGANIZATIONS_IDS, METRICS_ORGANIZATIONS_IDS_CACHE_TIMEOUT)
return organizations_ids

group_id = settings.METRICS_EXPORTER_ORGANIZATION_GROUP_ID
group_count = settings.METRICS_EXPORTER_TOTAL_ORGANIZATION_GROUPS
return [i for i in organizations_ids if i % group_count == group_id]


def is_allowed_to_start_metrics_calculation(organization_id, force=False) -> bool:
Expand Down
5 changes: 5 additions & 0 deletions engine/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@
# List of metrics to collect. Collect all available application metrics by default
METRICS_TO_COLLECT = getenv_list("METRICS_TO_COLLECT", METRICS_ALL)

# Total number of exporters collecting the same set of metrics
METRICS_EXPORTER_TOTAL_ORGANIZATION_GROUPS = getenv_integer("METRICS_EXPORTER_TOTAL_ORGANIZATION_GROUPS", 1)
# ID of this exporter, used to filter which orgs to collect for
METRICS_EXPORTER_ORGANIZATION_GROUP_ID = getenv_integer("METRICS_EXPORTER_ORGANIZATION_GROUP_ID", 0)


# Database
class DatabaseTypes:
Expand Down
Loading