Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(performance): Update queues module samples panel to support displaying producer samples. #70637

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export function DurationChart({
error={error}
chartColors={[AVG_COLOR]}
type={ChartType.LINE}
aggregateOutputFormat="duration"
/>
</ChartPanel>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import Onboarding from 'sentry/views/performance/onboarding';
import {LatencyChart} from 'sentry/views/performance/queues/charts/latencyChart';
import {ThroughputChart} from 'sentry/views/performance/queues/charts/throughputChart';
import {TransactionsTable} from 'sentry/views/performance/queues/destinationSummary/transactionsTable';
import {MessageConsumerSamplesPanel} from 'sentry/views/performance/queues/messageConsumerSamplesPanel';
import {MessageSamplesPanel} from 'sentry/views/performance/queues/messageSamplesPanel';
import {useQueuesMetricsQuery} from 'sentry/views/performance/queues/queries/useQueuesMetricsQuery';
import {
DESTINATION_TITLE,
Expand Down Expand Up @@ -155,7 +155,7 @@ function DestinationSummaryPage() {
</ModuleLayout.Layout>
</Layout.Main>
</Layout.Body>
<MessageConsumerSamplesPanel />
<MessageSamplesPanel />
</Fragment>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ function renderBodyCell(
}

if (key === 'transaction') {
return <TransactionCell transaction={row[key]} />;
return <TransactionCell transaction={row[key]} op={op} />;
}

if (!meta?.fields) {
Expand Down Expand Up @@ -179,12 +179,13 @@ function renderBodyCell(
});
}

function TransactionCell({transaction}: {transaction: string}) {
function TransactionCell({transaction, op}: {op: string; transaction: string}) {
const organization = useOrganization();
const {query} = useLocation();
const queryString = {
...query,
transaction,
'span.op': op,
};
return (
<NoOverflow>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import {render, screen, waitForElementToBeRemoved} from 'sentry-test/reactTestin
import {useLocation} from 'sentry/utils/useLocation';
import useOrganization from 'sentry/utils/useOrganization';
import usePageFilters from 'sentry/utils/usePageFilters';
import {MessageConsumerSamplesPanel} from 'sentry/views/performance/queues/messageConsumerSamplesPanel';
import {MessageSamplesPanel} from 'sentry/views/performance/queues/messageSamplesPanel';

jest.mock('sentry/utils/useLocation');
jest.mock('sentry/utils/usePageFilters');
jest.mock('sentry/utils/useOrganization');

describe('messageConsumerSamplesPanel', () => {
describe('messageSamplesPanel', () => {
const organization = OrganizationFixture();

let eventsRequestMock, eventsStatsRequestMock, samplesRequestMock;
Expand Down Expand Up @@ -85,8 +85,93 @@ describe('messageConsumerSamplesPanel', () => {
jest.resetAllMocks();
});

it('renders', async () => {
render(<MessageConsumerSamplesPanel />);
it('renders consumer panel', async () => {
jest.mocked(useLocation).mockReturnValue({
pathname: '',
search: '',
query: {
transaction: 'sentry.tasks.store.save_event',
destination: 'event-queue',
'span.op': 'queue.process',
},
hash: '',
state: undefined,
action: 'PUSH',
key: '',
});
render(<MessageSamplesPanel />);
await waitForElementToBeRemoved(() => screen.queryAllByTestId('loading-indicator'));
expect(eventsStatsRequestMock).toHaveBeenCalled();
expect(eventsRequestMock).toHaveBeenCalledWith(
`/organizations/${organization.slug}/events/`,
expect.objectContaining({
method: 'GET',
query: expect.objectContaining({
dataset: 'spansMetrics',
environment: [],
field: [
'count()',
'count_op(queue.publish)',
'count_op(queue.process)',
'sum(span.duration)',
'avg(span.duration)',
'avg_if(span.duration,span.op,queue.publish)',
'avg_if(span.duration,span.op,queue.process)',
'avg(messaging.message.receive.latency)',
],
per_page: 10,
project: [],
query:
'span.op:[queue.process,queue.publish] messaging.destination.name:event-queue transaction:sentry.tasks.store.save_event',
statsPeriod: '10d',
}),
})
);
expect(samplesRequestMock).toHaveBeenCalledWith(
`/api/0/organizations/${organization.slug}/spans-samples/`,
expect.objectContaining({
query: expect.objectContaining({
additionalFields: [
'trace',
'transaction.id',
'span.description',
'measurements.messaging.message.body.size',
'measurements.messaging.message.receive.latency',
'measurements.messaging.message.retry.count',
'messaging.message.id',
'trace.status',
'span.duration',
],
firstBound: 2666.6666666666665,
lowerBound: 0,
project: [],
query:
'span.op:queue.process transaction:sentry.tasks.store.save_event messaging.destination.name:event-queue',
referrer: undefined,
secondBound: 5333.333333333333,
statsPeriod: '10d',
upperBound: 8000,
}),
})
);
expect(screen.getByRole('table', {name: 'Span Samples'})).toBeInTheDocument();
});

it('renders producer panel', async () => {
jest.mocked(useLocation).mockReturnValue({
pathname: '',
search: '',
query: {
transaction: 'sentry.tasks.store.save_event',
destination: 'event-queue',
'span.op': 'queue.publish',
},
hash: '',
state: undefined,
action: 'PUSH',
key: '',
});
render(<MessageSamplesPanel />);
await waitForElementToBeRemoved(() => screen.queryAllByTestId('loading-indicator'));
expect(eventsStatsRequestMock).toHaveBeenCalled();
expect(eventsRequestMock).toHaveBeenCalledWith(
Expand Down Expand Up @@ -124,6 +209,7 @@ describe('messageConsumerSamplesPanel', () => {
'span.description',
'measurements.messaging.message.body.size',
'measurements.messaging.message.receive.latency',
'measurements.messaging.message.retry.count',
'messaging.message.id',
'trace.status',
'span.duration',
Expand All @@ -132,7 +218,7 @@ describe('messageConsumerSamplesPanel', () => {
lowerBound: 0,
project: [],
query:
'span.op:queue.process OR span.op:queue.publish transaction:sentry.tasks.store.save_event messaging.destination.name:event-queue',
'span.op:queue.publish transaction:sentry.tasks.store.save_event messaging.destination.name:event-queue',
referrer: undefined,
secondBound: 5333.333333333333,
statsPeriod: '10d',
Expand Down