Skip to content

Commit 0e4ec1f

Browse files
feat(dynamic-sampling): Add 'Prioritize transaction names' option
1 parent aeefd28 commit 0e4ec1f

File tree

3 files changed

+67
-0
lines changed

3 files changed

+67
-0
lines changed

static/app/types/sampling.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ export enum DynamicSamplingBiasType {
22
BOOST_ENVIRONMENTS = 'boostEnvironments',
33
BOOST_LATEST_RELEASES = 'boostLatestRelease',
44
BOOST_KEY_TRANSACTIONS = 'boostKeyTransactions',
5+
BOOST_TRANSACTION_NAMES = 'prioritiseByTxName',
56
IGNORE_HEALTH_CHECKS = 'ignoreHealthChecks',
67
}
78

static/app/views/settings/project/dynamicSampling/dynamicSampling.spec.tsx

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ describe('Dynamic Sampling', function () {
8080

8181
expect(ignoreHealthChecks).toBeEnabled();
8282
expect(ignoreHealthChecks).toBeChecked();
83+
84+
// Prioritize transaction names is not available
85+
expect(
86+
screen.queryByRole('checkbox', {name: 'Prioritize transaction names'})
87+
).not.toBeInTheDocument();
8388
});
8489

8590
it('renders disabled default UI, when user has not permission to edit', async function () {
@@ -174,4 +179,50 @@ describe('Dynamic Sampling', function () {
174179
})
175180
);
176181
});
182+
183+
it('render and toggle "Prioritize transaction names" option', function () {
184+
const {project, organization} = initializeOrg({
185+
...initializeOrg(),
186+
projects: [
187+
TestStubs.Project({
188+
dynamicSamplingBiases: [
189+
...dynamicSamplingBiases,
190+
{id: DynamicSamplingBiasType.BOOST_TRANSACTION_NAMES, active: false},
191+
],
192+
}),
193+
],
194+
organization: {
195+
...initializeOrg().organization,
196+
features: [...ORG_FEATURES, 'dynamic-sampling-transaction-name-priority'],
197+
},
198+
});
199+
200+
const mockRequests = renderMockRequests(organization.slug, project.slug);
201+
202+
render(<DynamicSampling project={project} />, {organization});
203+
204+
const prioritizeTransactionNames = screen.getByRole('checkbox', {
205+
name: 'Prioritize transaction names',
206+
});
207+
208+
expect(prioritizeTransactionNames).toBeEnabled();
209+
expect(prioritizeTransactionNames).not.toBeChecked();
210+
211+
userEvent.click(screen.getByRole('checkbox', {name: 'Prioritize transaction names'}));
212+
213+
expect(mockRequests.projectDetails).toHaveBeenCalledWith(
214+
`/projects/${organization.slug}/${project.slug}/`,
215+
expect.objectContaining({
216+
data: {
217+
dynamicSamplingBiases: [
218+
{id: DynamicSamplingBiasType.BOOST_LATEST_RELEASES, active: true},
219+
{id: DynamicSamplingBiasType.BOOST_ENVIRONMENTS, active: true},
220+
{id: DynamicSamplingBiasType.BOOST_KEY_TRANSACTIONS, active: true},
221+
{id: DynamicSamplingBiasType.IGNORE_HEALTH_CHECKS, active: true},
222+
{id: DynamicSamplingBiasType.BOOST_TRANSACTION_NAMES, active: true},
223+
],
224+
},
225+
})
226+
);
227+
});
177228
});

static/app/views/settings/project/dynamicSampling/dynamicSampling.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ export const knowDynamicSamplingBiases = {
4848
label: t('Prioritize key transactions'),
4949
help: t('Captures more of your most important (starred) transactions'),
5050
},
51+
[DynamicSamplingBiasType.BOOST_TRANSACTION_NAMES]: {
52+
label: t('Prioritize transaction names'),
53+
help: t("Balance high-volume endpoints so they don't drown out low-volume ones"),
54+
},
5155
[DynamicSamplingBiasType.IGNORE_HEALTH_CHECKS]: {
5256
label: t('Ignore health checks'),
5357
help: t('Discards your health checks transactions'),
@@ -58,6 +62,9 @@ export function DynamicSampling({project}: Props) {
5862
const organization = useOrganization();
5963
const api = useApi();
6064

65+
const hasTransactionNamePriorityFlag = organization.features.includes(
66+
'dynamic-sampling-transaction-name-priority'
67+
);
6168
const hasAccess = organization.access.includes('project:write');
6269
const biases = project.dynamicSamplingBiases ?? [];
6370

@@ -149,6 +156,14 @@ export function DynamicSampling({project}: Props) {
149156
return null;
150157
}
151158

159+
// "Prioritize Transaction Names" is only available to orgs with the feature flag
160+
if (
161+
!hasTransactionNamePriorityFlag &&
162+
key === DynamicSamplingBiasType.BOOST_TRANSACTION_NAMES
163+
) {
164+
return null;
165+
}
166+
152167
return (
153168
<BooleanField
154169
{...value}

0 commit comments

Comments
 (0)