io.sentry_Sentry.io错误跟踪入门
io.sentry
This article was created in partnership with Sentry. Thank you for supporting the partners who make SitePoint possible.
本文是与Sentry合作创建的。 感谢您支持使SitePoint成为可能的合作伙伴。
Writing code can be fun. Testing it is another matter. Of course, SitePoint readers always produce bug-free applications but errors can still slip into the best production code. How can you detect those issues?…
编写代码可能很有趣。 测试它是另一回事。 当然,SitePoint读取器始终会生成无错误的应用程序,但是错误仍然会渗入最佳的生产代码中。 您如何发现这些问题?…
测验 (Tests)
Writing software to test software is one option. Unit and integration testing can be adopted to verify functions and interfaces accordingly. Unfortunately:
编写软件以测试软件是一种选择。 可以采用单元和集成测试来相应地验证功能和接口。 不幸:
- It can be difficult to write tests when product requirements are evolving. 当产品要求不断变化时,编写测试可能很困难。
- Are you sure your tests cover every option and pathway? 您确定测试涵盖所有选项和途径吗?
- Who’s testing your tests? 谁在测试您的测试?
Tests help, but the industry still releases software with bugs because it’s impossible to cover every eventually. Does a bug occur in a certain browser, on a particular OS, at a specific time of day?
测试是有帮助的,但是行业仍然会发布带有错误的软件,因为不可能最终涵盖所有内容。 是否会在一天的特定时间在特定浏览器,特定操作系统上发生错误?
In addition, browser testing is notoriously complicated owing to:
此外,由于以下原因,浏览器测试非常复杂。
-
Multiple devices and applications. There’s a long tail of old, new, and obscure browsers across desktop PCs, tablets, smartphones, TVs, games consoles, smart watches, IoT devices, and more. It’s impossible to test everything.
多种设备和应用程序 。 跨台式机,平板电脑,智能手机,电视,游戏机,智能手表,IoT设备等的旧的,新的和晦涩的浏览器有很长的尾巴。 无法测试所有内容。
-
User control. Any user can choose whether to download, block or modify any part of your application. For example, Firefox will block Google Analytics when tracking is disabled; recording an Analytics event could cause the whole application to fail.
用户控制 。 任何用户都可以选择是否下载,阻止或修改应用程序的任何部分。 例如,当禁用跟踪时,Firefox将阻止Google Analytics(分析)。 记录Analytics事件可能会导致整个应用程序失败。
-
Network failures. Even if the user permits every file you throw at them, there’s no guarantee they’ll receive all images, CSS, JavaScript and other assets. Travelling or using flaky hotel wi-fi exacerbates the problem.
网络故障 。 即使用户允许您扔给他们的每个文件,也不能保证他们会收到所有图像,CSS,JavaScript和其他资产。 旅行或使用片状的酒店Wi-Fi加剧了这个问题。
用户反馈 (User Feedback)
Have you ever watched someone using your software? They always do something you never expected. I wince every time I see someone enter a URL into the Google.com search box.
您曾经看过有人在使用您的软件吗? 他们总是做一些您没想到的事情。 每当我看到有人在Google.com搜索框中输入网址时,我都会畏缩。
Humans are adept at finding their own methods to complete tasks based on previous experience. Those processes may or may not be efficient, but they’ll rarely match your expectations because your experiences are different. A bug may occur because a sequence of tasks is tackled in a manner that seems illogical to you.
人类会根据先前的经验来找到适合自己的方法来完成任务。 这些流程可能有效,也可能无效,但由于您的体验不同,因此它们很少达到您的期望。 可能会发生错误,因为按照对您似乎不合逻辑的方式解决了一系列任务。
Additionally, the majority of users will never report a bug. They won’t know whether the fault occurred in your app, the browser, or the OS. Many may blame themselves, will not know who to contact, or simply switch to a competing product.
此外,大多数用户将永远不会报告错误。 他们不知道故障是否发生在您的应用程序,浏览器或操作系统中。 许多人可能会自责,不知道与谁联系,或者只是转而使用竞争产品。
Users who do report issues will rarely be able to describe the problem unless they have software engineering expertise. It’s frustrating to be faced with dozens of “ProductX doesn’t work” issue tickets.
除非有软件工程专业知识,否则报告问题的用户将很少能够描述问题。 面对数十张“ ProductX不起作用”发行票, 真令人沮丧。
Ultimately, should we rely on customers to report problems?
最终,我们应该依靠客户来报告问题吗?
记录中 (Logging)
Logging errors is a possibility but:
记录错误是可能的,但是:
- How do you log errors that are completely unexpected? 您如何记录完全意外的错误?
- Will the logging code still run if your application fails? 如果您的应用程序失败,日志记录代码是否仍将运行?
- How do you log errors in environments outside your control, such as a browser? 您如何在您无法控制的环境(例如浏览器)中记录错误?
- A single error could be logged tens of thousands of times after deployment. Identifying critical flaws amongst known problems can be difficult. 部署后,单个错误可能被记录数万次。 在已知问题中识别关键缺陷可能很困难。
Fortunately, Sentry.io provides a logging-on-steroids solution which can capture the most obscure problems.
幸运的是, Sentry.io提供了一个类固醇测井解决方案,可以捕获最隐蔽的问题。
Sentry.io快速入门 (Sentry.io Quickstart)
Sentry.io is an open-source full-stack error tracking system which supports a wide range of server, browser, desktop and native mobile languages and frameworks including PHP, Node.js, Python, Ruby, C#, Java, Go, React, Angular, Vue, JavaScript and more. The system is used by Dropbox, AirBnB, PayPal, Uber, reddit, Mozilla, MailChimp, and Microsoft to monitor thousands of applications.
Sentry.io是开源的全栈错误跟踪系统,它支持各种服务器,浏览器,桌面和本机移动语言以及框架,包括PHP,Node.js,Python,Ruby,C#,Java,Go,React, Angular,Vue,JavaScript等。 Dropbox,AirBnB,PayPal,Uber,reddit,Mozilla,MailChimp和Microsoft使用该系统监视数千个应用程序。
Sentry.io developer accounts are free with commercial options for larger teams generating thousands of events across multiple projects. You can sign-up quickly using a GitHub, Azure DevOps, or Sentry.io account.
Sentry.io开发人员帐户免费提供商业选项,大型团队可以在多个项目中生成数千个事件。 您可以登录了快速使用GitHub上,天青的DevOps,或Sentry.io帐户。
On log-in, you’ll be prompted to start a new project by entering its name and choosing a technology:
登录时,系统会提示您输入新名称并选择一种技术来启动新项目:
You will then be issued with code to insert into your application. A typical example for client-side JavaScript requires a couple of new lines:
然后将向您发出插入到您的应用程序中的代码。 客户端JavaScript的一个典型示例需要几行新内容:
You may need to set-up multiple monitors to detect issues in your application’s browser UI, mobile app, and back-end server at the same time.
您可能需要设置多个监视器,以同时检测应用程序的浏览器UI,移动应用程序和后端服务器中的问题。
The whole process takes a few minutes. Once your application is deployed, any errors encountered by users – whether they are aware of them or not – are automatically captured and tracked in real time on the Sentry.io issue stream:
整个过程需要几分钟。 部署应用程序后,用户遇到的任何错误( 无论他们是否意识到)都将自动自动捕获并在Sentry.io问题流中进行实时跟踪:
Identical problems are presented as a single entry which reports how many times it was triggered and how many users were affected. Further details can be examined to determine the product version, issue severity, OS, browser, IP address, dates, call stack, etc:
相同的问题以单个条目的形式出现,该条目报告了触发该事件的次数以及受影响的用户数。 可以检查更多详细信息以确定产品版本,问题严重性,操作系统,浏览器,IP地址,日期,呼叫堆栈等:
Sentry.io features beyond the basics include:
Sentry.io的基本功能之外包括:
- configuration settings to define release versions, code repositories, server names, URLs, etc. 配置设置,用于定义发行版本,代码存储库,服务器名称,URL等。
- user information, messages, tagging, and custom events 用户信息,消息,标记和定制事件
- user feedback widgets to record further information 用户反馈小部件以记录更多信息
- inbound message filtering rules 入站邮件过滤规则
- issue assigning to team members 分配给团队成员的问题
- bookmarking, resolving, ignoring, sharing and deleting issues 为书签添加书签,解决,忽略,共享和删除问题
- activity and issue reports 活动和问题报告
- a command-line executable to report OS or build issues 报告操作系统或构建问题的命令行可执行文件
- a full API to submit, retrieve, update, delete and manage event data 完整的API,用于提交,检索,更新,删除和管理事件数据
- on-premise installations 本地安装
- robust security with optional two-factor authentication 具有可选的两因素身份验证的强大安全性
- chat integration with Slack, HipChat and others 与Slack,HipChat和其他聊天集成
- commercial and community support options. 商业和社区支持选项。
Sentry.io is logging more than 20 billion errors per month (mostly from my code!) Developer accounts are free and include 5,000 errors per month. Employ Sentry.io as the newest member of your Q&A team today!
Sentry.io每月记录超过200亿个错误(大部分来自我的代码!),开发人员帐户免费,每月包含5,000个错误。 聘请Sentry.io作为您的问答团队的最新成员 !
翻译自: https://www.sitepoint.com/getting-started-with-sentry-io-error-tracking/
io.sentry