@@ -35,6 +35,7 @@ def execute_trace_query_chart(
3535 stats_period : str ,
3636 y_axes : list [str ],
3737 group_by : list [str ] | None = None ,
38+ project_ids : list [int ] | None = None ,
3839) -> dict [str , Any ] | None :
3940 """
4041 Execute a trace query to get chart/timeseries data by calling the events-stats endpoint.
@@ -45,11 +46,12 @@ def execute_trace_query_chart(
4546 logger .warning ("Organization not found" , extra = {"org_id" : org_id })
4647 return None
4748
48- # Get all project IDs for the organization
49- project_ids = list (organization .project_set .values_list ("id" , flat = True ))
50- if not project_ids :
51- logger .warning ("No projects found for organization" , extra = {"org_id" : org_id })
52- return None
49+ # Use provided project_ids or get all project IDs for the organization
50+ if project_ids is None :
51+ project_ids = list (organization .project_set .values_list ("id" , flat = True ))
52+ if not project_ids :
53+ logger .warning ("No projects found for organization" , extra = {"org_id" : org_id })
54+ return None
5355
5456 params : dict [str , Any ] = {
5557 "query" : query ,
@@ -107,6 +109,7 @@ def execute_trace_query_table(
107109 y_axes : list [str ] | None = None ,
108110 per_page : int = 50 ,
109111 mode : Literal ["spans" , "aggregates" ] = "spans" ,
112+ project_ids : list [int ] | None = None ,
110113) -> dict [str , Any ] | None :
111114 """
112115 Execute a trace query to get table data by calling the events endpoint.
@@ -117,11 +120,12 @@ def execute_trace_query_table(
117120 logger .warning ("Organization not found" , extra = {"org_id" : org_id })
118121 return None
119122
120- # Get all project IDs for the organization
121- project_ids = list (organization .project_set .values_list ("id" , flat = True ))
122- if not project_ids :
123- logger .warning ("No projects found for organization" , extra = {"org_id" : org_id })
124- return None
123+ # Use provided project_ids or get all project IDs for the organization
124+ if project_ids is None :
125+ project_ids = list (organization .project_set .values_list ("id" , flat = True ))
126+ if not project_ids :
127+ logger .warning ("No projects found for organization" , extra = {"org_id" : org_id })
128+ return None
125129
126130 # Determine fields based on mode
127131 if mode == "aggregates" :
@@ -141,7 +145,6 @@ def execute_trace_query_table(
141145 "transaction" ,
142146 "timestamp" ,
143147 "project" ,
144- "project.name" ,
145148 "trace" ,
146149 ]
147150
0 commit comments