public PaletteInsightAgent(bool loadOptionsFromConfig = true)
        {
            // Set the working directory
            Assembly assembly = Assembly.GetExecutingAssembly();

            Directory.SetCurrentDirectory(Path.GetDirectoryName(assembly.Location));

            APIClient.SetTrustSSL();

            // Load PaletteInsightAgentOptions.  In certain use cases we may not want to load options from the config, but provide them another way (such as via a UI).
            options = PaletteInsightAgentOptions.Instance;

            // Locate the Tableau data folder
            tableauDataFolder = Loader.FindTableauDataFolder();

            var configuration = Loader.LoadConfigFile("config/Config.yml");

            Loader.LoadConfigTo(configuration, tableauDataFolder, options);

            // Make sure that our HTTP client is initialized, because Splunk logger might be enabled
            // and it is using HTTP to send log messages to Splunk.
            APIClient.Init(options.WebserviceConfig);

            // Add the webservice username/auth token from the license
            Configuration.Loader.UpdateWebserviceConfigFromLicense(options);

            // NOTE: License check disabled as this project became open-source
            //// check the license after the configuration has been loaded.
            //licenseGuard = new LicenseGuard();
            //if (!licenseGuard.CheckLicense(options.LicenseKey))
            //{
            //    Log.Fatal("Invalid license! Exiting...");
            //    Environment.Exit(-1);
            //}

            // Showing the current version in the log
            FileVersionInfo fvi     = FileVersionInfo.GetVersionInfo(assembly.Location);
            string          version = fvi.FileVersion;

            Log.Info("Palette Insight Agent version: " + version);

            USE_LOGPOLLER      = options.UseLogPolling;
            USE_THREADINFO     = options.UseThreadInfo;
            USE_COUNTERSAMPLES = options.UseCounterSamples;

            USE_TABLEAU_REPO     = options.UseRepoPolling;
            USE_STREAMING_TABLES = options.UseStreamingTables;
            if (USE_TABLEAU_REPO != USE_STREAMING_TABLES)
            {
                // Having different setup for Tableau repo and streaming tables is not welcome
                Log.Error("Invalid repo poll configuration! Either both Tableau repo poll and streaming tables poll should be enabled, or neither! Repo poll: {0} vs. Streaming tables: {1}",
                          USE_TABLEAU_REPO, USE_STREAMING_TABLES);
            }

            if (USE_LOGPOLLER)
            {
                // Load the log poller config & start the agent
                logPollerAgent = new LogPollerAgent(options.LogFolders, options.LogLinesPerBatch);
            }

            if (USE_THREADINFO)
            {
                // start the thread info agent
                threadInfoAgent = new ThreadInfoAgent(options.ThreadInfoPollInterval);
            }

            Loader.AddRepoFromWorkgroupYaml(configuration, tableauDataFolder, options);
            tableauRepo   = new Tableau9RepoConn(options.RepositoryDatabase, options.StreamingTablesPollLimit);
            repoPollAgent = new RepoPollAgent();
        }