我有一个 Angular 5 应用程序,使用使用 raven.js 的 sentry.io 进行错误日志记录。
我让这一切正常工作,但不想在开发中运行时记录错误。如何仅在启用生产模式时启用错误日志记录?
我的 app.module.ts 中有以下内容
import * as Raven from 'raven-js';
Raven
.config('https://xxx@sentry.io/xxx')
.install();
export class RavenErrorHandler implements ErrorHandler {
handleError(err: any): void {
Raven.captureException(err);
}
}
Run Code Online (Sandbox Code Playgroud) 我有一个指定多阶段构建的 Dockerfile,如下所示:
FROM python:2.7.15-slim-jessie
RUN pip install devpi-client --index https://pypi.org/simple --proxy=myproxy.com
RUN devpi use http://proxyip/root/internal --set-cfg
ENV HTTP_PROXY="http://myproxy.com"
ENV HTTPS_PROXY="http://myproxy.com"
FROM sentry:9.0-onbuild
RUN apt-get -qq update && DEBIAN_FRONTEND=noninteractive apt-get install -y -q libxslt1-dev libxml2-dev libpq-dev libldap2-dev libsasl2-dev libssl-dev
COPY sentry.conf.py /etc/sentry/sentry.conf.py
COPY requirements.txt /tmp/
RUN pip install -r /tmp/requirements.txt
# cleanup
RUN apt-get remove -y -q libxslt1-dev libxml2-dev libpq-dev libldap2-dev libsasl2-dev libssl-dev
RUN rm -rf /var/lib/apt/lists/*
RUN rm /tmp/requirements.txt
Run Code Online (Sandbox Code Playgroud)
`
继承的阶段sentry:9.0-onbuild具有在构建期间失败的 pip 命令,因为 pypi 服务器的代理的 ENV 设置包含在前一个构建阶段中。有没有办法保留此 ENV …
我查看了有关向 Spring 项目添加 Sentry 日志记录和监视的文档和一些 Github 示例。
有人有可以帮助我的示例或链接吗?
我使用 django-restful 框架,并且我想在 ModelViewSet 中发生错误时将用户信息添加到 Sentry 的报告中。
我发现这个哨兵文档:https ://docs.sentry.io/enriching-error-data/context/ ? _ga = 1.219964441.1220115692.1472094716%3F_ga & platform = python#capturing-the-user
它给出了一些代码如下:
from sentry_sdk import configure_scope
with configure_scope() as scope:
scope.user = {"email": "john.doe@example.com"}
Run Code Online (Sandbox Code Playgroud)
但我不知道如何正确使用它。我认为存在比以下更好的方法:
@list_route()
def fun_xxx(self, request, *args, **kwargs):
user = request.user
with configure_scope() as scope:
scope.user = {"id": user.id,......}
...some code may cause an error...
return Response({...})
Run Code Online (Sandbox Code Playgroud)
谁能给我一些建议?:)
使用已弃用的客户端 Raven,您可以忽略麻烦的错误:
Raven.config('your-dsn', {
ignoreErrors: [
'Can\'t execute code from freed script',
/SecurityError\: DOM Exception 18$/
]
}).install();
Run Code Online (Sandbox Code Playgroud)
我在新客户端中找到的唯一方法是使用before-send钩子:https :
//docs.sentry.io/error-reporting/configuration/filtering/?platform=browser#before-send
import * as Sentry from '@sentry/browser';
init({
beforeSend(event, hint) {
const { message } = hint.originalException;
if (message && message.match(/database unavailable/i)) {
return null;
}
return event;
}
});
Run Code Online (Sandbox Code Playgroud)
我搜索了所有文档,但没有找到忽略错误的全局方法。
我有一个 ASP.NET MVC (4.6.1) 网站,我们正在尝试使用 Sentry 服务对其进行监控。
根据安装文档,它只是说尽早初始化 Sentry,但他们示例的结构让我有理由怀疑是否没有更多内容。在我的 Gloabl.asax.cs 文件中,我调用包含 Sentry 初始化的自定义模型类。这是该课程的副本:
public class SentryModel
{
public static void Configure()
{
var environment = ConfigurationManager.AppSettings["Environment"];
//escape the method if we are in a development environment
if (environment.Equals("development", StringComparison.CurrentCultureIgnoreCase))
return;
Assembly web = Assembly.GetExecutingAssembly();
AssemblyName webName = web.GetName();
string myVersion = webName.Version.ToString();
string dsn_data = ConfigurationManager.ConnectionStrings["Sentry"].ConnectionString;
using (SentrySdk.Init(o =>
{
o.Dsn = new Dsn(dsn_data);
o.MaxBreadcrumbs = 50;
o.Debug = true;
o.Environment = environment;
o.Release = myVersion;
o.AttachStacktrace = true;
})) …Run Code Online (Sandbox Code Playgroud) 我正在测试 React 的错误边界,并在 Codecov 中注意到我的 Sentry 函数的特定部分尚未经过测试。
我曾尝试使用 jest.mock("@sentry/browser") 并嘲笑 Sentry,但是,似乎无法测试这些行。Sentry 导入正确模拟但不是scope.
这是我尝试嘲笑的一个例子。
import * as Sentry from "@sentry/browser"
const mock_scope = jest.fn(() => {
return { setExtras: null }
})
Sentry.withScope = jest.fn().mockImplementation(mock_scope)
Run Code Online (Sandbox Code Playgroud) 我正在将现有应用程序从 Sentry-raven 迁移到 Sentry-ruby。然而,迁移指南中似乎缺少一部分。
我该如何处理#sanitize_fields?
旧的配置如下所示:
Raven.configure do |config|
config.sanitize_fields = filter_parameters
end
Run Code Online (Sandbox Code Playgroud)
但是,#sanitize_fields 已被删除,而且我没有看到该功能被替换的任何地方。
我们用它来确保密码和确认信息不会发送到 Sentry(糟糕的一天),所以我需要在使用sentry-ruby 时做一些事情。
任何帮助将不胜感激。
我将哨兵(版本 2.10)与 Laravel v6.20.27 和 PHP v7.4.19 一起使用。我遵循文档中提到的相同步骤(https://docs.sentry.io/platforms/php/guides/laravel/other-versions/laravel5-6/)。但是我无法继续,因为我收到以下错误
There was an error sending the event.
SDK: Failed to send the event to Sentry. Reason: "SSL peer certificate or SSH remote key was not OK for "https://oXXXXXXX.ingest.sentry.io/api/XXXXXXXX/store/".".
Please check the error message from the SDK above for further hints about what went wrong.
Run Code Online (Sandbox Code Playgroud)
请帮我解决这个问题。
在 React 应用程序中集成 Sentry.io 后的行为。
sentry ×10
reactjs ×2
.net ×1
angular ×1
asp.net-mvc ×1
django ×1
docker ×1
exception ×1
global-asax ×1
javascript ×1
jestjs ×1
laravel ×1
logging ×1
monitoring ×1
php ×1
ruby ×1
rubygems ×1
spring ×1
vue.js ×1