def build_sessions_query(self, request: Request, organization): try: params = self.get_filter_params(request, organization, date_filter_optional=True) except NoProjects: raise NoProjects("No projects available") # give it a description # HACK to prevent front-end crash when release health is sessions-based: query_params = MultiValueDict(request.GET) if not release_health.is_metrics_based() and request.GET.get( "interval") == "10s": query_params["interval"] = "1m" if release_health.is_metrics_based(): allowed_resolution = AllowedResolution.ten_seconds elif features.has("organizations:minute-resolution-sessions", organization, actor=request.user): allowed_resolution = AllowedResolution.one_minute else: allowed_resolution = AllowedResolution.one_hour return QueryDefinition(query_params, params, allowed_resolution=allowed_resolution)
def build_sessions_query(self, request, organization): # validate and default all `project` params. projects = self.get_projects(request, organization) if projects is None or len(projects) == 0: raise NoProjects("No projects available") project_ids = [p.id for p in projects] return QueryDefinition(request.GET, project_ids)
def build_sessions_query(self, request, organization): try: params = self.get_filter_params(request, organization, date_filter_optional=True) except NoProjects: raise NoProjects("No projects available") # give it a description return QueryDefinition(request.GET, params)
def build_sessions_query(self, request, organization): try: params = self.get_filter_params(request, organization, date_filter_optional=True) except NoProjects: raise NoProjects("No projects available") # give it a description allow_minute_resolution = features.has( "organizations:minute-resolution-sessions", organization, actor=request.user) return QueryDefinition(request.GET, params, allow_minute_resolution=allow_minute_resolution)
def test_get_sessionsv2_schema(): query = QueryDefinition( query=MultiValueDict( { "statsPeriod": ["24h"], "interval": ["1h"], "field": ["sum(session)", "avg(session.duration)"], } ), params={}, allowed_resolution=AllowedResolution.one_hour, ) schema = get_sessionsv2_schema(datetime.now(timezone.utc), query) assert schema["sum(session)"] == FixedList(22 * [Ct.Counter] + 2 * [Ct.Ignore]) assert schema["avg(session.duration)"] == FixedList(22 * [Ct.Quantile] + 2 * [Ct.Ignore])
def _make_query(qs): return QueryDefinition(QueryDict(qs), {})
def _make_query(qs, allow_minute_resolution=True): allowed_resolution = (AllowedResolution.one_minute if allow_minute_resolution else AllowedResolution.one_hour) return QueryDefinition(QueryDict(qs), {}, allowed_resolution)
def _make_query(qs, allow_minute_resolution=True): return QueryDefinition(QueryDict(qs), {}, allow_minute_resolution)
def build_sessions_query(self, request, organization): # validate and default all `project` params. projects = self.get_projects(request, organization) project_ids = [p.id for p in projects] return QueryDefinition(request.GET, project_ids)