コード例 #1
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddSingleton(Configuration);
            services.TryAddSingleton <IHttpContextAccessor, HttpContextAccessor>();

            services.AddOptions();
            services.Configure <VaultSettings>(Configuration.GetSection("Vault"));
            services.AddKeyVault(Configuration);

            var appInsightsSettings = new AppInsightsSettings();

            Configuration.Bind("AppInsights:Context", appInsightsSettings);
            var instrumentationKey = services.GetSecret(Configuration, Configuration["AppInsights:InstrumentationKeySecret"]);

            services.AddAppInsights(appInsightsSettings, instrumentationKey);
            services.AddLogging(instrumentationKey);

            services.Configure <DocDbSettings>("SourceDb", Configuration.GetSection("SourceDb"));
            services.Configure <DocDbSettings>("ChangeDb", Configuration.GetSection("ChangeDb"));
            services.Configure <ChangeTrackSettings>(Configuration.GetSection("ChangeTracking"));

            var clientSettings = new HttpClientSettings();

            Configuration.Bind("Clients:EventsProducerApi", clientSettings);
            services.AddClient <IChangeTracker, ChangeTracker>(clientSettings);

            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
        }
コード例 #2
0
            public LogService(IOptions <AppInsightsSettings> settings)
            {
                _settings = settings.Value;

                Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration.Active.InstrumentationKey =
                    _settings.InstrumentationKey;

                _telemetry = new TelemetryClient(new TelemetryConfiguration
                {
                    InstrumentationKey = _settings.InstrumentationKey
                });
            }
コード例 #3
0
        static async Task Main(string[] args)
        {
            var builder = new HostBuilder()
                          .ConfigureAppConfiguration((hostingContext, configBuilder) =>
            {
                configBuilder.AddJsonFile("appsettings.json", optional: true);
            })
                          .ConfigureServices((hostingContext, services) =>
            {
                services.AddOptions();
                services.Configure <VaultSettings>(hostingContext.Configuration.GetSection("Vault"));
                services.Configure <DocDbSettings>(hostingContext.Configuration.GetSection("DocDb"));
                services.Configure <AppInsightsSettings>(
                    hostingContext.Configuration.GetSection("AppInsights:Context"));
                services.Configure <PrometheusMetricSettings>(hostingContext.Configuration.GetSection("Prometheus"));
                services.AddKeyVault(hostingContext.Configuration);

                // add app insights
                var appInsightsSettings = new AppInsightsSettings();
                hostingContext.Configuration.Bind("AppInsights:Context", appInsightsSettings);
                var instrumentationKey = services.GetSecret(hostingContext.Configuration, hostingContext.Configuration["AppInsights:InstrumentationKeySecret"]);
                services.AddAppInsights(appInsightsSettings, instrumentationKey);
                services.AddLogging(instrumentationKey);

                // add prometheus
                var promSettings = new PrometheusMetricSettings();
                hostingContext.Configuration.Bind("Prometheus", promSettings);
                services.UsePrometheus(promSettings);

                // heartbeat and runtime telemetry
                services.AddHostedService <DotNetRuntimeTelemetryWorker>();
                // services.AddHostedService<PrometheusHeartbeat>();
                // services.AddHostedService<AppInsightsHeartbeat>();

                //RunDocDbSyncJob(hostingContext, services);
                //RunDocDbBulkSyncJob(hostingContext, services);
                RunDocDbCopyJob(hostingContext, services);
                //RunEventJob(hostingContext, services);
            });

            await builder.RunConsoleAsync();
        }
コード例 #4
0
        static async Task Main(string[] args)
        {
            var builder = new HostBuilder()
                          .ConfigureAppConfiguration((hostingContext, configBuilder) =>
            {
                configBuilder.AddJsonFile("appsettings.json", optional: true);
            })
                          .ConfigureServices((hostingContext, services) =>
            {
                services.AddOptions();
                services.Configure <VaultSettings>(hostingContext.Configuration.GetSection("Vault"));
                services.AddKeyVault(hostingContext.Configuration);

                var appInsightsSettings = new AppInsightsSettings();
                hostingContext.Configuration.Bind("AppInsights:Context", appInsightsSettings);
                var instrumentationKey = services.GetSecret(hostingContext.Configuration, hostingContext.Configuration["AppInsights:InstrumentationKeySecret"]);
                services.AddAppInsights(appInsightsSettings, instrumentationKey);
                services.AddLogging(instrumentationKey);

                services.AddHostedService <MetricsBenchmark>();
            });

            await builder.RunConsoleAsync();
        }