Browse Source

chore(trace-explorer): Restore project selector (#73528)

We're reverting the decision to allow cross project searches. This puts
it back behind a flag.

Depends on #73524
Tony Xiao 8 months ago
parent
commit
52175777c5
2 changed files with 23 additions and 19 deletions
  1. 19 12
      static/app/views/traces/content.tsx
  2. 4 7
      static/app/views/traces/tracesSearchBar.tsx

+ 19 - 12
static/app/views/traces/content.tsx

@@ -183,18 +183,24 @@ export function Content() {
   return (
     <LayoutMain fullWidth>
       <PageFilterBar condensed>
-        <Tooltip
-          title={tct(
-            "Traces stem across multiple projects. You'll need to narrow down which projects you'd like to include per span.[br](ex. [code:project:javascript])",
-            {
-              br: <br />,
-              code: <Code />,
-            }
-          )}
-          position="bottom"
-        >
-          <ProjectPageFilter disabled projectOverride={ALL_PROJECTS} />
-        </Tooltip>
+        {organization.features.includes(
+          'organizations:performance-trace-explorer-enforce-projects'
+        ) ? (
+          <ProjectPageFilter />
+        ) : (
+          <Tooltip
+            title={tct(
+              "Traces stem across multiple projects. You'll need to narrow down which projects you'd like to include per span.[br](ex. [code:project:javascript])",
+              {
+                br: <br />,
+                code: <Code />,
+              }
+            )}
+            position="bottom"
+          >
+            <ProjectPageFilter disabled projectOverride={ALL_PROJECTS} />
+          </Tooltip>
+        )}
         <EnvironmentPageFilter />
         <DatePageFilter defaultPeriod="2h" />
       </PageFilterBar>
@@ -750,6 +756,7 @@ function useTraceSpans<F extends string>({
 
   const endpointOptions = {
     query: {
+      project: selection.projects,
       environment: selection.environments,
       ...(datetime ?? normalizeDateTimeParams(selection.datetime)),
       field: fields,

+ 4 - 7
static/app/views/traces/tracesSearchBar.tsx

@@ -9,10 +9,9 @@ import {SavedSearchType} from 'sentry/types/group';
 import {trackAnalytics} from 'sentry/utils/analytics';
 import {DiscoverDatasets} from 'sentry/utils/discover/types';
 import useOrganization from 'sentry/utils/useOrganization';
+import usePageFilters from 'sentry/utils/usePageFilters';
 import {useSpanFieldSupportedTags} from 'sentry/views/performance/utils/useSpanFieldSupportedTags';
 
-import {ALL_PROJECTS} from './utils';
-
 interface TracesSearchBarProps {
   handleClearSearch: (index: number) => boolean;
   handleSearch: (index: number, query: string) => void;
@@ -33,16 +32,14 @@ export function TracesSearchBar({
   handleSearch,
   handleClearSearch,
 }: TracesSearchBarProps) {
-  // TODO: load tags for autocompletion
   const organization = useOrganization();
+  const {selection} = usePageFilters();
   const canAddMoreQueries = queries.length <= 2;
   const localQueries = queries.length ? queries : [''];
 
   // Since trace explorer permits cross project searches,
   // autocompletion should also be cross projects.
-  const supportedTags = useSpanFieldSupportedTags({
-    projects: ALL_PROJECTS,
-  });
+  const supportedTags = useSpanFieldSupportedTags();
 
   return (
     <TraceSearchBarsContainer>
@@ -58,7 +55,7 @@ export function TracesSearchBar({
             metricAlert={false}
             supportedTags={supportedTags}
             dataset={DiscoverDatasets.SPANS_INDEXED}
-            projectIds={ALL_PROJECTS}
+            projectIds={selection.projects}
             savedSearchType={SavedSearchType.SPAN}
           />
           <StyledButton