public LogBatchCompletedEventArgs(LogBatchResult Result, Batch Batch) { this.Batch = Batch; this.Result = Result; }
public LogBatchCompletedEventArgs(Exception Error, Batch Batch) { this.Batch = Batch; this.Error = Error; }
private void LogBatchFailed(Batch batch, Exception error) { logAgent.IncrementTotalBatchesFailed(1); if (BatchSendFailed != null) BatchSendFailed(this, new BatchEventArgs(batch)); LogsFailedToSend(error, batch.Logs); }
private bool ProcessQueue(IEnumerable<Log> logs, bool IsAlreadyMapped) { if (logs != null && logs.Count() > 0) { Batch batch = new Batch(); batch.ApplicationName = logAgent.Configuration.ApplicationName; batch.ApplicationVersion = logAgent.Configuration.ApplicationVersion; batch.ApplicationId = logAgent.Configuration.ApplicationId; batch.SessionId = logAgent.SessionId; batch.InstanceId = InstanceDataClient.InstanceId; batch.BatchId = Guid.NewGuid(); batch.TimeStamp = logAgent.ServerTimeOffset.HasValue ? DateTimeOffset.Now.Add(logAgent.ServerTimeOffset.Value).Ticks : DateTimeOffset.Now.Ticks; batch.TotalFailures = FailedSendCount; batch.LogsDropped = logAgent.TotalLogsDropped; batch.LogsSent = logAgent.TotalLogsSent; batch.Logs = logs; Batch mappedBatch; if (!IsAlreadyMapped) { // apply mappings. If mappings are defined, it will create new instance of the batch and the logs using different keys and dropping come elements. mappedBatch = logAgent.MapBatchAndLogs(batch); } else { // apply mappings but ONLY to the batch. The logs have already been mapped. mappedBatch = logAgent.MapBatch(batch); } try { if (BatchSending != null) BatchSending(this, new BatchEventArgs(mappedBatch)); } catch { /* swollow */ } SendCount++; // the data client does the work of actually sending the info to the server return dataClient.LogBatchAsync(mappedBatch); } else return false; }
/// <summary> /// Helper method to deserialize a batch serailized via the default serialization /// </summary> /// <returns>The deserialized batch</returns> public static Batch Deserialize(XmlReader xmlReader) { if (xmlReader.GoToElement()) { Batch result = new Batch(); LogBase.DeserializeData(xmlReader, result); xmlReader.ReadStartElement(); List<Log> logs = new List<Log>(); while (xmlReader.GoToSibling()) { switch (xmlReader.LocalName) { case Log.LogNodeName: var log = Log.Deserialize(xmlReader); logs.Add(log); break; default: xmlReader.Skip(); break; } } result.Logs = logs; xmlReader.ReadEndElement(); return result; } else throw new Exception("Batch is empty"); }
public BatchEventArgs(Batch Batch) { this.Batch = Batch; }
internal Batch MapBatchAndLogs(Batch batch) { if (Configuration.MappingRules == null) return batch; else { IDictionary<string, string> data; foreach (Exception ex in Configuration.MappingRules.TryMap(batch, out data)) BroadcastException(ex); return new Batch(data) { Logs = GetMappedLogs(batch.Logs) }; } }