Пример #1
0
        public LogSharkRunner(LogSharkConfiguration config, MetricsModule metricsModule, ILoggerFactory loggerFactory)
        {
            CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture;

            _loggerFactory = loggerFactory;
            _logger        = loggerFactory.CreateLogger <LogSharkRunner>();

            _config = config;

            _processingNotificationsCollector = new ProcessingNotificationsCollector(_config.NumberOfErrorDetailsToKeep);

            if (_config.PublishWorkbooks)
            {
                var tableauServerInfo = new TableauServerInfo(
                    _config.TableauServerUrl,
                    _config.TableauServerSite,
                    _config.TableauServerUsername,
                    _config.TableauServerPassword,
                    _config.TableauServerTimeout);
                _publisherSettings = new PublisherSettings(
                    tableauServerInfo,
                    _config.GroupsToProvideWithDefaultPermissions,
                    _config.ApplyPluginProvidedTagsToWorkbooks,
                    _config.ParentProjectId,
                    _config.ParentProjectName);
            }
            _metricsModule = metricsModule;
        }
Пример #2
0
        public async Task MetricsShouldKeepUserDataOnLevelFull()
        {
            var metricsModule = new MetricsModule(_configurationLevelFull, new NullLoggerFactory());

            await metricsModule.ReportStartMetrics(_configDefault);

            var uploadedModel = _testUploader.UploadedPayloads[0] as StartMetrics;

            uploadedModel.System.Username.Should().NotBeNullOrWhiteSpace();
        }
Пример #3
0
        public static void Initialize()
        {
            // Atomic Modules
            CoreModule.Initialize();
            MathModule.Initialize();
            EngineModule.Initialize();
            InputModule.Initialize();
            IOModule.Initialize();
            ResourceModule.Initialize();
            AudioModule.Initialize();
            GraphicsModule.Initialize();
            SceneModule.Initialize();
            Atomic2DModule.Initialize();
            NavigationModule.Initialize();
            NetworkModule.Initialize();
            PhysicsModule.Initialize();
            EnvironmentModule.Initialize();
            UIModule.Initialize();

#if ATOMIC_DESKTOP
            IPCModule.Initialize();
#endif

            AtomicAppModule.Initialize();
            ScriptModule.Initialize();
            MetricsModule.Initialize();

            AtomicNETScriptModule.Initialize();
            AtomicNETNativeModule.Initialize();

            PlayerModule.Initialize();

            IntPtr coreptr = csi_Atomic_NETCore_Initialize(eventDispatchDelegate, updateDispatchDelegate, refCountedDeletedDelegate, throwManagedExceptionDelegate);

            NETCore core = (coreptr == IntPtr.Zero ? null : NativeCore.WrapNative <NETCore>(coreptr));

            if (core != null)
            {
                AtomicNET.RegisterSubsystem(core);
            }

            context = NETCore.Context;

            NativeCore.Initialize();
            CSComponentCore.Initialize();

#if ATOMIC_DESKTOP
            string[] arguments = Environment.GetCommandLineArgs();
            foreach (string arg in arguments)
            {
                AppBase.AddArgument(arg);
            }
#endif
        }
Пример #4
0
        public async Task MetricsShouldNotUploadOnEmptyConfig()
        {
            var metricsModule = new MetricsModule(null, new NullLoggerFactory());

            await metricsModule.ReportStartMetrics(_configDefault);

            _testUploader.UploadCallCount.Should().Be(0);

            await metricsModule.ReportEndMetrics(_runSummaryDefault);

            _testUploader.UploadCallCount.Should().Be(0);
        }
Пример #5
0
        public async Task MetricsShouldNotUploadOnTelemetryLevelNone()
        {
            var metricsModule = new MetricsModule(_configurationLevelNone, new NullLoggerFactory());

            await metricsModule.ReportStartMetrics(_configDefault);

            _testUploader.UploadCallCount.Should().Be(0);

            await metricsModule.ReportEndMetrics(_runSummaryDefault);

            _testUploader.UploadCallCount.Should().Be(0);
        }
Пример #6
0
        public LogSharkRunner(LogSharkConfiguration config, MetricsModule metricsModule, ILoggerFactory loggerFactory)
        {
            CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture;

            _loggerFactory = loggerFactory;
            _logger        = loggerFactory.CreateLogger <LogSharkRunner>();

            _config = config;

            _processingNotificationsCollector = new ProcessingNotificationsCollector(_config.NumberOfErrorDetailsToKeep);

            if (_config.PublishWorkbooks)
            {
                _publisherSettings = config.GetPublisherSettings();
            }

            _metricsModule = metricsModule;
        }
Пример #7
0
        private async Task <int> OnExecute()
        {
            var exeDir        = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
            var configuration = new ConfigurationBuilder()
                                .SetBasePath(exeDir)
                                .AddJsonFile(Config ?? "config/LogSharkConfig.json", optional: false, reloadOnChange: false)
                                .Build();

            var loggerFactory = ConfigureLogging(configuration);
            var logger        = loggerFactory.CreateLogger <Program>();

            var clParameters = new LogSharkCommandLineParameters
            {
                AppendTo                   = AppendTo,
                DatabaseName               = SqlDbName,
                DatabaseConnectionString   = SqlDbConnectionString,
                DatabaseHost               = SqlDbHost,
                DatabasePassword           = SqlDbPassword,
                DatabaseUsername           = SqlDbUser,
                EmbedCredentialsOnPublish  = SqlEmbedCreds,
                ForceRunId                 = ForceRunId,
                LogSetLocation             = LogSetLocation,
                PublishWorkbooks           = PublishWorkbooks,
                RequestedPlugins           = RequestedPlugins,
                UserProvidedRunId          = RunId,
                RequestedWriter            = Writer,
                TableauServerUsername      = Username,
                TableauServerPassword      = Password,
                TableauServerSite          = Site,
                TableauServerUrl           = Url,
                WorkbookNameSuffixOverride = WorkbookNameSuffixOverride,
            };
            var config = new LogSharkConfiguration(clParameters, configuration, loggerFactory);

            var metricUploaderConfiguration = new MetricsUploaderConfiguration(config);
            var metricUploader = new MetricUploader(metricUploaderConfiguration, loggerFactory);
            var metricsConfig  = new MetricsConfig(metricUploader, config);
            var metricsModule  = new MetricsModule(metricsConfig, loggerFactory);

            try
            {
                if (ListPLugins)
                {
                    using (var pluginManager = new PluginManager(config, loggerFactory))
                    {
                        var plugins = string.Join("\n\t- ", pluginManager.GetKnownPluginNames());
                        Console.WriteLine($"Available plugins:\n\t- {plugins}");
                    }
                    return(EnvironmentController.SetExitCode(ExitCode.OK));
                }
                else if (string.IsNullOrWhiteSpace(LogSetLocation))
                {
                    Console.WriteLine("The LogSetLocation field is required.\nSpecify--help for a list of available options and commands.");
                    return(EnvironmentController.SetExitCode(ExitCode.ERROR));
                }
                else
                {
                    var runner     = new LogSharkRunner(config, metricsModule, loggerFactory);
                    var runSummary = await runner.Run();

                    EnvironmentController.SetExitCode(runSummary, false);

                    logger.LogInformation(runSummary.ToStringReport());
                }
            }
            finally
            {
                loggerFactory.Dispose();
                Thread.Sleep(200); // Otherwise logger does not write final message sometimes
            }

            return(Environment.ExitCode);
        }