def _get_event_user(self, project, data): user_data = data.get('sentry.interfaces.User') if not user_data: return euser = EventUser( project=project, ident=user_data.get('id'), email=user_data.get('email'), username=user_data.get('username'), ip_address=user_data.get('ip_address'), ) if not euser.tag_value: return cache_key = 'euser:{}:{}'.format( project.id, md5_text(euser.tag_value).hexdigest(), ) cached = default_cache.get(cache_key) if cached is None: try: with transaction.atomic(using=router.db_for_write(EventUser)): euser.save() except IntegrityError: pass default_cache.set(cache_key, '', 3600) return euser
def _get_event_user(self, project, data): user_data = data.get("sentry.interfaces.User") if not user_data: return euser = EventUser( project=project, ident=user_data.get("id"), email=user_data.get("email"), username=user_data.get("username"), ip_address=user_data.get("ip_address"), ) if not euser.tag_value: return cache_key = "euser:{}:{}".format(project.id, md5(euser.tag_value.encode("utf-8")).hexdigest()) cached = default_cache.get(cache_key) if cached is None: try: with transaction.atomic(using=router.db_for_write(EventUser)): euser.save() except IntegrityError: pass default_cache.set(cache_key, "", 3600) return euser
def get_key_quota(self, key): from sentry import features # XXX(epurkhiser): Avoid excessive feature manager checks (which can be # expensive depending on feature handlers) for project rate limits. # This happens on /store. cache_key = u'project:{}:features:rate-limits'.format(key.project.id) has_rate_limits = default_cache.get(cache_key) if has_rate_limits is None: has_rate_limits = features.has('projects:rate-limits', key.project) default_cache.set(cache_key, has_rate_limits, 600) return key.rate_limit if has_rate_limits else (0, 0)
def get_key_quota(self, key): from sentry import features # XXX(epurkhiser): Avoid excessive feature manager checks (which can be # expensive depending on feature handlers) for project rate limits. # This happens on /store. cache_key = u'project:{}:rate-limits'.format(key.project.id) rate_limit = default_cache.get(cache_key) if rate_limit is None: has_rate_limits = features.has('projects:rate-limits', key.project) rate_limit = key.rate_limit if has_rate_limits else (0, 0) default_cache.set(cache_key, rate_limit, 600) return rate_limit
def _get_event_user(self, project, data): user_data = data.get('sentry.interfaces.User') if not user_data: return euser = EventUser( project_id=project.id, ident=user_data.get('id'), email=user_data.get('email'), username=user_data.get('username'), ip_address=user_data.get('ip_address'), name=user_data.get('name'), ) euser.set_hash() if not euser.hash: return cache_key = 'euserid:1:{}:{}'.format( project.id, euser.hash, ) euser_id = default_cache.get(cache_key) if euser_id is None: try: with transaction.atomic(using=router.db_for_write(EventUser)): euser.save() except IntegrityError: try: euser = EventUser.objects.get( project_id=project.id, hash=euser.hash, ) except EventUser.DoesNotExist: # why??? e_userid = -1 else: if euser.name != (user_data.get('name') or euser.name): euser.update( name=user_data['name'], ) e_userid = euser.id default_cache.set(cache_key, e_userid, 3600) return euser