def store() -> Generator[RealtimeMetricsStore, None, None]:
    store = LazyServiceWrapper(
        RealtimeMetricsStore,
        "sentry.processing.realtime_metrics.redis.RedisRealtimeMetricsStore",
        {
            "cluster": "default",
            "counter_bucket_size": 10,
            "counter_time_window": 120,
            "duration_bucket_size": 10,
            "duration_time_window": 120,
            "backoff_timer": 0,
        },
    )

    old_properties = realtime_metrics.__dict__.copy()
    store.expose(realtime_metrics.__dict__)
    yield store

    # cleanup
    realtime_metrics.__dict__.update(old_properties)
예제 #2
0
from __future__ import absolute_import

from django.conf import settings

from sentry.utils.services import LazyServiceWrapper

from .base import BaseTSDB  # NOQA
from .dummy import DummyTSDB

LazyServiceWrapper(BaseTSDB,
                   settings.SENTRY_TSDB,
                   settings.SENTRY_TSDB_OPTIONS,
                   dangerous=[DummyTSDB]).expose(locals())
예제 #3
0
from typing import TYPE_CHECKING

from django.conf import settings

from sentry.utils.services import LazyServiceWrapper

from .base import RealtimeMetricsStore

backend = LazyServiceWrapper(
    RealtimeMetricsStore,
    settings.SENTRY_REALTIME_METRICS_BACKEND,
    settings.SENTRY_REALTIME_METRICS_OPTIONS,
)
backend.expose(locals())

if TYPE_CHECKING:
    # This is all too dynamic for mypy, so manually set the same attributes from
    # RealtimeMetricsStore.__all__:
    __realtime_metrics_store__ = RealtimeMetricsStore()
    validate = __realtime_metrics_store__.validate
    increment_project_event_counter = __realtime_metrics_store__.increment_project_event_counter
    increment_project_duration_counter = (
        __realtime_metrics_store__.increment_project_duration_counter
    )
    projects = __realtime_metrics_store__.projects
    get_counts_for_project = __realtime_metrics_store__.get_counts_for_project
    get_durations_for_project = __realtime_metrics_store__.get_durations_for_project
    get_lpq_projects = __realtime_metrics_store__.get_lpq_projects
    is_lpq_project = __realtime_metrics_store__.is_lpq_project
    add_project_to_lpq = __realtime_metrics_store__.add_project_to_lpq
    remove_projects_from_lpq = __realtime_metrics_store__.remove_projects_from_lpq
예제 #4
0
파일: __init__.py 프로젝트: webZW/sentry
from __future__ import absolute_import

from sentry.utils.services import LazyServiceWrapper

from .base import EventStorage  # NOQA

backend = LazyServiceWrapper(
    EventStorage,
    'sentry.eventstore.snuba.SnubaEventStorage',
    {},
    metrics_path='eventstore',
)
backend.expose(locals())
예제 #5
0
from __future__ import absolute_import

from django.conf import settings

from sentry.utils.services import LazyServiceWrapper

from .base import TagStorage, TagKeyStatus  # NOQA
from .exceptions import *  # NOQA

backend = LazyServiceWrapper(
    TagStorage, settings.SENTRY_TAGSTORE, settings.SENTRY_TAGSTORE_OPTIONS
)
backend.expose(locals())
예제 #6
0
from django.conf import settings

from sentry.utils.services import LazyServiceWrapper

from .base import ChartRenderer  # NOQA

# The charts module provides a service to interface with the external
# Chartcuterie service, which produces charts as images.
#
# This module will handle producing and storing the images given some data that
# you would like to represent as a chart outside of the frontend application.

backend = LazyServiceWrapper(
    ChartRenderer,
    settings.SENTRY_CHART_RENDERER,
    settings.SENTRY_CHART_RENDERER_OPTIONS,
)
backend.expose(locals())
예제 #7
0
파일: __init__.py 프로젝트: pasala91/test
from django.conf import settings

from sentry.utils.services import LazyServiceWrapper

from .base import Quota  # NOQA

backend = LazyServiceWrapper(Quota, settings.SENTRY_QUOTAS, settings.SENTRY_QUOTA_OPTIONS)
backend.expose(locals())
예제 #8
0
from __future__ import absolute_import

from django.conf import settings

from sentry.utils.services import LazyServiceWrapper

from .base import NodeStorage  # NOQA

backend = LazyServiceWrapper(NodeStorage, settings.SENTRY_NODESTORE,
                             settings.SENTRY_NODESTORE_OPTIONS)
backend.expose(locals())
예제 #9
0
from django.conf import settings

from sentry.utils.services import LazyServiceWrapper

from .base import ReleaseHealthBackend

backend = LazyServiceWrapper(
    ReleaseHealthBackend,
    settings.SENTRY_RELEASE_HEALTH,
    settings.SENTRY_RELEASE_HEALTH_OPTIONS,
)
backend.expose(locals())
예제 #10
0
from sentry.utils.services import LazyServiceWrapper

from .attribute import Attribute
from .base import Analytics
from .event import Event
from .event_manager import default_manager
from .map import Map
from .utils import get_backend_path

__all__ = (
    "Analytics",
    "Attribute",
    "Event",
    "Map",
    "record",
    "record_event",
    "setup",
)

backend = LazyServiceWrapper(
    backend_base=Analytics,
    backend_path=get_backend_path(options.get("analytics.backend")),
    options=options.get("analytics.options"),
)

record = backend.record
record_event = backend.record_event
register = default_manager.register
setup = backend.setup
validate = backend.validate
예제 #11
0
파일: __init__.py 프로젝트: zanjs/sentry
from __future__ import absolute_import

from django.conf import settings

from sentry.utils.services import LazyServiceWrapper

from .base import BaseTSDB  # NOQA
from .dummy import DummyTSDB


backend = LazyServiceWrapper(BaseTSDB, settings.SENTRY_TSDB,
                             settings.SENTRY_TSDB_OPTIONS,
                             (DummyTSDB,))
backend.expose(locals())
예제 #12
0
from django.conf import settings

from sentry.utils.services import LazyServiceWrapper

from .base import StringIndexer

backend = LazyServiceWrapper(
    StringIndexer,
    settings.SENTRY_METRICS_INDEXER,
    settings.SENTRY_METRICS_INDEXER_OPTIONS,
)
backend.expose(locals())
예제 #13
0
파일: __init__.py 프로젝트: liang0/sentry-1
from __future__ import absolute_import

from django.conf import settings

from sentry.utils.services import LazyServiceWrapper

from .base import NodeStorage  # NOQA

backend = LazyServiceWrapper(
    NodeStorage,
    settings.SENTRY_NODESTORE,
    settings.SENTRY_NODESTORE_OPTIONS,
    metrics_path="nodestore",
)
backend.expose(locals())
예제 #14
0
from django.conf import settings

from sentry.utils.services import LazyServiceWrapper

from .base import TagStorage, TagKeyStatus  # NOQA
from .exceptions import *  # NOQA

LazyServiceWrapper(TagStorage, settings.SENTRY_TAGSTORE, settings.SENTRY_TAGSTORE_OPTIONS).expose(
    locals()
)
예제 #15
0
from __future__ import absolute_import

from django.conf import settings

from sentry.utils.services import LazyServiceWrapper

from .base import EventStorage, Filter  # NOQA

backend = LazyServiceWrapper(
    EventStorage,
    settings.SENTRY_EVENTSTORE,
    settings.SENTRY_EVENTSTORE_OPTIONS,
    metrics_path="eventstore",
)
backend.expose(locals())
예제 #16
0
from __future__ import absolute_import

from django.conf import settings

from sentry.utils.services import LazyServiceWrapper

from .base import EventStream

backend = LazyServiceWrapper(
    EventStream,
    settings.SENTRY_EVENTSTREAM,
    settings.SENTRY_EVENTSTREAM_OPTIONS,
)
backend.expose(locals())
예제 #17
0
from typing import TYPE_CHECKING

from django.conf import settings

from sentry.utils.services import LazyServiceWrapper

from .base import RealtimeMetricsStore

realtime_metrics_store: RealtimeMetricsStore = LazyServiceWrapper(
    RealtimeMetricsStore,
    settings.SENTRY_REALTIME_METRICS_BACKEND,
    settings.SENTRY_REALTIME_METRICS_OPTIONS,
)

realtime_metrics_store.expose(locals())

if TYPE_CHECKING:
    # This is all too dynamic for mypy, so manually set the same attributes from
    # RealtimeMetricsStore.__all__:
    validate = realtime_metrics_store.validate
    increment_project_event_counter = realtime_metrics_store.increment_project_event_counter
    increment_project_duration_counter = realtime_metrics_store.increment_project_duration_counter
    projects = realtime_metrics_store.projects
    get_counts_for_project = realtime_metrics_store.get_counts_for_project
    get_durations_for_project = realtime_metrics_store.get_durations_for_project
    get_lpq_projects = realtime_metrics_store.get_lpq_projects
    is_lpq_project = realtime_metrics_store.is_lpq_project
    add_project_to_lpq = realtime_metrics_store.add_project_to_lpq
    remove_projects_from_lpq = realtime_metrics_store.remove_projects_from_lpq
예제 #18
0
from typing import TYPE_CHECKING

from django.conf import settings

from sentry.utils.services import LazyServiceWrapper

from .base import ProjectConfigDebounceCache

backend = LazyServiceWrapper(
    ProjectConfigDebounceCache,
    settings.SENTRY_RELAY_PROJECTCONFIG_DEBOUNCE_CACHE,
    settings.SENTRY_RELAY_PROJECTCONFIG_DEBOUNCE_CACHE_OPTIONS,
)

backend.expose(locals())

if TYPE_CHECKING:
    check_is_debounced = backend.check_is_debounced
    mark_task_done = backend.mark_task_done
from __future__ import absolute_import

from django.conf import settings

from sentry import options
from sentry.utils.services import LazyServiceWrapper

from .base import Analytics  # NOQA
from .event_manager import default_manager
from .event import *  # NOQA


def get_backend_path(backend):
    try:
        backend = settings.SENTRY_ANALYTICS_ALIASES[backend]
    except KeyError:
        pass
    return backend


backend = LazyServiceWrapper(
    Analytics, get_backend_path(options.get('analytics.backend')), options.get('analytics.options')
)
backend.expose(locals())

register = default_manager.register
예제 #20
0
from collections import namedtuple
from django.conf import settings

from sentry.utils.dates import to_datetime
from sentry.utils.services import LazyServiceWrapper

from .backends.base import Backend  # NOQA
from .backends.dummy import DummyBackend  # NOQA

backend = LazyServiceWrapper(
    Backend, settings.SENTRY_DIGESTS, settings.SENTRY_DIGESTS_OPTIONS, (DummyBackend,)
)
backend.expose(locals())


class Record(namedtuple("Record", "key value timestamp")):
    @property
    def datetime(self):
        return to_datetime(self.timestamp)


ScheduleEntry = namedtuple("ScheduleEntry", "key timestamp")

OPTIONS = frozenset(("increment_delay", "maximum_delay", "minimum_delay"))


def get_option_key(plugin, option):
    assert option in OPTIONS
    return f"digests:{plugin}:{option}"
예제 #21
0
from __future__ import absolute_import

from django.conf import settings

from sentry.utils.services import LazyServiceWrapper

from .base import Buffer  # NOQA


backend = LazyServiceWrapper(Buffer, settings.SENTRY_BUFFER,
                             settings.SENTRY_BUFFER_OPTIONS)
backend.expose(locals())
예제 #22
0
파일: __init__.py 프로젝트: zanjs/sentry
from __future__ import absolute_import

from django.conf import settings

from sentry.utils.services import LazyServiceWrapper

from .base import RateLimiter  # NOQA

backend = LazyServiceWrapper(RateLimiter, settings.SENTRY_RATELIMITER,
                             settings.SENTRY_RATELIMITER_OPTIONS)
backend.expose(locals())
예제 #23
0
파일: __init__.py 프로젝트: zvrr/sentry
from __future__ import absolute_import

from sentry.utils.services import LazyServiceWrapper

from .base import EventStorage, Columns, Filter  # NOQA

backend = LazyServiceWrapper(EventStorage,
                             "sentry.eventstore.snuba.SnubaEventStorage", {},
                             metrics_path="eventstore")
backend.expose(locals())
예제 #24
0
from __future__ import absolute_import

from django.conf import settings

from sentry.utils.services import LazyServiceWrapper

from .base import SearchBackend  # NOQA

LazyServiceWrapper(
    SearchBackend,
    settings.SENTRY_SEARCH,
    settings.SENTRY_SEARCH_OPTIONS,
).expose(locals())
예제 #25
0
파일: __init__.py 프로젝트: pasala91/test
from django.conf import settings

from sentry.utils.services import LazyServiceWrapper

from .base import Newsletter  # NOQA

backend = LazyServiceWrapper(Newsletter, settings.SENTRY_NEWSLETTER,
                             settings.SENTRY_NEWSLETTER_OPTIONS)
backend.expose(locals())
예제 #26
0
from typing import TYPE_CHECKING

from django.conf import settings

from sentry.rules.history.base import RuleHistoryBackend
from sentry.utils.services import LazyServiceWrapper

LazyServiceWrapper(
    RuleHistoryBackend,
    settings.SENTRY_ISSUE_ALERT_HISTORY,
    settings.SENTRY_ISSUE_ALERT_HISTORY_OPTIONS,
).expose(locals())

if TYPE_CHECKING:
    __rule_history_backend__ = RuleHistoryBackend()
    record = __rule_history_backend__.record
    fetch_rule_groups_paginated = __rule_history_backend__.fetch_rule_groups_paginated
    fetch_rule_hourly_stats = __rule_history_backend__.fetch_rule_hourly_stats