Ejemplo n.º 1
0
        public SuperDumpRepository(
            IOptions <SuperDumpSettings> settings,
            BundleRepository bundleRepo,
            DumpRepository dumpRepo,
            AnalysisService analysisService,
            DownloadService downloadService,
            SymStoreService symStoreService,
            UnpackService unpackService,
            PathHelper pathHelper,
            IdenticalDumpRepository identicalRepository,
            IOneAgentSdk dynatraceSdk)
        {
            this.settings            = settings;
            this.bundleRepo          = bundleRepo;
            this.dumpRepo            = dumpRepo;
            this.analysisService     = analysisService;
            this.downloadService     = downloadService;
            this.symStoreService     = symStoreService;
            this.unpackService       = unpackService;
            this.pathHelper          = pathHelper;
            this.identicalRepository = identicalRepository;
            pathHelper.PrepareDirectories();

            this.dynatraceSdk   = dynatraceSdk;
            messagingSystemInfo = dynatraceSdk.CreateMessagingSystemInfo("Hangfire", "download", MessageDestinationType.QUEUE, ChannelType.IN_PROCESS, null);
        }
Ejemplo n.º 2
0
        public AnalyzerPipeline(
            DumpRepository dumpRepo,
            BundleRepository bundleRepo,
            PathHelper pathHelper,
            IOptions <SuperDumpSettings> settings,
            ElasticSearchService elasticSearch,
            SimilarityService similarityService,
            FaultReportingService faultReportingService,
            IOneAgentSdk dynatraceSdk)
        {
            var analyzers = new List <AnalyzerJob>();

            analyzers.Add(new DumpAnalyzerJob(dumpRepo, settings, pathHelper, dynatraceSdk));
            analyzers.Add(new EmptyAnalyzerJob(dumpRepo));

            var postAnalyzers = new List <PostAnalysisJob>();

            postAnalyzers.Add(new ElasticSearchJob(bundleRepo, dumpRepo, elasticSearch));
            postAnalyzers.Add(new SimilarityAnalyzerJob(similarityService, settings));
            postAnalyzers.Add(new FaultReportJob(faultReportingService, settings));

            Analyzers        = analyzers;
            InitialAnalyzers = analyzers.Where(analyzerJob => analyzerJob is InitalAnalyzerJob).Cast <InitalAnalyzerJob>();
            PostAnalysisJobs = postAnalyzers;
        }
Ejemplo n.º 3
0
        public ElasticSearchService(DumpRepository dumpRepo, BundleRepository bundleRepo, PathHelper pathHelper, IOptions <SuperDumpSettings> settings,
                                    IOneAgentSdk dynatraceSdk)
        {
            this.dumpRepo   = dumpRepo ?? throw new NullReferenceException("DumpRepository must not be null!");
            this.bundleRepo = bundleRepo ?? throw new NullReferenceException("BundleRepository must not be null!");
            this.pathHelper = pathHelper ?? throw new NullReferenceException("PathHelper must not be null!");

            this.dynatraceSdk   = dynatraceSdk;
            messagingSystemInfo = dynatraceSdk.CreateMessagingSystemInfo("Hangfire", "elasticsearch", MessageDestinationType.QUEUE, ChannelType.IN_PROCESS, null);

            string host = settings.Value.ElasticSearchHost;

            if (string.IsNullOrEmpty(host))
            {
                elasticClient = null;
                return;
            }
            ConnectionSettings connSettings = new ConnectionSettings(new Uri(settings.Value.ElasticSearchHost));

            ((IConnectionSettingsValues)connSettings).DefaultIndices.Add(typeof(ElasticSDResult), RESULT_IDX);

            elasticClient = new ElasticClient(connSettings);

            if (!IndexExists())
            {
                CreateIndex();
            }
        }
Ejemplo n.º 4
0
        public TraceGrainCallFilter(ILogger <TraceGrainCallFilter> logger)
        {
            _logger      = logger;
            _oneAgentSdk = OneAgentSdkFactory.CreateInstance();
            var loggingCallback = new StdErrLoggingCallback();

            _oneAgentSdk.SetLoggingCallback(loggingCallback);
        }
Ejemplo n.º 5
0
        public SimilarityService(DumpRepository dumpRepo, RelationshipRepository relationShipRepository, IOptions <SuperDumpSettings> settings,
                                 IOneAgentSdk dynatraceSdk)
        {
            this.dumpRepo         = dumpRepo;
            this.relationShipRepo = relationShipRepository;
            this.settings         = settings;

            this.dynatraceSdk   = dynatraceSdk;
            messagingSystemInfo = dynatraceSdk.CreateMessagingSystemInfo("Hangfire", "similarityanalysis", MessageDestinationType.QUEUE, ChannelType.IN_PROCESS, null);
        }
Ejemplo n.º 6
0
 public DumpAnalyzerJob(
     DumpRepository dumpRepo,
     IOptions <SuperDumpSettings> settings,
     PathHelper pathHelper,
     IOneAgentSdk dynatraceSdk)
 {
     this.dumpRepo     = dumpRepo;
     this.settings     = settings;
     this.pathHelper   = pathHelper;
     this.dynatraceSdk = dynatraceSdk;
 }
Ejemplo n.º 7
0
 public AnalysisService(
     DumpRepository dumpRepo,
     BundleRepository bundleRepo,
     PathHelper pathHelper,
     NotificationService notifications,
     AnalyzerPipeline analyzerPipeline,
     IOneAgentSdk dynatraceSdk
     )
 {
     this.dumpRepo         = dumpRepo;
     this.bundleRepo       = bundleRepo;
     this.pathHelper       = pathHelper;
     this.notifications    = notifications;
     this.analyzerPipeline = analyzerPipeline;
     this.dynatraceSdk     = dynatraceSdk;
     messagingSystemInfo   = dynatraceSdk.CreateMessagingSystemInfo("Hangfire", "analysis", MessageDestinationType.QUEUE, ChannelType.IN_PROCESS, null);
 }
Ejemplo n.º 8
0
        public RedisCartStore(string redisAddress)
        {
            // Serialize empty cart into byte array.
            var cart = new Hipstershop.Cart();

            emptyCartBytes   = cart.ToByteArray();
            connectionString = $"{redisAddress},ssl=false,allowAdmin=true,connectRetry=5";

            redisConnectionOptions = ConfigurationOptions.Parse(connectionString);

            // Try to reconnect if first retry failed (up to 5 times with exponential backoff)
            redisConnectionOptions.ConnectRetry         = REDIS_RETRY_NUM;
            redisConnectionOptions.ReconnectRetryPolicy = new ExponentialRetry(100);

            redisConnectionOptions.KeepAlive = 180;

            oneAgentSdk = OneAgentSdkFactory.CreateInstance();
            dbInfo      = oneAgentSdk.CreateDatabaseInfo("Cache", "Redis", ChannelType.TCP_IP, redisAddress);
        }
Ejemplo n.º 9
0
 public AnalysisService(
     IDumpStorage dumpStorage,
     DumpRepository dumpRepo,
     BundleRepository bundleRepo,
     PathHelper pathHelper,
     IOptions <SuperDumpSettings> settings,
     NotificationService notifications,
     ElasticSearchService elasticSearch,
     SimilarityService similarityService,
     IOneAgentSdk dynatraceSdk
     )
 {
     this.dumpStorage       = dumpStorage;
     this.dumpRepo          = dumpRepo;
     this.bundleRepo        = bundleRepo;
     this.pathHelper        = pathHelper;
     this.settings          = settings;
     this.notifications     = notifications;
     this.elasticSearch     = elasticSearch;
     this.similarityService = similarityService;
     this.dynatraceSdk      = dynatraceSdk;
     messagingSystemInfo    = dynatraceSdk.CreateMessagingSystemInfo("Hangfire", "analysis", MessageDestinationType.QUEUE, ChannelType.IN_PROCESS, null);
 }
Ejemplo n.º 10
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app,
                              IOptions <SuperDumpSettings> settings,
                              IServiceProvider serviceProvider,
                              SlackNotificationService sns,
                              IAuthorizationHelper authorizationHelper,
                              ILoggerFactory loggerFactory,
                              IOneAgentSdk oneAgentSdk)
        {
            Task.Run(async() => await app.ApplicationServices.GetService <BundleRepository>().Populate());
            Task.Run(async() => await app.ApplicationServices.GetService <RelationshipRepository>().Populate());
            Task.Run(async() => await app.ApplicationServices.GetService <IdenticalDumpRepository>().Populate());
            if (settings.Value.UseJiraIntegration)
            {
                Task.Run(async() => await app.ApplicationServices.GetService <JiraIssueRepository>().Populate());
            }

            // configure Logger
            loggerFactory.AddConsole(config.GetSection("Logging"));

            var fileLogConfig = config.GetSection("FileLogging");
            var logPath       = Path.GetDirectoryName(fileLogConfig.GetValue <string>("PathFormat"));

            Directory.CreateDirectory(logPath);
            loggerFactory.AddFile(config.GetSection("FileLogging"));

            if (settings.Value.UseAllRequestLogging)
            {
                loggerFactory.AddFile(config.GetSection("RequestFileLogging"));
            }

            loggerFactory.AddDebug();

            oneAgentSdk.SetLoggingCallback(new DynatraceSdkLogger(loggerFactory.CreateLogger <DynatraceSdkLogger>()));

            if (settings.Value.UseHttpsRedirection)
            {
                app.UseHttpsRedirection();
            }
            if (settings.Value.UseLdapAuthentication)
            {
                app.UseAuthentication();
                app.UseSwaggerAuthorizationMiddleware(authorizationHelper);
            }
            else
            {
                app.MapWhen(context => context.Request.Path.StartsWithSegments("/Login") || context.Request.Path.StartsWithSegments("/api/Token"),
                            appBuilder => appBuilder.Run(async context => {
                    context.Response.StatusCode = 404;
                    await context.Response.WriteAsync("");
                }));
            }

            if (settings.Value.UseAllRequestLogging)
            {
                ILogger logger = loggerFactory.CreateLogger("SuperDumpServiceRequests");
                app.Use(async(context, next) => {
                    logger.LogRequest(context);
                    await next.Invoke();
                });
            }

            app.UseHangfireDashboard("/hangfire", new DashboardOptions {
                Authorization = new[] { new CustomAuthorizeFilter(authorizationHelper) }
            });

            app.UseHangfireServer(new BackgroundJobServerOptions {
                Queues      = new[] { "download" },
                WorkerCount = settings.Value.MaxConcurrentBundleExtraction
            });
            app.UseHangfireServer(new BackgroundJobServerOptions {
                Queues      = new[] { "analysis" },
                WorkerCount = settings.Value.MaxConcurrentAnalysis
            });
            app.UseHangfireServer(new BackgroundJobServerOptions {
                Queues      = new[] { "elasticsearch" },
                WorkerCount = 1
            });
            app.UseHangfireServer(new BackgroundJobServerOptions {
                Queues      = new[] { "retention" },
                WorkerCount = 1
            });
            app.UseHangfireServer(new BackgroundJobServerOptions {
                Queues      = new[] { "similarityanalysis" },
                WorkerCount = 8
            });
            if (settings.Value.UseJiraIntegration)
            {
                app.UseHangfireServer(new BackgroundJobServerOptions {
                    Queues      = new[] { "jirastatus" },
                    WorkerCount = 2
                });

                JiraIssueRepository jiraIssueRepository = app.ApplicationServices.GetService <JiraIssueRepository>();
                jiraIssueRepository.StartRefreshHangfireJob();
                jiraIssueRepository.StartBundleSearchHangfireJob();
            }
            app.ApplicationServices.GetService <DumpRetentionService>().StartService();

            GlobalJobFilters.Filters.Add(new AutomaticRetryAttribute {
                Attempts = 0
            });

            app.UseSwagger();
            app.UseSwaggerUi();
            app.UseHealthChecks("/healthcheck");

            LogProvider.SetCurrentLogProvider(new ColouredConsoleLogProvider());

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                BrowserLinkExtensions.UseBrowserLink(app);                 // using the extension method directly somehow did not work in .NET Core 2.0 (ambiguous extension method)
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseStaticFiles();

            app.UseWebSockets();
            app.MapWebSocketManager("/cmd", serviceProvider.GetService <WebTermHandler>());

            app.UseMvcWithDefaultRoute();
        }
 public CartServiceImpl(ICartStore cartStore)
 {
     this.cartStore = cartStore;
     oneAgentSdk    = OneAgentSdkFactory.CreateInstance();
 }