Beispiel #1
0
 def __init__(self, **options):
     if not options:
         # inherit default options from REDIS_OPTIONS
         options = settings.SENTRY_REDIS_OPTIONS
     super(RedisQuota, self).__init__(**options)
     options.setdefault('hosts', {0: {}})
     self.cluster = make_rb_cluster(options['hosts'])
Beispiel #2
0
    def __init__(self, **options):
        if not options:
            # inherit default options from REDIS_OPTIONS
            options = settings.SENTRY_REDIS_OPTIONS
        options.setdefault("hosts", {0: {}})

        self.cluster = make_rb_cluster(options["hosts"])
Beispiel #3
0
    def __init__(self, hosts=None, prefix='ts:', vnodes=64, **kwargs):
        # inherit default options from REDIS_OPTIONS
        defaults = settings.SENTRY_REDIS_OPTIONS

        if hosts is None:
            hosts = defaults.get('hosts', {0: {}})

        self.cluster = make_rb_cluster(hosts)
        self.prefix = prefix
        self.vnodes = vnodes
        super(RedisTSDB, self).__init__(**kwargs)
Beispiel #4
0
    def __init__(self, hosts=None, prefix='ts:', vnodes=64, **kwargs):
        # inherit default options from REDIS_OPTIONS
        defaults = settings.SENTRY_REDIS_OPTIONS

        if hosts is None:
            hosts = defaults.get('hosts', {0: {}})

        self.cluster = make_rb_cluster(hosts)
        self.prefix = prefix
        self.vnodes = vnodes
        super(RedisTSDB, self).__init__(**kwargs)
Beispiel #5
0
    def __init__(self, version=None, prefix=None, **options):
        if not options:
            # inherit default options from REDIS_OPTIONS
            options = settings.SENTRY_REDIS_OPTIONS

        options.setdefault('hosts', {
            0: {},
        })
        self.cluster = make_rb_cluster(options['hosts'])
        self.client = self.cluster.get_routing_client()

        super(RedisCache, self).__init__(version=version, prefix=prefix)
Beispiel #6
0
from sentry.models import Project, Group, Event

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

MAX_RECENT = 15
RECENT_HOURS = 24 * 30

# The Redis cluster manager (``clusters``) was added in Sentry 8.2 (GH-2714)
# and replaces ``make_rb_cluster`` (which will be removed in a future version.)
try:
    from sentry.utils.redis import clusters
    cluster = clusters.get('default')
except ImportError:
    from sentry.utils.redis import make_rb_cluster
    cluster = make_rb_cluster(settings.SENTRY_REDIS_OPTIONS['hosts'])


def get_key(tenant):
    return 'sentry-hipchat-ac:%s:mentions' % tenant.id


def get_recent_mentions(tenant):
    client = cluster.get_routing_client()
    key = get_key(tenant)
    ids = [
        x for x in client.zrangebyscore(key,
                                        time.time() -
                                        (RECENT_HOURS * 60), '+inf')
    ][-MAX_RECENT:]
Beispiel #7
0
import json
import time

from sentry.utils.redis import make_rb_cluster
from sentry.utils.dates import to_datetime, to_timestamp
from sentry.models import Project, Group, Event

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


MAX_RECENT = 15
RECENT_HOURS = 24 * 30


cluster = make_rb_cluster(settings.SENTRY_REDIS_OPTIONS['hosts'])


def get_key(tenant):
    return 'sentry-hipchat-ac:%s:mentions' % tenant.id


def get_recent_mentions(tenant):
    client = cluster.get_routing_client()
    key = get_key(tenant)
    ids = [x for x in client.zrangebyscore(
        key, time.time() - (RECENT_HOURS * 60), '+inf')][-MAX_RECENT:]

    with cluster.map() as map_client:
        items = [map_client.get('%s:%s' % (key, id)) for id in ids]
    items = [json.loads(x.value) for x in items if x.value is not None]