public MoesifMiddlewareNetFramework(OwinMiddleware next, Dictionary <string, object> _middleware) : base(next) { moesifOptions = _middleware; try { // Initialize client debug = LoggerHelper.GetConfigBoolValues(moesifOptions, "LocalDebug", false); client = new MoesifApiClient(moesifOptions["ApplicationId"].ToString(), "moesif-netframework/1.3.8", debug); logBody = LoggerHelper.GetConfigBoolValues(moesifOptions, "LogBody", true); isBatchingEnabled = LoggerHelper.GetConfigBoolValues(moesifOptions, "EnableBatching", true); // Enable batching disableStreamOverride = LoggerHelper.GetConfigBoolValues(moesifOptions, "DisableStreamOverride", false); // Reset Request Body position batchSize = LoggerHelper.GetConfigIntValues(moesifOptions, "BatchSize", 25); // Batch Size queueSize = LoggerHelper.GetConfigIntValues(moesifOptions, "QueueSize", 1000); // Event Queue Size batchMaxTime = LoggerHelper.GetConfigIntValues(moesifOptions, "batchMaxTime", 2); // Batch max time in seconds appConfigSyncTime = LoggerHelper.GetConfigIntValues(moesifOptions, "appConfigSyncTime", 300); // App config sync time in seconds appConfig = new AppConfig(); // Create a new instance of AppConfig userHelper = new UserHelper(); // Create a new instance of userHelper companyHelper = new CompanyHelper(); // Create a new instane of companyHelper clientIpHelper = new ClientIp(); // Create a new instance of client Ip authorizationHeaderName = LoggerHelper.GetConfigStringValues(moesifOptions, "AuthorizationHeaderName", "authorization"); authorizationUserIdField = LoggerHelper.GetConfigStringValues(moesifOptions, "AuthorizationUserIdField", "sub"); samplingPercentage = 100; // Default sampling percentage configETag = null; // Default configETag lastUpdatedTime = DateTime.UtcNow; // Default lastUpdatedTime MoesifQueue = new ConcurrentQueue <EventModel>(); // Initialize queue new Thread(async() => // Create a new thread to read the queue and send event to moesif { Thread.CurrentThread.IsBackground = true; if (isBatchingEnabled) { ScheduleWorker(); } else { ScheduleAppConfig(); // Scheduler to fetch application configuration every 5 minutes } }).Start(); } catch (Exception e) { throw new Exception("Please provide the application Id to send events to Moesif"); } }