public Task Push(Packet <IScenePeerClient> ctx) { var documentDto = ctx.ReadObject <DocumentDto>(); if (documentDto.Type == null) { throw new ArgumentNullException($"invalid analytics document received. 'Type' is null"); } if (!System.Text.RegularExpressions.Regex.IsMatch(documentDto.Type, TypeRegex)) { _logger.Log(LogLevel.Error, "analytics", $"Invalid analytics type type received : {documentDto.Type}", documentDto); } // Add some meta data for kibana try { Newtonsoft.Json.Linq.JObject content = Newtonsoft.Json.Linq.JObject.Parse(documentDto.Content);//Try parse document AnalyticsDocument document = new AnalyticsDocument { Type = documentDto.Type, Content = content, CreationDate = DateTime.UtcNow }; _analytics.Push(document); } catch (Exception) { _logger.Log(LogLevel.Error, "analytics", $"Invalid analytics json received", documentDto.Content); } return(Task.CompletedTask); }
/// <summary> /// Push data in memory /// </summary> /// <param name="content">String to store</param> public void Push(AnalyticsDocument content) { var store = _documents.GetOrAdd(content.Type, t => new ConcurrentQueue <AnalyticsDocument>()); content.CreationDate = DateTime.UtcNow; store.Enqueue(content); }
/// <summary> /// Push data in memory /// </summary> /// <param name="group">Index type where the data will be store</param> /// <param name="category">category of analytics document, for search purpose</param> /// <param name="document">Json object to store</param> public void Push(string group, string category, JObject content) { AnalyticsDocument document = new AnalyticsDocument { Content = content, Type = group, Category = category }; Push(document); }