public void FirstOrDefault_FromDatabase_CapturesQuery()
        {
            _ = SentryDatabaseLogging.UseBreadcrumbs(_fixture.QueryLogger);

            _ = _fixture.DbContext.TestTable.FirstOrDefault();

            _fixture.QueryLogger.Received().Log(Arg.Any <string>(), BreadcrumbLevel.Debug);
        }
Exemplo n.º 2
0
        protected void Application_Start()
        {
            SentryDatabaseLogging.UseBreadcrumbs();
            _sentrySdk = SentrySdk.Init(o =>
            {
                o.Dsn         = new Dsn(ConfigurationManager.AppSettings["SentryDsn"]);
                o.Environment = ConfigurationManager.AppSettings["SentryEnvironment"] ?? "Unknown";
                o.AddEntityFramework();
            });

            GlobalConfiguration.Configure(WebApiConfig.Register);
        }
Exemplo n.º 3
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            SentryDatabaseLogging.UseBreadcrumbs();
            _sentry = SentrySdk.Init(o =>
            {
                o.Dsn = new Dsn(Properties.Settings.Default.SentryDSN);
                o.AddEntityFramework();
            });
        }
Exemplo n.º 4
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            RouteConfig.RegisterRoutes(RouteTable.Routes);

            SentryDatabaseLogging.UseBreadcrumbs();

            _sentry = SentrySdk.Init(o =>
            {
                // We store the DSN inside Web.config; make sure to use your own DSN!
                o.Dsn = new Dsn(ConfigurationManager.AppSettings["SentryDsn"]);

                // Get Entity Framework integration
                o.AddEntityFramework();
            });
        }
Exemplo n.º 5
0
 protected void Application_Start()
 {
     AreaRegistration.RegisterAllAreas();
     GlobalConfiguration.Configure(WebApiConfig.Register);
     FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
     RouteConfig.RegisterRoutes(RouteTable.Routes);
     BundleConfig.RegisterBundles(BundleTable.Bundles);
     SentryDatabaseLogging.UseBreadcrumbs();
     _sentrySdk = SentrySdk.Init(o =>
     {
         // We store the DSN inside Web.config
         o.Dsn = new Dsn(ConfigurationManager.AppSettings["SentryDsn"]);
         // Add the EntityFramework integration
         o.AddEntityFramework();
     });
 }
        public void ReaderExecuting_SentryCommandInterceptor_CapturesQuery()
        {
            var expected = new
            {
                Query = "Expected query string"
            };

            var interceptor = SentryDatabaseLogging.UseBreadcrumbs(_fixture.QueryLogger);

            var command = new EffortCommand()
            {
                CommandText = expected.Query
            };

            interceptor.ReaderExecuting(command, new DbCommandInterceptionContext <DbDataReader>());
            _fixture.QueryLogger.Received(1).Log(expected.Query, BreadcrumbLevel.Debug);
        }
Exemplo n.º 7
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);

            // We add the query logging here so multiple DbContexts in the same project are supported
            SentryDatabaseLogging.UseBreadcrumbs();

            // Set up the sentry SDK
            _sentry = SentrySdk.Init(o =>
            {
                // We store the DSN inside Web.config; make sure to use your own DSN!
                o.Dsn = new Dsn(ConfigurationManager.AppSettings["SentryDsn"]);

                // Get Entity Framework integration
                o.AddEntityFramework();
            });
        }
        public void NonQueryExecuting_WithException_CapturesQuery()
        {
            var expected = new
            {
                Query = "Expected query string"
            };

            var interceptor = SentryDatabaseLogging.UseBreadcrumbs(_fixture.QueryLogger, initOnce: false);

            var command = new EffortCommand
            {
                CommandText = expected.Query
            };

            interceptor.NonQueryExecuting(command, new DbCommandInterceptionContext <int> {
                Exception = new Exception()
            });
            _fixture.QueryLogger.Received(1).Log(expected.Query, BreadcrumbLevel.Error);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Adds the entity framework integration.
        /// </summary>
        /// <param name="sentryOptions">The sentry options.</param>
        /// <returns></returns>
        public static SentryOptions AddEntityFramework(this SentryOptions sentryOptions)
        {
            try
            {
#pragma warning disable 618 // TODO: We can make the method internal on a new major release.
                SentryDatabaseLogging.UseBreadcrumbs(diagnosticLogger: sentryOptions.DiagnosticLogger);
#pragma warning restore 618
            }
            catch (Exception e)
            {
                sentryOptions.DiagnosticLogger?
                .LogError("Failed to configure EF breadcrumbs. Make sure to init Sentry before EF.", e);
            }

            sentryOptions.AddExceptionProcessor(new DbEntityValidationExceptionProcessor());
            // DbConcurrencyExceptionProcessor is untested due to problems with testing it, so it might not be production ready
            //sentryOptions.AddExceptionProcessor(new DbConcurrencyExceptionProcessor());
            return(sentryOptions);
        }
    /// <summary>
    /// Adds the entity framework integration.
    /// </summary>
    /// <param name="sentryOptions">The sentry options.</param>
    public static SentryOptions AddEntityFramework(this SentryOptions sentryOptions)
    {
        try
        {
            _ = SentryDatabaseLogging.UseBreadcrumbs(diagnosticLogger: sentryOptions.DiagnosticLogger);
        }
        catch (Exception e)
        {
            sentryOptions.DiagnosticLogger?
            .LogError("Failed to configure EF breadcrumbs. Make sure to init Sentry before EF.", e);
        }

        DbIntegration = new DbInterceptionIntegration();
        sentryOptions.AddIntegration(DbIntegration);

        sentryOptions.AddExceptionProcessor(new DbEntityValidationExceptionProcessor());
        // DbConcurrencyExceptionProcessor is untested due to problems with testing it, so it might not be production ready
        //sentryOptions.AddExceptionProcessor(new DbConcurrencyExceptionProcessor());
        return(sentryOptions);
    }
        public void UseBreadCrumbs_SentryDatabaseLogging_AddsInterceptor()
        {
            var interceptor = SentryDatabaseLogging.UseBreadcrumbs(_fixture.QueryLogger);

            Assert.NotNull(interceptor);
        }