MCPcopy
hub / github.com/getsentry/sentry / DynamicSamplingRulesTable

Function DynamicSamplingRulesTable

static/gsAdmin/views/dynamicSamplingPanel.tsx:323–420  ·  view source on GitHub ↗
({
  baseSampleRate,
  searchQuery,
  rules = [],
}: DynamicSamplingRulesTableProps)

Source from the content-addressed store, hash-verified

321};
322
323function DynamicSamplingRulesTable({
324 baseSampleRate,
325 searchQuery,
326 rules = [],
327}: DynamicSamplingRulesTableProps) {
328 const round = (value: number) => Math.round(value * 10000) / 10000;
329
330 const formatSamplingRateValue = (samplingValue: any) => {
331 if (
332 samplingValue.type === 'sampleRate' ||
333 samplingValue.type === 'minimumSampleRate'
334 ) {
335 return `${round(samplingValue.value * 100)}%`;
336 }
337 return `* ${round(samplingValue.value)}`;
338 };
339
340 const evaluateRuleImpact = (rule: RuleV2) => {
341 if (getRuleType(rule) === RuleType.BOOST_LOW_VOLUME_PROJECTS) {
342 return 0;
343 }
344 if (
345 rule.samplingValue.type === 'sampleRate' ||
346 rule.samplingValue.type === 'minimumSampleRate'
347 ) {
348 return round(rule.samplingValue.value - baseSampleRate);
349 }
350 return round(rule.samplingValue.value - 1);
351 };
352
353 const dynamicSamplingRules = rules
354 .map(rule => {
355 return {
356 ...rule,
357 formattedRateValue: formatSamplingRateValue(rule.samplingValue),
358 formattedRateType: startCase(rule.samplingValue.type),
359 type: getRuleType(rule),
360 target: getStringifiedCondition(rule.condition),
361 impact: evaluateRuleImpact(rule),
362 };
363 })
364
365 // eslint-disable-next-line @typescript-eslint/no-base-to-string
366 .filter(row => Object.values(row).join().toLowerCase().includes(searchQuery));
367
368 return (
369 <Fragment>
370 <DSRulesTable
371 headers={['Name', 'Type', 'Value', 'Target']}
372 isEmpty={!dynamicSamplingRules.length}
373 emptyMessage="No dynamic sampling rules to display"
374 >
375 {dynamicSamplingRules.map(row => (
376 <Fragment key={row.id}>
377 <Stack gap="xs">
378 {row.type}
379 {defined(row.timeRange) && (
380 <div data-test-id="timerange">

Callers

nothing calls this directly

Calls 8

definedFunction · 0.90
formatSamplingRateValueFunction · 0.85
getRuleTypeFunction · 0.85
getStringifiedConditionFunction · 0.85
evaluateRuleImpactFunction · 0.85
filterMethod · 0.45
joinMethod · 0.45
valuesMethod · 0.45

Tested by

no test coverage detected