예제 #1
0
        public void when_serializing_exception_notice()
        {
            var       client    = new RollbarClient();
            Exception exception = null;

            try
            {
                CreateException();
            }
            catch (Exception ex)
            {
                exception = ex;
            }

            var notice = client.NoticeBuilder.CreateExceptionNotice(exception);

            notice.Server.Host    = "miker";
            notice.Request.Url    = "http://localhost/hej";
            notice.Request.Method = "GET";
            notice.Request.Headers.Add("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.65 Safari/537.31");
            notice.Request.UserIp  = "67.90.39.34";
            notice.Person.Id       = "123";
            notice.Person.Username = Environment.UserName;

            var serialized = client.Serialize(notice);

            it["shouldn't be blank"] = () => serialized.should_not_be_empty();

            Console.WriteLine(serialized);
        }
        public void TestUsingUnreasonablyShortTimeout()
        {
            // [DO]: let's send a payload using unreasonably short PayloadPostTimeout
            // [EXPECT]: even under all the good networking conditions sending a payload should not succeed
            RollbarInfrastructureOptions infrastructureOptions =
                new RollbarInfrastructureOptions();

            infrastructureOptions.PayloadPostTimeout =
                TimeSpan.FromMilliseconds(5); // short enough
            RollbarInfrastructure.Instance.Config.RollbarInfrastructureOptions
            .Reconfigure(infrastructureOptions);
            using (var logger = (RollbarLogger)RollbarFactory.CreateNew(RollbarInfrastructure.Instance.Config.RollbarLoggerConfig))
            {
                RollbarUnitTestEnvironmentUtil.TraceCurrentRollbarInfrastructureConfig();
                RollbarUnitTestEnvironmentUtil.Trace(logger.Config, "Logger_Config");
                var client = new RollbarClient(logger);
                var bundle = new PayloadBundle(logger, RollbarClientFixture.CrateTestPackage(), ErrorLevel.Info);
                client.EnsureHttpContentToSend(bundle);
                var response = client.PostAsJson(bundle);
                RollbarUnitTestEnvironmentUtil.Trace(response, "Rollbar API HTTP response");
                Assert.IsNull(response);
                Assert.AreEqual(1, bundle.Exceptions.Count);
                //Assert.AreEqual("While PostAsJson(PayloadBundle payloadBundle)...", bundle.Exceptions.First().Message);
                //Assert.IsTrue(bundle.Exceptions.First().InnerException.Message.StartsWith("One or more errors occurred"));
                //Assert.AreEqual("A task was canceled.",  bundle.Exceptions.First().InnerException.InnerException.Message);
            }
        }
        public LinkOrphanGamesJobResult LinkOrphanGames()
        {
            var result    = new LinkOrphanGamesJobResult();
            var stopwatch = new Stopwatch();

            stopwatch.Start();
            try
            {
                var orphanGames = GetOrphanGames();
                result.OrphanGames = orphanGames.Count;
                foreach (var game in orphanGames)
                {
                    CreateOrUpdateOrphanGames(game, result);
                }
            }
            catch (Exception ex)
            {
                result.Success = false;
                RollbarClient.SendException(ex);
                ex.ToExceptionless();
            }

            stopwatch.Stop();
            result.TimeEllapsed = stopwatch.Elapsed;
            return(result);
        }
        public void TestUsingLongEnoughTimeout()
        {
            // [DO]: let's send a payload using reasonably long PayloadPostTimeout
            // [EXPECT]: even under all the good networking conditions sending a payload should succeed
            RollbarInfrastructureOptions infrastructureOptions =
                new RollbarInfrastructureOptions();

            infrastructureOptions.PayloadPostTimeout =
                TimeSpan.FromMilliseconds(2000); // long enough
            RollbarInfrastructure.Instance.Config.RollbarInfrastructureOptions
            .Reconfigure(infrastructureOptions);
            using (var logger = (RollbarLogger)RollbarFactory.CreateNew(RollbarInfrastructure.Instance.Config.RollbarLoggerConfig))
            {
                RollbarUnitTestEnvironmentUtil.TraceCurrentRollbarInfrastructureConfig();
                RollbarUnitTestEnvironmentUtil.Trace(logger.Config, "Logger_Config");
                var client = new RollbarClient(logger);
                var bundle = new PayloadBundle(logger, RollbarClientFixture.CrateTestPackage(), ErrorLevel.Info);
                client.EnsureHttpContentToSend(bundle);
                var response = client.PostAsJson(bundle);
                RollbarUnitTestEnvironmentUtil.Trace(response, "Rollbar API HTTP response");
                Assert.IsNotNull(response, "let's send a payload using reasonably long PayloadPostTimeout");
                Assert.AreEqual(0, response.Error);
                Assert.AreEqual(0, bundle.Exceptions.Count);
            }
        }
        public void when_serializing_exception_notice()
        {
            var client = new RollbarClient();
            Exception exception = null;

            try
            {
                CreateException();
            }
            catch (Exception ex)
            {
                exception = ex;
            }

            var notice = client.NoticeBuilder.CreateExceptionNotice(exception);
            notice.Server.Host = "miker";
            notice.Request.Url = "http://localhost/hej";
            notice.Request.Method = "GET";
            notice.Request.Headers.Add("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.65 Safari/537.31");
            notice.Request.UserIp = "67.90.39.34";
            notice.Person.Id = "123";
            notice.Person.Username = Environment.UserName;

            var serialized = client.Serialize(notice);

            it["shouldn't be blank"] = () => serialized.should_not_be_empty();

            Console.WriteLine(serialized);
        }
예제 #6
0
        /// <summary>
        /// Sends the given event to Rollbar
        /// </summary>
        /// <param name="loggingEvent">The event to report</param>
        protected override void Append(LoggingEvent loggingEvent)
        {
            var client = new RollbarClient(_configuration);

            Task task = null;

            if (loggingEvent.Level >= Level.Critical)
            {
                task = Send(loggingEvent, client.SendCriticalMessage, client.SendCriticalException);
            }
            else if (loggingEvent.Level >= Level.Error)
            {
                task = Send(loggingEvent, client.SendErrorMessage, client.SendErrorException);
            }
            else if (loggingEvent.Level >= Level.Warn)
            {
                task = Send(loggingEvent, client.SendWarningMessage, client.SendWarningException);
            }
            else if (loggingEvent.Level >= Level.Info)
            {
                task = client.SendInfoMessage(loggingEvent.RenderedMessage);
            }
            else if (loggingEvent.Level >= Level.Debug)
            {
                task = client.SendDebugMessage(loggingEvent.RenderedMessage);
            }

            if (task != null && !Asynchronous)
            {
                task.Wait(TimeSpan.FromSeconds(5));
            }
        }
예제 #7
0
        public void when_calling_send_critical_message_task_returns_and_can_be_used()
        {
            var client  = new RollbarClient();
            var message = "";

            var task = client.SendCriticalMessage(message);

            Assert.IsNotNull(task);
            Assert.DoesNotThrow(() => task.Wait(0));
        }
예제 #8
0
        public void when_calling_send_warning_exception_task_returns_and_can_be_used()
        {
            var       client    = new RollbarClient();
            Exception exception = new NotImplementedException();

            var task = client.SendWarningException(exception);

            Assert.IsNotNull(task);
            Assert.DoesNotThrow(() => task.Wait(0));
        }
예제 #9
0
        /// <summary>
        /// Gets the deployments page asynchronously.
        /// </summary>
        /// <param name="environment">The environment.</param>
        /// <param name="pageNumber">The page number.</param>
        /// <returns></returns>
        public async Task <IDeploymentDetails[]> GetDeploymentsPageAsync(string environment, int pageNumber)
        {
            Assumption.AssertNotNullOrWhiteSpace(this._readAccessToken, nameof(this._readAccessToken));

            var           config        = new RollbarConfig(this._readAccessToken);
            RollbarClient rollbarClient = new RollbarClient(config);

            var result = await rollbarClient.GetDeploymentsAsync(this._readAccessToken, pageNumber);

            return(result.DeploysPage.Deploys);
        }
예제 #10
0
        public void TestGetDeploy()
        {
            RollbarClient rollbarClient = new RollbarClient(this._loggerConfig);

            var task = rollbarClient.GetDeploymentAsync(RollbarUnitTestSettings.DeploymentsReadAccessToken, "8387647");

            task.Wait(TimeSpan.FromSeconds(3));
            Assert.IsNotNull(task.Result);
            Assert.AreEqual(task.Result.ErrorCode, 0);
            Assert.IsNotNull(task.Result.Deploy);
            Assert.IsTrue(!string.IsNullOrWhiteSpace(task.Result.Deploy.DeployID));
        }
예제 #11
0
        public void when_calling_send_task_returns_and_can_be_used()
        {
            var client  = new RollbarClient();
            var message = "";

            var notice = new DataModelBuilder().CreateMessageNotice(message, "debug");

            var task = client.Send(notice, null);

            Assert.IsNotNull(task);
            Assert.DoesNotThrow(() => task.Wait(0));
        }
예제 #12
0
        /// <summary>
        /// Gets the deployment asynchronously.
        /// </summary>
        /// <param name="deploymentID">The deployment identifier.</param>
        /// <returns></returns>
        public async Task <IDeploymentDetails> GetDeploymentAsync(string deploymentID)
        {
            Assumption.AssertNotNullOrWhiteSpace(deploymentID, nameof(deploymentID));
            Assumption.AssertNotNullOrWhiteSpace(this._readAccessToken, nameof(this._readAccessToken));

            var           config        = new RollbarConfig(this._readAccessToken);
            RollbarClient rollbarClient = new RollbarClient(config);

            var result = await rollbarClient.GetDeploymentAsync(this._readAccessToken, deploymentID);

            return(result.Deploy);
        }
예제 #13
0
        //--- Methods ---
        public async override Task InitializeAsync(LambdaConfig config)
        {
            var tableName = config.ReadDynamoDBTableName("RegistrationTable");

            _registrations = new RegistrationTable(new AmazonDynamoDBClient(), tableName);
            _rollbarClient = new RollbarClient(
                config.ReadText("RollbarReadAccessToken", defaultValue: null),
                config.ReadText("RollbarWriteAccessToken", defaultValue: null),
                message => LogInfo(message)
                );
            _rollbarProjectPrefix = config.ReadText("RollbarProjectPrefix");
        }
예제 #14
0
        public void TestGetDeploysPage()
        {
            RollbarClient rollbarClient = new RollbarClient(this._loggerConfig);

            var task = rollbarClient.GetDeploymentsAsync(RollbarUnitTestSettings.DeploymentsReadAccessToken, 1);

            task.Wait(TimeSpan.FromSeconds(3));
            Assert.IsNotNull(task.Result);
            Assert.AreEqual(task.Result.ErrorCode, 0);
            Assert.IsNotNull(task.Result.DeploysPage);
            Assert.IsTrue(task.Result.DeploysPage.PageNumber > 0);
        }
예제 #15
0
        public void when_serializing_message_notice_result_should_not_be_empty()
        {
            var client = new RollbarClient();
            var notice = client.NoticeBuilder.CreateMessageNotice("Hello");

            notice.Server.Host    = "miker";
            notice.Request.Url    = "http://localhost/hej";
            notice.Request.Method = "GET";

            var serialized = client.Serialize(notice);

            Assert.IsNotNullOrEmpty(serialized);
        }
예제 #16
0
        //--- Methods ---
        public override async Task InitializeAsync(LambdaConfig config)
        {
            _logic      = new Logic(this);
            _snsClient  = new AmazonSimpleNotificationServiceClient();
            _errorTopic = config.ReadText("ErrorReportTopic");
            _usageTopic = config.ReadText("UsageReportTopic");
            var tableName    = config.ReadDynamoDBTableName("RegistrationTable");
            var dynamoClient = new AmazonDynamoDBClient();

            _registrations       = new RegistrationTable(dynamoClient, tableName);
            _cachedRegistrations = new Dictionary <string, OwnerMetaData>();
            _rollbarClient       = new RollbarClient(null, null, message => LogInfo(message));
        }
 public void ConstructionTest()
 {
     using (var logger = new RollbarLogger())
     {
         RollbarClient client = new RollbarClient(logger);
         PayloadQueue  pq     = new PayloadQueue(logger, client);
         Assert.IsNotNull(pq.Logger);
         Assert.AreSame(logger, pq.Logger);
         Assert.AreSame(client, pq.Client);
         Assert.AreSame(client.Config, pq.Client.Config);
         Assert.AreSame(client.Config, logger.Config);
     }
 }
예제 #18
0
        public void BasicTest()
        {
            MessagePackage package = new MessagePackage($"{nameof(RollbarClientFixture)}.BasicTest");

            // [DO]: let's send a payload with default config settings (including default value for the PayloadPostTimeout)
            // [EXPECT]: under all the good networking conditions sending a payload should succeed
            RollbarConfig config = new RollbarConfig();

            config.Reconfigure(this._loggerConfig);
            using (var logger = (RollbarLogger)RollbarFactory.CreateNew(config))
            {
                var client = new RollbarClient(logger);
                var bundle = new PayloadBundle(logger, package, ErrorLevel.Info);
                client.EnsureHttpContentToSend(bundle);
                var response = client.PostAsJson(bundle);
                Assert.IsNotNull(response);
                Assert.AreEqual(0, response.Error);
                Assert.AreEqual(0, bundle.Exceptions.Count);
            }

            // [DO]: let's send a payload using unreasonably short PayloadPostTimeout
            // [EXPECT]: even under all the good networking conditions sending a payload should not succeed
            config.PayloadPostTimeout = TimeSpan.FromMilliseconds(10); // too short
            using (var logger = (RollbarLogger)RollbarFactory.CreateNew(config))
            {
                var client = new RollbarClient(logger);
                var bundle = new PayloadBundle(logger, package, ErrorLevel.Info);
                client.EnsureHttpContentToSend(bundle);
                var response = client.PostAsJson(bundle);
                Assert.IsNull(response);
                Assert.AreEqual(1, bundle.Exceptions.Count);
                //Assert.AreEqual("While PostAsJson(PayloadBundle payloadBundle)...", bundle.Exceptions.First().Message);
                //Assert.IsTrue(bundle.Exceptions.First().InnerException.Message.StartsWith("One or more errors occurred"));
                //Assert.AreEqual("A task was canceled.",  bundle.Exceptions.First().InnerException.InnerException.Message);
            }

            // [DO]: let's send a payload using reasonably long PayloadPostTimeout
            // [EXPECT]: even under all the good networking conditions sending a payload should succeed
            config.PayloadPostTimeout = TimeSpan.FromMilliseconds(1000); // long enough
            using (var logger = (RollbarLogger)RollbarFactory.CreateNew(config))
            {
                var client = new RollbarClient(logger);
                var bundle = new PayloadBundle(logger, package, ErrorLevel.Info);
                client.EnsureHttpContentToSend(bundle);
                var response = client.PostAsJson(bundle);
                Assert.IsNotNull(response);
                Assert.AreEqual(0, response.Error);
                Assert.AreEqual(0, bundle.Exceptions.Count);
            }
        }
예제 #19
0
        /// <summary>
        /// Registers the deployment asynchronously.
        /// </summary>
        /// <param name="deployment">The deployment.</param>
        /// <returns></returns>
        public async Task RegisterAsync(IDeployment deployment)
        {
            Assumption.AssertNotNullOrWhiteSpace(this._writeAccessToken, nameof(this._writeAccessToken));

            var config =
                new RollbarConfig(this._writeAccessToken)
            {
                Environment = deployment.Environment,
            };

            RollbarClient rollbarClient = new RollbarClient(config);

            await rollbarClient.PostAsync(deployment);
        }
        public void when_serializing_message_notice()
        {
            var client = new RollbarClient();
            var notice = client.NoticeBuilder.CreateMessageNotice("Hello");

            notice.Server.Host = "miker";
            notice.Request.Url = "http://localhost/hej";
            notice.Request.Method = "GET";

            var serialized = client.Serialize(notice);

            it["shouldn't be blank"] = () => serialized.should_not_be_empty();

            Console.WriteLine(serialized);
        }
예제 #21
0
        public void when_serializing_message_notice()
        {
            var client = new RollbarClient();
            var notice = client.NoticeBuilder.CreateMessageNotice("Hello");

            notice.Server.Host    = "miker";
            notice.Request.Url    = "http://localhost/hej";
            notice.Request.Method = "GET";

            var serialized = client.Serialize(notice);

            it["shouldn't be blank"] = () => serialized.should_not_be_empty();

            Console.WriteLine(serialized);
        }
예제 #22
0
        public void TestPostDeployment()
        {
            RollbarClient rollbarClient = new RollbarClient(this._loggerConfig);

            var deployment = new Deployment(this._loggerConfig.AccessToken, this._loggerConfig.Environment, "99909a3a5a3dd4363f414161f340b582bb2e4161")
            {
                Comment         = "Some new unit test deployment",
                LocalUsername   = "******",
                RollbarUsername = "******",
            };

            var task = rollbarClient.PostAsync(deployment);

            task.Wait(TimeSpan.FromSeconds(3));
            Assert.IsNull(task.Exception);
        }
 public void TestUsingDefaultConfig()
 {
     // [DO]: let's send a payload with default config settings (including default value for the PayloadPostTimeout)
     // [EXPECT]: under all the good networking conditions sending a payload should succeed
     using (var logger = (RollbarLogger)RollbarFactory.CreateNew(RollbarInfrastructure.Instance.Config.RollbarLoggerConfig))
     {
         RollbarUnitTestEnvironmentUtil.TraceCurrentRollbarInfrastructureConfig();
         RollbarUnitTestEnvironmentUtil.Trace(logger.Config, "Logger_Config");
         var client = new RollbarClient(logger);
         var bundle = new PayloadBundle(logger, RollbarClientFixture.CrateTestPackage(), ErrorLevel.Info);
         client.EnsureHttpContentToSend(bundle);
         var response = client.PostAsJson(bundle);
         RollbarUnitTestEnvironmentUtil.Trace(response, "Rollbar API HTTP response");
         Assert.IsNotNull(response);
         Assert.AreEqual(0, response.Error);
         Assert.AreEqual(0, bundle.Exceptions.Count);
     }
 }
예제 #24
0
        private async void ReportExceptionToRollbar(Exception exception)
        {
#if DEBUG
            return;
#endif

            try
            {
                var config = new Configuration(_rollbarAccessToken)
                {
                    Environment = "Production",
                    Platform    = $"Platform: AutoPrintr.{_appType}. Version: {System.Reflection.Assembly.GetExecutingAssembly().GetName().Version}"
                };
                var client = new RollbarClient(config);
                await client.SendException(exception, exception?.GetType()?.Name, "error", TransformRollbarDataModel);
            }
            catch { }
        }
예제 #25
0
        protected virtual async Task InitializeAsync(ILambdaConfigSource envSource, ILambdaContext context)
        {
            // read configuration from environment variables
            DeploymentTier      = envSource.Read("TIER");
            ModuleName          = envSource.Read("MODULE");
            _deadLetterQueueUrl = envSource.Read("DEADLETTERQUEUE");
            _loggingTopicArn    = envSource.Read("LOGGINGTOPIC");
            var framework = envSource.Read("LAMBDARUNTIME");

            LogInfo($"TIER = {DeploymentTier}");
            LogInfo($"MODULE = {ModuleName}");
            LogInfo($"DEADLETTERQUEUE = {_deadLetterQueueUrl ?? "NONE"}");
            LogInfo($"LOGGINGTOPIC = {_loggingTopicArn ?? "NONE"}");

            // read optional git-sha file
            var gitsha = File.Exists("gitsha.txt") ? File.ReadAllText("gitsha.txt") : null;

            LogInfo($"GITSHA = {gitsha ?? "NONE"}");

            // convert environment variables to lambda parameters
            _appConfig = new LambdaConfig(new LambdaDictionarySource(await ReadParametersFromEnvironmentVariables()));

            // initialize rollbar
            var          rollbarAccessToken = _appConfig.ReadText("RollbarToken", defaultValue: null);
            const string proxy    = "";
            const string platform = "lambda";

            _rollbarClient = RollbarClient.Create(new RollbarConfiguration(

                                                      // NOTE (2018-08-06, bjorg): the rollbar access token determines the rollbar project
                                                      //  the error report is associated with; when rollbar intergration is disabled,
                                                      //  use the module name instead so the logging recipient can determine the module
                                                      //  the log entry belongs to.
                                                      rollbarAccessToken ?? ModuleName,
                                                      proxy,
                                                      DeploymentTier,
                                                      platform,
                                                      framework,
                                                      gitsha
                                                      ));
            _rollbarEnabled = (rollbarAccessToken != null);
            LogInfo($"ROLLBAR = {(_rollbarEnabled ? "ENABLED" : "DISABLED")}");
        }
예제 #26
0
        private void Log(LambdaLogLevel level, Exception exception, string format, params object[] args)
        {
            string message = RollbarClient.FormatMessage(format, args);

            Log(level, $"{message}", exception?.ToString());
            if (level >= LambdaLogLevel.WARNING)
            {
                if (_rollbarEnabled)
                {
                    try {
                        Log(LambdaLogLevel.INFO, "rollbar sending data", extra: null);
                        var result = _rollbarClient.SendAsync(level.ToString(), exception, format, args).Result;
                        if (!result.IsSuccess)
                        {
                            Log(LambdaLogLevel.ERROR, $"Rollbar payload request failed. {result.Message}. UUID: {result.UUID}", extra: null);
                        }
                    } catch (Exception e) {
                        Log(LambdaLogLevel.ERROR, "rollbar SendAsync exception", e.ToString());
                    }
                }
                else if (_loggingTopicArn != null)
                {
                    string payload;
                    try {
                        // send exception to error-topic
                        payload = _rollbarClient.CreatePayload(MAX_SNS_SIZE, level.ToString(), exception, format, args);
                    } catch (Exception e) {
                        Log(LambdaLogLevel.ERROR, "rollbar CreatePayload exception", e.ToString());
                        return;
                    }
                    try {
                        // send exception to error-topic
                        _snsClient.PublishAsync(new PublishRequest {
                            TopicArn = _loggingTopicArn,
                            Message  = payload
                        }).Wait();
                    } catch (Exception e) {
                        Log(LambdaLogLevel.ERROR, "SNS publish exception", e.ToString());
                        Log(LambdaLogLevel.INFO, "logging payload", payload);
                    }
                }
            }
        }
예제 #27
0
        public void when_serializing_exception_notice_result_should_not_be_empty()
        {
            var       client    = new RollbarClient();
            Exception exception = new NotImplementedException();

            var notice = client.NoticeBuilder.CreateExceptionNotice(exception);

            notice.Server.Host    = "miker";
            notice.Request.Url    = "http://localhost/hej";
            notice.Request.Method = "GET";
            notice.Request.Headers.Add("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.65 Safari/537.31");
            notice.Request.UserIp  = "67.90.39.34";
            notice.Person.Id       = "123";
            notice.Person.Username = Environment.UserName;

            var serialized = client.Serialize(notice);

            Assert.IsNotNullOrEmpty(serialized);
        }
예제 #28
0
        //--- Methods ---
        public async override Task InitializeAsync(LambdaConfig config)
        {
            var tableName = config.ReadDynamoDBTableName("RegistrationTable");

            _registrations = new RegistrationTable(new AmazonDynamoDBClient(), tableName);
            _rollbarClient = new RollbarClient(
                config.ReadText("RollbarReadAccessToken", defaultValue: null),
                config.ReadText("RollbarWriteAccessToken", defaultValue: null),
                message => LogInfo(message)
                );
            _rollbarProjectPattern = config.ReadText("RollbarProjectPattern");
            _coreSecretsKey        = config.ReadText("CoreSecretsKey");

            // set default project pattern if none is specified
            if (_rollbarProjectPattern == "")
            {
                var rollbarProjectPrefix = config.ReadText("RollbarProjectPrefix");
                _rollbarProjectPattern = $"{rollbarProjectPrefix}{{ModuleFullName}}";
            }
        }
예제 #29
0
        public void TestPayloadScrubbing()
        {
            string initialPayload =
                "{\"access_token\":\"17965fa5041749b6bf7095a190001ded\",\"data\":{\"environment\":\"_Rollbar - unit - tests\",\"body\":{\"message\":{\"body\":\"Via log4net\"}},\"level\":\"info\",\"timestamp\":1555443532,\"platform\":\"Microsoft Windows 10.0.17763 \",\"language\":\"c#\",\"framework\":\".NETCoreApp,Version=v2.1\",\"custom\":{\"log4net\":{\"LoggerName\":\"RollbarAppenderFixture\",\"Level\":{\"Name\":\"INFO\",\"Value\":40000,\"DisplayName\":\"INFO\"},\"Message\":\"Via log4net\",\"ThreadName\":\"3\",\"TimeStamp\":\"2019-04-16T12:38:49.0503367-07:00\",\"LocationInfo\":null,\"UserName\":\"NOT AVAILABLE\",\"Identity\":\"NOT AVAILABLE\",\"ExceptionString\":\"\",\"Domain\":\"NOT AVAILABLE\",\"Properties\":{\"log4net:UserName\":\"NOT AVAILABLE\",\"log4net:HostName\":\"wscdellwin\",\"log4net:Identity\":\"NOT AVAILABLE\"},\"TimeStampUtc\":\"2019-04-16T19:38:49.0503367Z\"}},\"uuid\":\"25f57cce37654291a1ea517fb5dfb255\",\"notifier\":{\"name\":\"Rollbar.NET\",\"version\":\"3.0.6\"}}}";

            string[] scrubFields = new string[]
            {
                "log4net:UserName",
                "log4net:HostName",
                "log4net:Identity",
            };

            Assert.IsFalse(initialPayload.Contains("***"));
            string scrubbedPayload = RollbarClient.ScrubPayload(initialPayload, scrubFields);

            Assert.IsTrue(scrubbedPayload.Contains("***"));
            Assert.IsTrue(scrubbedPayload.Contains("\"log4net:UserName\": \"***\""));
            Assert.IsTrue(scrubbedPayload.Contains("\"log4net:HostName\": \"***\""));
            Assert.IsTrue(scrubbedPayload.Contains("\"log4net:Identity\": \"***\""));
        }
예제 #30
0
        /// <summary>
        /// First attemps to create a RollbarClient using config read from
        /// appSettings. Uses properties of this class as overrides if specified.
        /// </summary>
        /// <param name="logEvent"></param>
        /// <returns></returns>
        private RollbarClient CreateClient(LogEventInfo logEvent)
        {
            var client = new RollbarClient();

            client.RequestStarting  += RollbarClientRequestStarting;
            client.RequestCompleted += RollbarClientRequestCompleted;

            if (!string.IsNullOrEmpty(AccessToken))
            {
                client.Configuration.AccessToken = AccessToken;
            }

            if (!string.IsNullOrEmpty(Endpoint))
            {
                client.Configuration.Endpoint = Endpoint;
            }

            if (Environment != null)
            {
                client.Configuration.Environment = Environment.Render(logEvent);
            }

            if (Platform != null)
            {
                client.Configuration.Platform = Platform.Render(logEvent);
            }

            if (Language != null)
            {
                client.Configuration.Language = Language.Render(logEvent);
            }

            if (Framework != null)
            {
                client.Configuration.Framework = Framework.Render(logEvent);
            }

            return(client);
        }
예제 #31
0
        public void ItPushesErrorsUpToTheServer()
        {
            RollbarClient rollbarClient = new RollbarClient();

            rollbarClient.SendErrorException(new Exception("Integration Test"));
        }
예제 #32
0
        public LinkOrphanGamesJobResult LinkOrphanGames()
        {
            var result    = new LinkOrphanGamesJobResult();
            var stopwatch = new Stopwatch();

            stopwatch.Start();
            try
            {
                var orphanGames = GetOrphanGames();
                result.OrphanGames = orphanGames.Count;

                foreach (var game in orphanGames)
                {
                    var gameName = RemoveYear(game.Name);

                    var existingGame = GetExistingBGGGameByName(gameName);
                    if (existingGame != null)
                    {
                        UpdateGameDefinition(game, existingGame.Id, result);
                    }
                    else
                    {
                        var searchResult = _boardGameGeekApiClient.SearchBoardGames(gameName, true);
                        if (searchResult.Any())
                        {
                            var gameToAdd = GetGameToAddFromSearch(searchResult);

                            if (gameToAdd != null)
                            {
                                existingGame = GetExistingBGGGameById(gameToAdd);
                                if (existingGame != null)
                                {
                                    UpdateGameDefinition(game, existingGame.Id, result);
                                }
                                else
                                {
                                    var newRecord = CreateBGGGame(gameToAdd);

                                    UpdateGameDefinition(game, newRecord.Id, result);
                                }
                            }
                        }
                    }

                    if (game.BoardGameGeekGameDefinitionId != null)
                    {
                        _dataContext.CommitAllChanges();
                    }
                    else
                    {
                        result.StillOrphanGames.Add(new LinkOrphanGamesJobResult.OrphanGame()
                        {
                            Name          = game.Name,
                            Id            = game.Id,
                            GamingGroupId = game.GamingGroupId
                        });
                    }
                }
            }
            catch (Exception ex)
            {
                result.Success = false;
                RollbarClient.SendException(ex);
            }

            stopwatch.Stop();
            result.TimeEllapsed = stopwatch.Elapsed;
            return(result);
        }