Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="services"></param>
        public void ConfigureServices(IServiceCollection services)
        {
            // Configuration
            services.AddOptions();
            services.Configure <ApplicationOptions>(Configuration);
            services.AddSingleton(Configuration);

            var config = ConfigurationHelper.Configuration.Get <ApplicationOptions>();

            // Swagger
            services.AddCustomSwagger(Configuration);

            // AppMetrics
            services.AddMetrics();
            services.AddMetricsTrackingMiddleware();

            //Zipkin
            services.AddHttpClient("Tracer").AddHttpMessageHandler(provider =>
                                                                   TracingHandler.WithoutInnerHandler(provider.GetService <IConfiguration>()["applicationName"]));

            // Health Checks
            services.AddHealthChecks();

            //Services
            services.AddScoped <ITokenProvider>(_ => new TokenProvider(config.OpenIdConnectConfiguration));
            services.AddScoped <IFlickrSearchService>(_ => new FlickrSearchService(config.FlickrConfiguration.ApiKey, config.FlickrConfiguration.Secret));
            services.AddScoped <IFlickrDownloadService, FlickrDownloadService>();

            services.AddCustomHttpServices(Configuration);

            services.AddMvc();
        }
Ejemplo n.º 2
0
 // This method gets called by the runtime. Use this method to add services to the container.
 public void ConfigureServices(IServiceCollection services)
 {
     services.AddControllers();
     services.AddHttpClient(ServiceName.ProductService, client =>
     {
         client.BaseAddress = new Uri($"http://localhost:5002");
     })
     //.AddHttpMessageHandler<NacosDiscoveryDelegatingHandler>()
     .AddHttpMessageHandler(provider => TracingHandler.WithoutInnerHandler(ServiceName.OrderService));
 }
Ejemplo n.º 3
0
 // This method gets called by the runtime. Use this method to add services to the container.
 public void ConfigureServices(IServiceCollection services)
 {
     services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
     services.AddHttpClient <IExpenseClient, ExpenseClient>(client =>
     {
         client.BaseAddress = new Uri(Configuration.GetConnectionString("Expenses"));
     }).AddHttpMessageHandler(provider => TracingHandler.WithoutInnerHandler("report"));
     services.AddTransient <IToggleClient>(s => new ToggleClient(Configuration.GetConnectionString("Consul"), new ConsulClient(), Configuration.GetConnectionString("ConsulTemplateFile")));
     services.AddLogging(opt =>
     {
         opt.AddConsole();
     });
 }
Ejemplo n.º 4
0
        /// <summary>
        /// 注册分布式追踪埋点配置 zipkin
        /// </summary>
        /// <param name="services"></param>
        /// <param name="configuration"></param>
        /// <returns></returns>
        public static IServiceCollection AddZipkin(this IServiceCollection services, IConfiguration configuration)
        {
            services.AddOptions();
            services.Configure <ZipkinOptions>(configuration);

            //var zipkinOptions = new ZipkinOptions();
            var zipkinOptions = services.BuildServiceProvider().GetRequiredService <IOptions <ZipkinOptions> >().Value;

            services.AddHttpClient(zipkinOptions.HttpClientServiceName)
            .AddHttpMessageHandler(sp => TracingHandler.WithoutInnerHandler(zipkinOptions.ApplicationName));

            services.AddResilienceHttpClient(zipkinOptions.HttpClientServiceName);

            return(services);
        }
Ejemplo n.º 5
0
 public override void ConfigureServices(IServiceCollection services)
 {
     services.AddHttpClient("Tracer").AddHttpMessageHandler(provider =>
                                                            TracingHandler.WithoutInnerHandler(provider.GetService <IConfiguration>()["applicationName"]));
 }
Ejemplo n.º 6
0
 // This method gets called by the runtime. Use this method to add services to the container.
 public void ConfigureServices(IServiceCollection services)
 {
     services.AddHttpClient("Tracer").AddHttpMessageHandler(provider => TracingHandler.WithoutInnerHandler(provider.GetService <IConfiguration>()["AppName"]));
     services.AddControllersWithViews();
 }
Ejemplo n.º 7
0
 public void ConfigureServices(IServiceCollection services)
 {
     services.AddHttpClient("Tracer").AddHttpMessageHandler(provider => TracingHandler.WithoutInnerHandler("Client-App"));
 }