哨兵不记录请求有效载荷在.NET中

发布于 2025-01-20 16:40:53 字数 456 浏览 1 评论 0原文

最近我开始使用 Sentry 来记录错误日志。我使用此代码片段进行连接:

webBuilder.UseSentry(o =>
{
    o.Dsn = settings.GetConnectionString("Sentry"); // env variable
    o.AttachStacktrace = true;
    o.TracesSampleRate = 1;
    o.IncludeActivityData = true;
});

这工作正常并且记录错误,但我注意到请求负载未记录。我在网上查找了一些教程并发现了有关 IncludeRequestPayload = true 但在我的情况下它不存在。我在 .NET 3.1 中使用 Sentry.AspNetCore 版本 3.16.0。您知道是否可以使用此版本记录有效负载,如果可以,我该怎么做?

Recently I started using Sentry for error logs. I use this snippet to connect:

webBuilder.UseSentry(o =>
{
    o.Dsn = settings.GetConnectionString("Sentry"); // env variable
    o.AttachStacktrace = true;
    o.TracesSampleRate = 1;
    o.IncludeActivityData = true;
});

This works fine and it logs errors but I noticed that request payload is not logged. I looked for some tutorials online and found about IncludeRequestPayload = true but in my case it doesn't exist. I use Sentry.AspNetCore version 3.16.0 within a .NET 3.1. Do you know if it's possible to log the payload with this version and if so, how can I do it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

画▽骨i 2025-01-27 16:40:53

我设法自己解决了。对于那些偶然发现类似内容的任何人,您只需要将maxRequestBodySize添加到sentry.extensibility.requestsize.always.always.always,尽管 docs

webBuilder.UseSentry(o =>
{
    o.Dsn = settings.GetConnectionString("Sentry");
    o.AttachStacktrace = true;
    o.TracesSampleRate = 1;
    o.MaxRequestBodySize = Sentry.Extensibility.RequestSize.Always; //this line
    o.IncludeActivityData = true;
});

I managed to solve it myself. For anyone that stumbles upon something like this, you just need to add a MaxRequestBodySize to Sentry.Extensibility.RequestSize.Always, although not well described in docs.

webBuilder.UseSentry(o =>
{
    o.Dsn = settings.GetConnectionString("Sentry");
    o.AttachStacktrace = true;
    o.TracesSampleRate = 1;
    o.MaxRequestBodySize = Sentry.Extensibility.RequestSize.Always; //this line
    o.IncludeActivityData = true;
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文