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

Basic usage

Sentry Of SDK Hook into your runtime environment , And automatically report errors (errors)、 abnormal (exceptions) And refuse to (rejections).

Key terms :

  • event Is to Sentry An example of sending data . Usually , The data is an error (error) Or abnormal (exception).
  • issue It’s a set of similar events .
  • The report of the incident is called capturing. After capturing the event , It will be sent to Sentry.

The most common form of capture is capture errors (capture errors). The errors that can be caught vary from platform to platform . Usually , If you have something that looks like an exception (exception) Things that are , It can be captured . For certain SDK, You can also omit capture_exception Parameters of ,Sentry Will attempt to catch the current exception . To Sentry It’s also useful to report errors or messages manually .

When capturing Events , You can also record the crumbs that caused the event (breadcrumbs). Breadcrumbs are different from events : They won’t be Sentry Create events in , But it will be buffered before sending the next event . In our Breadcrumbs documentation Learn more about crumbs in .

Capture the error

stay JavaScript in , You can pass the error object to captureException(), To capture it as an event . You can throw a string as an error , In this case, backtracking cannot be recorded .

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

Capture naked messages

Another common operation is to capture naked messages (bare message). The message should be sent to Sentry The text message of . Usually , The message won’t go out , But they can be useful for some teams .

Sentry.captureMessage("Something went wrong");

Set the event level

level — Similar to log level — It’s usually based on Integration (integration) Default added . You can also override it in an event .

To be in scope External settings level, You can call captureMessage() Every event :

Sentry.captureMessage("this is a debug message", "debug");

To be in scope (scope) Set levels in , You can call setLevel()

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

Or every event :

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

Chinese documents are synchronized to :

  • https://getsentry.hacker-linner.com
 I'm for less .
WeChat :uuhells123.
official account :*** Afternoon tea .
Thank you for your support ????????????!