Управление количеством транзакций в Sentry
22 июня 2023 г.
За количество транзакций в конфигурации sentry отвечает tracesSampleRate. Он принимает значения от 0 до 1. Например, значение 0.01 - 1% транзакций от всего потока.
Документация : https://docs.sentry.io/platforms/javascript/configuration/sampling/#setting-a-uniform-sample-rate
JavaScript
1Sentry.init({2 dsn: '',3 tracesSampleRate: 0.01,4});
Для более детальной фильтрации транзакций можно использовать tracesSampler.
JavaScript
1Sentry.init({2 <span class="comment">// ...</span>34 tracesSampler: samplingContext => {5 <span class="comment">// Examine provided context data (including parent decision, if any) along</span>6 <span class="comment">// with anything in the global namespace to compute the sample rate or</span>7 <span class="comment">// sampling decision for this transaction</span>89 if ("...") {10 <span class="comment">// These are important - take a big sample</span>11 return 1;12 } else if ("...") {13 <span class="comment">// These are less important or happen much more frequently - only take 1%</span>14 return 0.01;15 } else if ("...") {16 <span class="comment">// These aren't something worth tracking - drop all transactions like this</span>17 return 0;18 } else {19 <span class="comment">// Default sample rate</span>20 return 0.5;21 }22 };23});