After stepping on the pit, I found that it was actually very simple. I tried to describe it in simple words

Sentry deployment

Website registration

If the specific application is generally not recommended in the company, you can refer to my article for the general process

(a)

Corporate Deployment (recommended)

If you don’t want to learn deployment, you can skip it. Deployment is not our job. Operation and maintenance will be more professional, but I also want to comb the deployment process and step on the pit.

Docker mirror

This is more than once built operation joke, rely on very much, and accidentally will report errors, but see github update is quite frequent. If operation and maintenance use docker deployment by themselves, they will write dockerFile and docker-compose by themselves, which will be very heavy workload

1. Pull the mirror

This process is very long, if you encounter an error, you can gogithubtheissueLook up and down. I came across something aboutkfakaFound the same mistake in their issue. The final inputlocalhost:9000You can visit

2. Mail configuration

Enter localhost:9000 and configure email information in config.yml. The following uses the enterprise wechat email as an example

mail.backend: 'django_smtp_ssl.SSLEmailBackend' # Use dummy if you want to disable email entirely mail.host: 'smtp.exmail.qq.com' mail.port: 465 mail.username: '' mail.password: '1996810jyjJYJ' mail.use-tls: True # The email address to send on behalf of your client.Copy the code

A plug-in django_smtp_ssl is installed. After installation, you need to install a plug-in django_smtp_ssl in requirements.txt.

pip install django-smtp-ssl
Copy the code

Then you need to add it in requirements.txt

# Add plugins here # sentry-dingtalk-new Django-smtp-ssl ~=1.0Copy the code

How is Sentry used in an application

Sentry.captureException (sentry. captureException, sentry. captureException, sentry. captureException

axios.interceptors.response.use( (response) => { return Promise.resolve(response); }, (error) => {sentry. captureException(new error (error)); return Promise.reject(error); });Copy the code

Sentry workbench

I have mentioned it in this article. Here are some of the problems I encountered and the solutions I used in the actual application. As mentioned earlier, the rules for setting up alarms are as follows

So we have a problem here. Some error reports are only sent to certain people, but not onesetTagAPI, use it

1. Add the following code to your code

Sentry.configureScope(function (scope) {// Set the tag scope.setTag("specialError", "specialError"); scope.setUser({ "username": "nanlan", }); }); Sentry.captureException(new Error(error));Copy the code

2. Select the tag matching condition

3. Select the action to send

conclusion

This article mainly talks about some of their own respectively in the deployment (mainly pull image and mail send), some pits stepped in the business scenario (can not report server errors), different scenarios set up different alarm rules, if there is any pit in the future, will be recorded at any time

Error Monitoring System setup by Sentry (2)

Sentry Build error Monitoring System (1)