/// <inheritdoc/> public IEventProcessor CreateEventProcessor(LdClientContext context) { var eventsConfig = new EventsConfiguration { AllAttributesPrivate = _allAttributesPrivate, DiagnosticRecordingInterval = _diagnosticRecordingInterval, EventCapacity = _capacity, EventFlushInterval = _flushInterval, EventsUri = new Uri(_baseUri, "bulk"), DiagnosticUri = new Uri(_baseUri, "diagnostic"), InlineUsersInEvents = _inlineUsersInEvents, PrivateAttributeNames = _privateAttributes.ToImmutableHashSet(), UserKeysCapacity = _userKeysCapacity, UserKeysFlushInterval = _userKeysFlushInterval }; var logger = context.Basic.Logger.SubLogger(LogNames.EventsSubLog); var eventSender = _eventSender ?? new DefaultEventSender( context.Http.HttpProperties, eventsConfig, logger ); return(new DefaultEventProcessorWrapper( new EventProcessor( eventsConfig, eventSender, new DefaultUserDeduplicator(_userKeysCapacity, _userKeysFlushInterval), context.DiagnosticStore, null, logger, null ))); }
public void Referenced_Fields_Are_Added() { var ambientField = new DynamicFieldDefinition("A1", ConfigParser.FieldType.String); var config = new EventsConfiguration( new Dictionary <string, EventDefinition> { { "TEST", new EventDefinition(new Dictionary <string, IFieldDefinition> { { "A1ref", new ReferenceFieldDefinition("A1ref", ambientField) } }, 100, "TEST") } }, new Dictionary <string, IFieldDefinition> { { ambientField.Name, ambientField } }); var ambientContext = new Mock <IAmbientContext>(); ambientContext.Setup(x => x.GetValue("A1")).Returns("V1"); var dispatcherMock = new Mock <IEventDispatcher>(); var sut = new EventStream(ambientContext.Object, dispatcherMock.Object, new EventStreamSettings(), config); sut.SendAsync(new Event("TEST", new KeyValuePair <string, object> [0])); dispatcherMock.Verify(x => x.Dispatch(It.Is <Event>(e => e.Fields.Count == 1 && e.Fields.First().Key == "A1ref" && e.Fields.First().Value.ToString() == "V1" ))); }
public EventStream( IAmbientContext ambientContext, IEventDispatcher dispatcher, EventStreamSettings settings, EventsConfiguration configuration) { _ambientContext = ambientContext; _dispatcher = dispatcher; _settings = settings; _configuration = configuration; }
private Event GetEvent(string eventName, string agentVersion) { var version = new Version(agentVersion); var version13 = new Version("1.3.0"); var version12 = new Version("1.2.0"); var version11 = new Version("1.1.0"); var version10 = new Version("1.0.0"); // Version 1.2 var config = v12EventsConfiguration; string configPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "v12events.config"); // Version 1.3 if (version >= version13) { config = v13EventsConfiguration; configPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "v13events.config"); } // Read the EventsConfiguration file if (config == null) { config = EventsConfiguration.Get(configPath); } if (config != null) { if (version >= version13) { v13EventsConfiguration = config; } else { v12EventsConfiguration = config; } if (!string.IsNullOrEmpty(eventName)) { return(config.Events.Find(o => o.Name.ToLower() == eventName.ToLower())); } } return(null); }
private List <Event> GetEvents(string agentVersion) { var version = new Version(agentVersion); var version13 = new Version("1.3.0"); var version12 = new Version("1.2.0"); var version11 = new Version("1.1.0"); var version10 = new Version("1.0.0"); // Version 1.2 var config = v12EventsConfiguration; string configPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "v12events.config"); // Version 1.3 if (version >= version13) { config = v13EventsConfiguration; configPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "v13events.config"); } // Read the EventsConfiguration file if (config == null) { config = EventsConfiguration.Get(configPath); } if (config != null) { if (version >= version13) { v13EventsConfiguration = config; } else { v12EventsConfiguration = config; } return(config.Events); } return(null); }
public void Event_Is_Sampled_By_Seed() { var config = new EventsConfiguration( new Dictionary <string, EventDefinition> { { "TEST", new EventDefinition(new Dictionary <string, IFieldDefinition>(), 5, "TEST") } }, new Dictionary <string, IFieldDefinition>()); var ambientContext = new Mock <IAmbientContext>(); var dispatcherMock = new Mock <IEventDispatcher>(); var sut = new EventStream(ambientContext.Object, dispatcherMock.Object, new EventStreamSettings(), config); for (var i = 0; i < 1000; i++) { ambientContext.Setup(x => x.UserSeed).Returns(i); sut.SendAsync(new Event("TEST", new KeyValuePair <string, object> [0])); } dispatcherMock.Verify(x => x.Dispatch(It.IsAny <Event>()), Times.Exactly(50)); }