Sentry SDK带有ASP.NET 4.6.1不起作用

发布于 2025-01-23 12:15:15 字数 941 浏览 1 评论 0原文

我有一个ASP.NET应用,使用.NET 4.6.1版本。当我安装了哨兵Nuget并使用Sentry SDK时,什么都没有工作,没有将事件发送给Sentry。以下是我尝试此哨兵的global.asax配置。

<%@ Application Language="C#" %>
<%@ Import Namespace="Sentry" %>
<%@ Import Namespace="Sentry.AspNet" %>
<%@ Import Namespace="Sentry.Extensibility" %>
<script runat="server">
    private IDisposable _sentry;

    protected void Application_Start()
    {
       _sentry = SentrySdk.Init(o =>
        {
            o.Dsn = "dsn url";
            
        });

        // Initialize Sentry to capture AppDomain unhandled exceptions and more.
        
    }
    // Global error catcher
    protected void Application_Error()
    {
        var exception = Server.GetLastError();

        SentrySdk.CaptureException(exception);
    }


    protected void Application_End()
    {
        if (_sentry != null)
            _sentry.Dispose();
    }
</script>

谁能帮我吗?谢谢

I have an Asp.Net app, using .net 4.6.1 version. When I installed Sentry nuget and used Sentry SDK, nothing working, no events are being sent to Sentry. Below is global.asax configs where I tried this Sentry.

<%@ Application Language="C#" %>
<%@ Import Namespace="Sentry" %>
<%@ Import Namespace="Sentry.AspNet" %>
<%@ Import Namespace="Sentry.Extensibility" %>
<script runat="server">
    private IDisposable _sentry;

    protected void Application_Start()
    {
       _sentry = SentrySdk.Init(o =>
        {
            o.Dsn = "dsn url";
            
        });

        // Initialize Sentry to capture AppDomain unhandled exceptions and more.
        
    }
    // Global error catcher
    protected void Application_Error()
    {
        var exception = Server.GetLastError();

        SentrySdk.CaptureException(exception);
    }


    protected void Application_End()
    {
        if (_sentry != null)
            _sentry.Dispose();
    }
</script>

Can anyone help me? Thanks

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

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

发布评论

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

评论(1

十秒萌定你 2025-01-30 12:15:15

请参阅文档中的样本在这里。具体来说,您需要按以下方式更改代码:

  • 添加o.addaspnet(); sentrysdk.init 呼叫
  • 使用server.capturelasterror()在您的application_error方法中,

如果要启用Sentry的性能监视功能,您还需要:

  • 在您的选项中设置tracessAmplerate

  • 添加以下代码:


    {
    context.startsentrytransaction();
    }

    受保护的void application_endrequest()
    {
    context.finishsentrytransaction();
    }

Refer to the sample in the documentation here. Specifically, you need to change your code as follows:

  • Add o.AddAspNet(); to the body of your SentrySdk.Init call
  • Use Server.CaptureLastError() in your Application_Error method

If you want to enable Sentry's performance monitoring features, you also need to:

  • Set a TracesSampleRate in your options

  • Add the following code:

    protected void Application_BeginRequest()
    {
        Context.StartSentryTransaction();
    }
    
    protected void Application_EndRequest()
    {
        Context.FinishSentryTransaction();
    }
    
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文