Sentry (v20.12.1) k8s cloud native architecture exploration, sampling transactions of JavaScript performance monitoring

For less 2021-01-22 13:48:41
sentry v20.12.1 20.12.1 k8s cloud


series

  1. Sentry-Go SDK Chinese Practice Guide
  2. Let's brush together Sentry For Go Official document Enriching Events
  3. Snuba:Sentry New search infrastructure ( be based on ClickHouse above )
  4. Sentry 10 K8S Cloud native architecture exploration ,Vue App 1 Minutes fast access
  5. Sentry(v20.12.1) K8S Cloud native architecture exploration , Before you play / Back end monitoring and event log big data analysis , High performance and high availability + Scalable cluster deployment
  6. Sentry(v20.12.1) K8S Cloud native architecture exploration ,Sentry JavaScript SDK Three ways to install and load
  7. Sentry(v20.12.1) K8S Cloud native architecture exploration ,SENTRY FOR JAVASCRIPT SDK Configuration details
  8. Sentry(v20.12.1) K8S Cloud native architecture exploration , SENTRY FOR JAVASCRIPT Basic usage of manually capturing Events
  9. Sentry(v20.12.1) K8S Cloud native architecture exploration ,SENTRY FOR JAVASCRIPT Source Maps Detailed explanation
  10. Sentry(v20.12.1) K8S Cloud native architecture exploration ,SENTRY FOR JAVASCRIPT Troubleshooting
  11. Sentry(v20.12.1) K8S Cloud native architecture exploration ,1 Minutes to go JavaScript Performance monitoring
  12. Sentry(v20.12.1) K8S Cloud native architecture exploration ,JavaScript Management of performance monitoring Transactions

There are two ways you can control sending to Sentry Of transactions The amount of .

Uniform Sample Rate

If you wish transactions Of cross-section uniform , No matter where or under what circumstances you are in the application , And satisfied with the default inheritance and priority behavior described below , Setting a uniform sampling rate is a good choice .

So , Please put Sentry.init() Medium tracesSampleRate Option set to 0 To 1 A number between . After setting this option , Each created transaction There will be a percentage of opportunities sent to Sentry.( therefore , for example , If you will tracesSampleRate Set to 0.2, Will record and send about 20% Of transactions.) As shown below :

Sentry.init({
// ...
tracesSampleRate: 0.2,
});

Dynamic Sampling Function

If you meet the following conditions , The sampling function is a good choice :

  • Want to be different rates Sampling different transactions
  • Want to filter out some completely transactions
  • To modify the default priority and inheritance behavior described below

To do dynamic sampling , Please put Sentry.init() Medium tracesSampler Option is set to a function , This function will accept samplingContext Object and return 0 To 1 The sampling rate between . for example :

Sentry.init({
// ...
tracesSampler: samplingContext => {
// Examine provided context data (including parent decision, if any) along
// with anything in the global namespace to compute the sample rate or
// sampling decision for this transaction
if ("...") {
// These are important - take a big sample
return 0.5;
} else if ("...") {
// These are less important or happen much more frequently - only take 1%
return 0.01;
} else if ("...") {
// These aren't something worth tracking - drop all transactions like this
return 0;
} else {
// Default sample rate
return 0.1;
}
};
});

For convenience , This function can also return Boolean values . return true Equal to return to 1, And guarantee that transaction Will be sent to Sentry. return false Equal to return to 0, This will ensure that transaction Send to Sentry.

Default Sampling Context Data

establish transaction when , Pass to tracesSampler Of samplingContext The information contained in the object varies by platform and integration .

For browser based SDK, It includes at least the following :

// contents of `samplingContext`
{
transactionContext: {
name: string; // human-readable identifier, like "GET /users"
op: string; // short description of transaction type, like "pageload"
}
parentSampled: boolean; // if this transaction has a parent, its sampling decision
location: Location | WorkerLocation; // the window.location or self.location object
... // custom context as passed to `startTransaction`
}

Custom Sampling Context Data

Manually create transaction when , You can pass the data as an optional second parameter to startTransaction To add data to samplingContext. If you want the sampler to be accessible but don't want it to be tags or data Attach to transaction Data in ( For example, sensitive information or too large to follow transaction Messages sent ), This will be very useful . for example :

Sentry.startTransaction(
{
// `transactionContext` - will be recorded on transaction
name: 'Search from navbar',
op: 'search',
tags: {
testGroup: 'A3',
treatmentName: 'eager load',
},
},
// `customSamplingContext` - won't be recorded
{
// PII
userId: '12312012',
// too big to send
resultsFromLastSearch: { ... }
},
);

Inheritance

No matter what transaction What is the sampling decision of , The decision will be passed on to child spans, And from there to any... That they subsequently cause in other services transactions.( More about how to complete the dissemination , Please see the Connecting Backend and Frontend Transactions.)

If you are currently creating transaction It's the follow-up transactions One of ( let me put it another way , If it has a father transaction), Then upstream ( Father ) Sampling decisions will always be included in the sampling context data , So that your tracesSampler Choose whether and when to inherit the decision .( in the majority of cases , Inheritance is the right choice , So there's no partial tracking .)

In some SDK in , For convenience ,tracesSampler Function can return a Boolean value , such , If this is the expected behavior , You can return to the parent's decision directly .

tracesSampler: samplingContext => {
// always inherit
if (samplingContext.parentSampled !== undefined) {
return samplingContext.parentSampled
}
...
// rest of sampling logic here
}

If you are using tracesSampleRate instead of tracesSampler , Then the decision will always be inherited .

Forcing a Sampling Decision

If in transaction When you create it, you know if you want to transaction Send to Sentry, You can also choose to pass the sampling decision directly to transaction Constructors ( Please note that , be not in customSamplingContext In the object ). If you do , be transaction Will not accept tracesSampleRate Constraints , And it won't run tracesSampler, So you can count on the decisions passed not to be covered .

Sentry.startTransaction({
name: "Search from navbar",
sampled: true,
});

Precedence

transaction There are many ways to make sampling decisions .

  • Based on tracesSampleRate Random sampling at the static sampling rate set in
  • according to tracesSampler Return the dynamic sampling rate for random sampling
  • tracesSampler The absolute decision of return (100% Opportunity or 0% The opportunity to )
  • If transaction There's a parent , Then it inherits the sampling decision of its parent
  • Absolute decision-making power is passed on to startTransaction

When more than one situation is possible , The following priority rules should be followed :

  1. If you pass the sampling decision to startTransaction( See... Above Forcing a Sampling Decision), Regardless of any other factor , Will use that decision .
  2. If you define tracesSampler , Will use its decision . It can choose to keep or ignore any parent sampling decision , Or use sampling context data to make your own decisions , Or for transaction Choose a sampling rate .
  3. If not defined tracesSampler, But there is a parent sampling decision , Then the parent sampling decision is used .
  4. If not defined tracesSampler And there is no parent sampling decision , Will use tracesSampleRate.

Chinese documents are synchronized to :

 I'm for less .
WeChat :uuhells123.
official account : Hacker afternoon tea .
Thank you for your support !
版权声明
本文为[For less]所创,转载请带上原文链接,感谢
https://javamana.com/2021/01/20210122134609095v.html

  1. 【计算机网络 12(1),尚学堂马士兵Java视频教程
  2. 【程序猿历程,史上最全的Java面试题集锦在这里
  3. 【程序猿历程(1),Javaweb视频教程百度云
  4. Notes on MySQL 45 lectures (1-7)
  5. [computer network 12 (1), Shang Xuetang Ma soldier java video tutorial
  6. The most complete collection of Java interview questions in history is here
  7. [process of program ape (1), JavaWeb video tutorial, baidu cloud
  8. Notes on MySQL 45 lectures (1-7)
  9. 精进 Spring Boot 03:Spring Boot 的配置文件和配置管理,以及用三种方式读取配置文件
  10. Refined spring boot 03: spring boot configuration files and configuration management, and reading configuration files in three ways
  11. 精进 Spring Boot 03:Spring Boot 的配置文件和配置管理,以及用三种方式读取配置文件
  12. Refined spring boot 03: spring boot configuration files and configuration management, and reading configuration files in three ways
  13. 【递归,Java传智播客笔记
  14. [recursion, Java intelligence podcast notes
  15. [adhere to painting for 386 days] the beginning of spring of 24 solar terms
  16. K8S系列第八篇(Service、EndPoints以及高可用kubeadm部署)
  17. K8s Series Part 8 (service, endpoints and high availability kubeadm deployment)
  18. 【重识 HTML (3),350道Java面试真题分享
  19. 【重识 HTML (2),Java并发编程必会的多线程你竟然还不会
  20. 【重识 HTML (1),二本Java小菜鸟4面字节跳动被秒成渣渣
  21. [re recognize HTML (3) and share 350 real Java interview questions
  22. [re recognize HTML (2). Multithreading is a must for Java Concurrent Programming. How dare you not
  23. [re recognize HTML (1), two Java rookies' 4-sided bytes beat and become slag in seconds
  24. 造轮子系列之RPC 1:如何从零开始开发RPC框架
  25. RPC 1: how to develop RPC framework from scratch
  26. 造轮子系列之RPC 1:如何从零开始开发RPC框架
  27. RPC 1: how to develop RPC framework from scratch
  28. 一次性捋清楚吧,对乱糟糟的,Spring事务扩展机制
  29. 一文彻底弄懂如何选择抽象类还是接口,连续四年百度Java岗必问面试题
  30. Redis常用命令
  31. 一双拖鞋引发的血案,狂神说Java系列笔记
  32. 一、mysql基础安装
  33. 一位程序员的独白:尽管我一生坎坷,Java框架面试基础
  34. Clear it all at once. For the messy, spring transaction extension mechanism
  35. A thorough understanding of how to choose abstract classes or interfaces, baidu Java post must ask interview questions for four consecutive years
  36. Redis common commands
  37. A pair of slippers triggered the murder, crazy God said java series notes
  38. 1、 MySQL basic installation
  39. Monologue of a programmer: despite my ups and downs in my life, Java framework is the foundation of interview
  40. 【大厂面试】三面三问Spring循环依赖,请一定要把这篇看完(建议收藏)
  41. 一线互联网企业中,springboot入门项目
  42. 一篇文带你入门SSM框架Spring开发,帮你快速拿Offer
  43. 【面试资料】Java全集、微服务、大数据、数据结构与算法、机器学习知识最全总结,283页pdf
  44. 【leetcode刷题】24.数组中重复的数字——Java版
  45. 【leetcode刷题】23.对称二叉树——Java版
  46. 【leetcode刷题】22.二叉树的中序遍历——Java版
  47. 【leetcode刷题】21.三数之和——Java版
  48. 【leetcode刷题】20.最长回文子串——Java版
  49. 【leetcode刷题】19.回文链表——Java版
  50. 【leetcode刷题】18.反转链表——Java版
  51. 【leetcode刷题】17.相交链表——Java&python版
  52. 【leetcode刷题】16.环形链表——Java版
  53. 【leetcode刷题】15.汉明距离——Java版
  54. 【leetcode刷题】14.找到所有数组中消失的数字——Java版
  55. 【leetcode刷题】13.比特位计数——Java版
  56. oracle控制用户权限命令
  57. 三年Java开发,继阿里,鲁班二期Java架构师
  58. Oracle必须要启动的服务
  59. 万字长文!深入剖析HashMap,Java基础笔试题大全带答案
  60. 一问Kafka就心慌?我却凭着这份,图灵学院vip课程百度云