A series of

  1. Sentry-go SDK Chinese Practice Guide
  2. Plan together according to official documents in Sentry For Go
  3. Snuba: Sentry’s new search infrastructure (based on ClickHouse)
  4. Sentry 10 K8S cloud native architecture exploration, fast access to Vue App in 1 minute
  5. Sentry(V20.12.1) K8S cloud native architecture exploration, play forward/back end monitoring and event log big data analysis, high performance + high availability + scalable + 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

Basic usage

The Sentry SDK hooks into your runtime environment and automatically reports errors, exceptions, and rejections.

Key terms:

  • An event is an instance of sending data to a Sentry. Typically, this data is an error (error) or exception (exception).
  • An issue is a group of similar events.
  • Reporting of events is called capturing. Once the event is captured, it is sent to Sentry.

The most common form of capture is capture errors. The errors that can be caught vary from platform to platform. Usually, if you have something that looks like an exception, it can be caught. For some SDKS, you can also omit the capture_exception argument, and Sentry will attempt to catch the current exception. It is also useful for manually reporting errors or messages to the Sentry.

When you capture an event, you can also record the breadcrumbs that caused the event. Breadcrumbs are different from events: they do not create events in Sentry, but are buffered before the next event is sent. Learn more about crumbs in our Breadcrumbs Documentation.

Capture the error

In JavaScript, you can pass an error object to captureException() to capture it as an event. A string can be thrown as an error, in which case no traceback can be recorded.

try {
  aFunctionThatMightFail();
} catch (err) {
  Sentry.captureException(err);
}
Copy the code

Catching bare messages

Another common operation is to catch bare messages. A message is a text message that should be sent to Sentry. Usually, messages don’t go out, but they can be useful to some teams.

Sentry.captureMessage("Something went wrong");
Copy the code

Setting the Event Level

Level — similar to logging level — is usually added by default based on integration. You can also override it in the event.

To set the level outside the scope, you can call captureMessage() for each event:

Sentry.captureMessage("this is a debug message"."debug");
Copy the code

To set the level within the scope, you can call setLevel() :

Sentry.configureScope(function(scope) {
  scope.setLevel(Sentry.Severity.Warning);
});
Copy the code

Or each event:

Sentry.withScope(function(scope) {
  scope.setLevel("info");
  Sentry.captureException("info");
});
Copy the code

Chinese documents have been synchronized to:

  • getsentry.hacker-linner.com
I am for less. Wechat: uuhells123. Public account: Hacker afternoon tea. Thank you for your support 👍👍👍!Copy the code