public static Collector CreateCollector(AddCollectorToConfigCommand addCollectorToConfigCommand) { switch (addCollectorToConfigCommand) { case AddSqlCollectorToConfigCommand command: return(SqlCollectorFactory.CreateCollector(command)); case AddRavenDbCollectorToConfigCommand command: return(RavenDbCollectorFactory.CreateCollector(command)); case AddPerformanceCounterCollectorToConfigCommand command: return(new PerformanceCounterCollector() { Category = command.Category, Counter = command.Counter, MachineName = command.MachineName, Instance = command.Instance }); case AddRestApiCollectorToConfigCommand command: return(new RestApiCollector() { JsonPath = command.JsonPath, RequestUri = command.RequestUri != null ? new Uri(command.RequestUri) : null, TagName = command.TagName }); case AddSystemInformationCollectorToConfigCommand command: return(new SystemInformationCollector()); default: throw new NotSupportedException($"{addCollectorToConfigCommand?.GetType()} is not supported yet."); } }
public Task AddCollectorAsync(string collectorConfigId, AddCollectorToConfigCommand addCollectorCommand) { Collector collector = CollectorFactory.CreateCollector(addCollectorCommand); if (collector != null) { SetCollectorValues(collector, addCollectorCommand); AddCollectorToConfig(collectorConfigId, collector); } return(Task.CompletedTask); }
private void SetCollectorValues(Collector collector, AddCollectorToConfigCommand command) { collector.Id = collector.CreateId(); collector.DisplayName = command.DisplayName; collector.Description = command.Description; collector.StartingTime = command.StartingTime.TryParseDateTimeOffsetFromString(); collector.EndAt = command.EndAt.TryParseDateTimeOffsetFromString(); collector.Priority = command.Priority; collector.OverlappingRecurring = command.OverlappingRecurring; collector.GroupName = command.GroupName; collector.RandomTimeDelay = command.RandomTimeDelay.TryParseTimeSpanFromString(); collector.StartingTimeDelay = command.StartingTimeDelay.TryParseTimeSpanFromString(); collector.PollingInterval = command.PollingInterval.TryParseTimeSpanFromString(); collector.Verifiers = new System.Collections.Generic.List <Verifier>(); }