React 应用程序的 Sentry 中的事务应该是什么

What should be an transaction in Sentry for React application

事务的概念在 Sentry 文档中有简要说明

还有这里https://docs.sentry.io/product/performance/transaction-summary/

我的问题是:对于客户端 (React) 应用程序

在 main/top-level 组件 created/rendered 时开始事务并在它被销毁时结束是否可以,因为知道用户可能会花费大量时间不与之交互browser/component 没有代码是运行? - 或者这不是交易的设计目的

希望现在还不算太晚,但发现问题的其他人可能会感兴趣:

不,这不是交易的设计目的。在 another part of the Sentry documentation 中有更详细的解释和一些示例(重点是我的):

A trace represents the record of the entire operation you want to measure or track - like page load, an instance of a user completing some action in your application, or a cron job in your backend. When a trace includes work in multiple services, such as those listed above, it's called a distributed trace, because the trace is distributed across those services.

Each trace consists of one or more tree-like structures called transactions, the nodes of which are called spans. In most cases, each transaction represents a single instance of a service being called, and each span within that transaction represents that service performing a single unit of work, whether calling a function within that service or making a call to a different service.

在您的 client-side 应用程序中,您可能对测量更感兴趣,例如(在 React 的情况下)从加载组件到加载数据并完成第一次渲染所花费的时间。您的事务可能是组件的渲染,由多个 span 组成(挂载、获取数据、渲染)。

理论上你当然可以做你想做的事,Sentry 允许你进行这些长时间的 运行 交易,例如检查option maxTransactionDuration 设置检测时(默认为 10 分钟,因此您的示例可能有效)。

如果您想知道人们在一个 screen/in 一个 widget/view 上停留了多长时间以及他们如何与之交互,您可以在其中收集这些事件的经典跟踪系统可能更重要你想要和需要。