Exemplo n.º 1
0
        public ExtendedEventsExport(XEventsExportSettings settings, IExtendedEventsOnTargetBuilder xEventsTargetBuilder)
        {
            _settings             = settings;
            _logBuffers           = new LogBuffers();
            _xEventsTargetBuilder = xEventsTargetBuilder;

            foreach (var logSourceSettings in _settings.LogSources)
            {
                _logBuffers.LogPositions.TryAdd(logSourceSettings,
                                                new ConcurrentDictionary <string, ExtendedEventsPosition>());

                var logPositions = xEventsTargetBuilder.GetCurrentLogPositions(settings, logSourceSettings.XEventsLog);
                foreach (var logPosition in logPositions)
                {
                    FileInfo logFileInfo = new FileInfo(logPosition.Value.CurrentFileData);
                    _logBuffers.LogPositions.AddOrUpdate(logSourceSettings,
                                                         (settingsKey) =>
                    {
                        var newPositions = new ConcurrentDictionary <string, ExtendedEventsPosition>();
                        newPositions.AddOrUpdate(logFileInfo.Name,
                                                 (dirName) => logPosition.Value,
                                                 (dirName, oldPosition) => logPosition.Value);
                        return(newPositions);
                    },
                                                         (settingsKey, logBufferItemOld) =>
                    {
                        logBufferItemOld.AddOrUpdate(logFileInfo.Name,
                                                     (dirName) => logPosition.Value,
                                                     (dirName, oldPosition) => logPosition.Value);
                        return(logBufferItemOld);
                    });
                }
            }
        }
 public async Task SaveRowsData(XEventsExportSettings settings, Dictionary<LogBufferItemKey, LogBufferItem> dataFromBuffer)
 {
     using (ClickHouseContext context = new ClickHouseContext(settings.ConnectionString))
     {
         await context.SaveRowsData(dataFromBuffer);
     }
 }
 public IDictionary<string, ExtendedEventsPosition> GetCurrentLogPositions(XEventsExportSettings settings, ExtendedEventsLogBase xEventsLog)
 {
     using (ClickHouseContext context = new ClickHouseContext(settings.ConnectionString))
     {
         return context.GetCurrentLogPositions(xEventsLog);
     }
 }
        public IXEventsOnTarget CreateTarget(XEventsExportSettings settings, KeyValuePair<LogBufferItemKey, LogBufferItem> logBufferItem)
        {
            IXEventsOnTarget target = new ExtendedEventsOnClickHouse(settings.ConnectionString,
                logBufferItem.Key.Settings.Portion);
            target.SetLogInformation(logBufferItem.Key.Settings.XEventsLog);

            return target;
        }