Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions static/app/components/events/metrics/metricsSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@ import {trackAnalytics} from 'sentry/utils/analytics';
import {useLocation} from 'sentry/utils/useLocation';
import {useNavigate} from 'sentry/utils/useNavigate';
import useOrganization from 'sentry/utils/useOrganization';
import {TraceItemAttributeProvider} from 'sentry/views/explore/contexts/traceItemAttributeContext';
import {METRICS_DRAWER_QUERY_PARAM} from 'sentry/views/explore/metrics/constants';
import {MetricsSamplesTable} from 'sentry/views/explore/metrics/metricInfoTabs/metricsSamplesTable';
import {canUseMetricsUI} from 'sentry/views/explore/metrics/metricsFlags';
import {TraceItemDataset} from 'sentry/views/explore/types';
import {SectionKey} from 'sentry/views/issueDetails/streamline/context';
import {InterimSection} from 'sentry/views/issueDetails/streamline/interimSection';
import {TraceViewMetricsProviderWrapper} from 'sentry/views/performance/newTraceDetails/traceMetrics';
Expand Down Expand Up @@ -107,12 +105,7 @@ function MetricsSectionContent({
openDrawer(
() => (
<TraceViewMetricsProviderWrapper traceSlug={traceId}>
<TraceItemAttributeProvider
traceItemType={TraceItemDataset.TRACEMETRICS}
enabled
>
<MetricsDrawer group={group} event={event} project={project} />
</TraceItemAttributeProvider>
<MetricsDrawer group={group} event={event} project={project} />
</TraceViewMetricsProviderWrapper>
),
{
Expand Down
8 changes: 5 additions & 3 deletions static/app/components/events/ourlogs/ourlogsDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,14 @@ export function OurlogsDrawer({
const setLogsQuery = useSetQueryParamsQuery();
const logsSearch = useQueryParamsSearch();

const logsAttributeConfig = {traceItemType: TraceItemDataset.LOGS, enabled: true};

const {attributes: stringAttributes, secondaryAliases: stringSecondaryAliases} =
useTraceItemAttributes('string');
useTraceItemAttributes(logsAttributeConfig, 'string');
const {attributes: numberAttributes, secondaryAliases: numberSecondaryAliases} =
useTraceItemAttributes('number');
useTraceItemAttributes(logsAttributeConfig, 'number');
const {attributes: booleanAttributes, secondaryAliases: booleanSecondaryAliases} =
useTraceItemAttributes('boolean');
useTraceItemAttributes(logsAttributeConfig, 'boolean');

const tracesItemSearchQueryBuilderProps = {
initialQuery: logsSearch.formatString(),
Expand Down
28 changes: 12 additions & 16 deletions static/app/components/events/ourlogs/ourlogsSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,10 @@ import {
LogsPageDataProvider,
useLogsPageDataQueryResult,
} from 'sentry/views/explore/contexts/logs/logsPageData';
import {TraceItemAttributeProvider} from 'sentry/views/explore/contexts/traceItemAttributeContext';
import {LOGS_DRAWER_QUERY_PARAM} from 'sentry/views/explore/logs/constants';
import {LogsQueryParamsProvider} from 'sentry/views/explore/logs/logsQueryParamsProvider';
import {LogRowContent} from 'sentry/views/explore/logs/tables/logsTableRow';
import {useQueryParamsSearch} from 'sentry/views/explore/queryParams/context';
import {TraceItemDataset} from 'sentry/views/explore/types';
import {SectionKey} from 'sentry/views/issueDetails/streamline/context';
import {InterimSection} from 'sentry/views/issueDetails/streamline/interimSection';

Expand Down Expand Up @@ -116,20 +114,18 @@ function OurlogsSectionContent({
freeze={traceId ? {traceId} : undefined}
>
<LogsPageDataProvider disabled={!traceId}>
<TraceItemAttributeProvider traceItemType={TraceItemDataset.LOGS} enabled>
<OurlogsDrawer
group={group}
event={event}
project={project}
embeddedOptions={
expandedLogId ? {openWithExpandedIds: [expandedLogId]} : undefined
}
additionalData={{
event,
scrollToDisabled: !!expandedLogId,
}}
/>
</TraceItemAttributeProvider>
<OurlogsDrawer
group={group}
event={event}
project={project}
embeddedOptions={
expandedLogId ? {openWithExpandedIds: [expandedLogId]} : undefined
}
additionalData={{
event,
scrollToDisabled: !!expandedLogId,
}}
/>
</LogsPageDataProvider>
</LogsQueryParamsProvider>
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,13 @@ export function useSpanSearchQueryBuilderProps(props: UseSpanSearchQueryBuilderP
spanSearchQueryBuilderProps: TraceItemSearchQueryBuilderProps;
spanSearchQueryBuilderProviderProps: UseTraceItemSearchQueryBuilderPropsReturnType;
} {
const spansConfig = {traceItemType: TraceItemDataset.SPANS, enabled: true};
const {tags: numberAttributes, secondaryAliases: numberSecondaryAliases} =
useTraceItemTags('number');
useTraceItemTags(spansConfig, 'number');
const {tags: stringAttributes, secondaryAliases: stringSecondaryAliases} =
useTraceItemTags('string');
useTraceItemTags(spansConfig, 'string');
const {tags: booleanAttributes, secondaryAliases: booleanSecondaryAliases} =
useTraceItemTags('boolean');
useTraceItemTags(spansConfig, 'boolean');

const stringAttributesWithSemver = useMemo(() => {
if (SpanFields.RELEASE in stringAttributes) {
Expand Down
8 changes: 4 additions & 4 deletions static/app/components/preprod/preprodSearchBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type {TagCollection} from 'sentry/types/group';
import useOrganization from 'sentry/utils/useOrganization';
import {TraceItemSearchQueryBuilder} from 'sentry/views/explore/components/traceItemSearchQueryBuilder';
import {HIDDEN_PREPROD_ATTRIBUTES} from 'sentry/views/explore/constants';
import {useTraceItemAttributesWithConfig} from 'sentry/views/explore/contexts/traceItemAttributeContext';
import {useTraceItemAttributes} from 'sentry/views/explore/contexts/traceItemAttributeContext';
import {TraceItemDataset} from 'sentry/views/explore/types';

interface PreprodSearchBarProps {
Expand Down Expand Up @@ -80,11 +80,11 @@ export function PreprodSearchBar({
const hiddenKeys = allowedKeys ? undefined : HIDDEN_PREPROD_ATTRIBUTES;

const {attributes: rawStringAttributes, secondaryAliases: rawStringSecondaryAliases} =
useTraceItemAttributesWithConfig(traceItemAttributeConfig, 'string', hiddenKeys);
useTraceItemAttributes(traceItemAttributeConfig, 'string', hiddenKeys);
const {attributes: rawNumberAttributes, secondaryAliases: rawNumberSecondaryAliases} =
useTraceItemAttributesWithConfig(traceItemAttributeConfig, 'number', hiddenKeys);
useTraceItemAttributes(traceItemAttributeConfig, 'number', hiddenKeys);
const {attributes: rawBooleanAttributes, secondaryAliases: rawBooleanSecondaryAliases} =
useTraceItemAttributesWithConfig(traceItemAttributeConfig, 'boolean', hiddenKeys);
useTraceItemAttributes(traceItemAttributeConfig, 'boolean', hiddenKeys);

const stringAttributes = useMemo(
() =>
Expand Down
152 changes: 63 additions & 89 deletions static/app/views/alerts/rules/metric/eapField.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import {render, screen, userEvent, waitFor} from 'sentry-test/reactTestingLibrar

import EAPField from 'sentry/views/alerts/rules/metric/eapField';
import {EventTypes} from 'sentry/views/alerts/rules/metric/types';
import {TraceItemAttributeProvider} from 'sentry/views/explore/contexts/traceItemAttributeContext';
import {TraceItemDataset} from 'sentry/views/explore/types';

describe('EAPField', () => {
const organization = OrganizationFixture();
Expand All @@ -21,13 +19,11 @@ describe('EAPField', () => {

it('renders', () => {
render(
<TraceItemAttributeProvider traceItemType={TraceItemDataset.SPANS} enabled>
<EAPField
aggregate="count(span.duration)"
onChange={() => {}}
eventTypes={[EventTypes.TRACE_ITEM_SPAN]}
/>
</TraceItemAttributeProvider>
<EAPField
aggregate="count(span.duration)"
onChange={() => {}}
eventTypes={[EventTypes.TRACE_ITEM_SPAN]}
/>
);
expect(fieldsMock).toHaveBeenCalledWith(
`/organizations/${organization.slug}/trace-items/attributes/`,
Expand All @@ -54,13 +50,11 @@ describe('EAPField', () => {

it('renders epm with argument disabled', () => {
render(
<TraceItemAttributeProvider traceItemType={TraceItemDataset.SPANS} enabled>
<EAPField
aggregate="epm()"
onChange={() => {}}
eventTypes={[EventTypes.TRACE_ITEM_SPAN]}
/>
</TraceItemAttributeProvider>
<EAPField
aggregate="epm()"
onChange={() => {}}
eventTypes={[EventTypes.TRACE_ITEM_SPAN]}
/>
);
expect(fieldsMock).toHaveBeenCalledWith(
`/organizations/${organization.slug}/trace-items/attributes/`,
Expand All @@ -81,13 +75,11 @@ describe('EAPField', () => {

it('renders failure_rate with argument disabled', () => {
render(
<TraceItemAttributeProvider traceItemType={TraceItemDataset.SPANS} enabled>
<EAPField
aggregate="failure_rate()"
onChange={() => {}}
eventTypes={[EventTypes.TRACE_ITEM_SPAN]}
/>
</TraceItemAttributeProvider>
<EAPField
aggregate="failure_rate()"
onChange={() => {}}
eventTypes={[EventTypes.TRACE_ITEM_SPAN]}
/>
);
expect(fieldsMock).toHaveBeenCalledWith(
`/organizations/${organization.slug}/trace-items/attributes/`,
Expand Down Expand Up @@ -115,13 +107,11 @@ describe('EAPField', () => {
it('should call onChange with the new aggregate string when switching aggregates', async () => {
const onChange = jest.fn();
render(
<TraceItemAttributeProvider traceItemType={TraceItemDataset.SPANS} enabled>
<EAPField
aggregate="count(span.duration)"
onChange={onChange}
eventTypes={[EventTypes.TRACE_ITEM_SPAN]}
/>
</TraceItemAttributeProvider>
<EAPField
aggregate="count(span.duration)"
onChange={onChange}
eventTypes={[EventTypes.TRACE_ITEM_SPAN]}
/>
);
expect(fieldsMock).toHaveBeenCalledWith(
`/organizations/${organization.slug}/trace-items/attributes/`,
Expand All @@ -144,13 +134,11 @@ describe('EAPField', () => {
function Component() {
const [aggregate, setAggregate] = useState('count(span.duration)');
return (
<TraceItemAttributeProvider traceItemType={TraceItemDataset.SPANS} enabled>
<EAPField
aggregate={aggregate}
onChange={setAggregate}
eventTypes={[EventTypes.TRACE_ITEM_SPAN]}
/>
</TraceItemAttributeProvider>
<EAPField
aggregate={aggregate}
onChange={setAggregate}
eventTypes={[EventTypes.TRACE_ITEM_SPAN]}
/>
);
}

Expand All @@ -177,13 +165,11 @@ describe('EAPField', () => {
function Component() {
const [aggregate, setAggregate] = useState('count(span.duration)');
return (
<TraceItemAttributeProvider traceItemType={TraceItemDataset.SPANS} enabled>
<EAPField
aggregate={aggregate}
onChange={setAggregate}
eventTypes={[EventTypes.TRACE_ITEM_SPAN]}
/>
</TraceItemAttributeProvider>
<EAPField
aggregate={aggregate}
onChange={setAggregate}
eventTypes={[EventTypes.TRACE_ITEM_SPAN]}
/>
);
}

Expand Down Expand Up @@ -212,13 +198,11 @@ describe('EAPField', () => {

it('renders count with argument disabled for logs', () => {
render(
<TraceItemAttributeProvider traceItemType={TraceItemDataset.LOGS} enabled>
<EAPField
aggregate="count(message)"
onChange={() => {}}
eventTypes={[EventTypes.TRACE_ITEM_LOG]}
/>
</TraceItemAttributeProvider>
<EAPField
aggregate="count(message)"
onChange={() => {}}
eventTypes={[EventTypes.TRACE_ITEM_LOG]}
/>
);
expect(fieldsMock).toHaveBeenCalledWith(
`/organizations/${organization.slug}/trace-items/attributes/`,
Expand Down Expand Up @@ -246,13 +230,11 @@ describe('EAPField', () => {
function Component() {
const [aggregate, setAggregate] = useState('count(message)');
return (
<TraceItemAttributeProvider traceItemType={TraceItemDataset.LOGS} enabled>
<EAPField
aggregate={aggregate}
onChange={setAggregate}
eventTypes={[EventTypes.TRACE_ITEM_LOG]}
/>
</TraceItemAttributeProvider>
<EAPField
aggregate={aggregate}
onChange={setAggregate}
eventTypes={[EventTypes.TRACE_ITEM_LOG]}
/>
);
}

Expand Down Expand Up @@ -281,13 +263,11 @@ describe('EAPField', () => {
function Component() {
const [aggregate, setAggregate] = useState('count(message)');
return (
<TraceItemAttributeProvider traceItemType={TraceItemDataset.LOGS} enabled>
<EAPField
aggregate={aggregate}
onChange={setAggregate}
eventTypes={[EventTypes.TRACE_ITEM_LOG]}
/>
</TraceItemAttributeProvider>
<EAPField
aggregate={aggregate}
onChange={setAggregate}
eventTypes={[EventTypes.TRACE_ITEM_LOG]}
/>
);
}

Expand Down Expand Up @@ -316,13 +296,11 @@ describe('EAPField', () => {
function Component() {
const [aggregate, setAggregate] = useState('count(span.duration)');
return (
<TraceItemAttributeProvider traceItemType={TraceItemDataset.SPANS} enabled>
<EAPField
aggregate={aggregate}
onChange={setAggregate}
eventTypes={[EventTypes.TRACE_ITEM_SPAN]}
/>
</TraceItemAttributeProvider>
<EAPField
aggregate={aggregate}
onChange={setAggregate}
eventTypes={[EventTypes.TRACE_ITEM_SPAN]}
/>
);
}

Expand All @@ -345,13 +323,11 @@ describe('EAPField', () => {
it('should call onChange with correct apdex aggregate when switching to apdex', async () => {
const onChange = jest.fn();
render(
<TraceItemAttributeProvider traceItemType={TraceItemDataset.SPANS} enabled>
<EAPField
aggregate="count(span.duration)"
onChange={onChange}
eventTypes={[EventTypes.TRACE_ITEM_SPAN]}
/>
</TraceItemAttributeProvider>
<EAPField
aggregate="count(span.duration)"
onChange={onChange}
eventTypes={[EventTypes.TRACE_ITEM_SPAN]}
/>
);

await userEvent.click(screen.getByText('count'));
Expand All @@ -368,16 +344,14 @@ describe('EAPField', () => {
function Component() {
const [aggregate, setAggregate] = useState('apdex(span.duration,300)');
return (
<TraceItemAttributeProvider traceItemType={TraceItemDataset.SPANS} enabled>
<EAPField
aggregate={aggregate}
onChange={newAggregate => {
setAggregate(newAggregate);
onChange(newAggregate, {});
}}
eventTypes={[EventTypes.TRACE_ITEM_SPAN]}
/>
</TraceItemAttributeProvider>
<EAPField
aggregate={aggregate}
onChange={newAggregate => {
setAggregate(newAggregate);
onChange(newAggregate, {});
}}
eventTypes={[EventTypes.TRACE_ITEM_SPAN]}
/>
);
}

Expand Down
Loading
Loading