/// <summary> /// Add a log event to the ElasticSearch Repo /// </summary> /// <param name="loggingEvent"></param> protected override void Append(LoggingEvent loggingEvent) { if (_client == null || loggingEvent == null) { return; } if (DropEventsOverBulkLimit && _bulk.Count >= BulkSize) { _tolerateCalls.Call(() => LogLog.Warn(GetType(), "Message lost due to bulk overflow! Set DropEventsOverBulkLimit to false in order to prevent that."), GetType(), 0); return; } var logEvent = LogEventFactory.CreateLogEvent(loggingEvent); PrepareAndAddToBulk(logEvent); if (!DropEventsOverBulkLimit && _bulk.Count >= BulkSize && BulkSize > 0) { DoIndexNow(); } }
private void ReportOverflow() { _tolerateCalls.Call(() => _eventWriter.Warn(GetType(), "Message lost due to bulk overflow! Set DropEventsOverBulkLimit to false in order to prevent that."), GetType(), 0); }
private void Checker(TolerateCallsBase tolerator, bool shouldTolerate) { var t = GetType(); var mock = new FuncMock(); Parallel.For(0, 100, i => tolerator.Call(mock.Inc, t, 0)); Assert.AreEqual(shouldTolerate ? 1 : 100, mock.Times); Parallel.For(0, 100, i => tolerator.Call(mock.Inc, t, 1)); Assert.AreEqual(shouldTolerate ? 2 : 200, mock.Times); Thread.Sleep(TimeSpan.FromSeconds(TimeSec)); Parallel.For(0, 100, i => tolerator.Call(mock.Inc, t, 0)); Parallel.For(0, 100, i => tolerator.Call(mock.Inc, t, 1)); Assert.AreEqual(shouldTolerate ? 4 : 400, mock.Times); }