Added Appinsights K8s telemetry initializer

This commit is contained in:
Ramón Tomás 2017-10-11 18:53:26 +02:00
parent a04cef97ef
commit c3e15969b9
26 changed files with 182 additions and 16 deletions

1
.env
View File

@ -24,3 +24,4 @@ ESHOP_PROD_EXTERNAL_DNS_NAME_OR_IP=10.121.122.92
#ESHOP_SERVICE_BUS_USERNAME=<ServiceBusUserName-OnlyUsedIfUsingRabbitMQUnderwindows> #ESHOP_SERVICE_BUS_USERNAME=<ServiceBusUserName-OnlyUsedIfUsingRabbitMQUnderwindows>
#ESHOP_SERVICE_BUS_PASSWORD=<ServiceBusUserPassword-OnlyUsedIfUsingRabbitMQUnderwindows> #ESHOP_SERVICE_BUS_PASSWORD=<ServiceBusUserPassword-OnlyUsedIfUsingRabbitMQUnderwindows>
#INSTRUMENTATION_KEY= #INSTRUMENTATION_KEY=
#ORCHESTRATOR_TYPE=<k8S/SF>

View File

@ -20,6 +20,7 @@ services:
- EventBusPassword=${ESHOP_SERVICE_BUS_PASSWORD} - EventBusPassword=${ESHOP_SERVICE_BUS_PASSWORD}
- AzureServiceBusEnabled=False - AzureServiceBusEnabled=False
- ApplicationInsights__InstrumentationKey=${INSTRUMENTATION_KEY} - ApplicationInsights__InstrumentationKey=${INSTRUMENTATION_KEY}
- OrchestratorType=${ORCHESTRATOR_TYPE}
ports: ports:
- "5103:80" - "5103:80"
@ -38,6 +39,7 @@ services:
- AzureServiceBusEnabled=False - AzureServiceBusEnabled=False
- AzureStorageEnabled=False - AzureStorageEnabled=False
- ApplicationInsights__InstrumentationKey=${INSTRUMENTATION_KEY} - ApplicationInsights__InstrumentationKey=${INSTRUMENTATION_KEY}
- OrchestratorType=${ORCHESTRATOR_TYPE}
ports: ports:
- "5101:80" - "5101:80"
@ -55,6 +57,7 @@ services:
- OrderingApiClient=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5102 - OrderingApiClient=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5102
- UseCustomizationData=True - UseCustomizationData=True
- ApplicationInsights__InstrumentationKey=${INSTRUMENTATION_KEY} - ApplicationInsights__InstrumentationKey=${INSTRUMENTATION_KEY}
- OrchestratorType=${ORCHESTRATOR_TYPE}
ports: ports:
- "5105:80" - "5105:80"
@ -73,6 +76,7 @@ services:
- CheckUpdateTime=30000 - CheckUpdateTime=30000
- GracePeriodTime=1 - GracePeriodTime=1
- ApplicationInsights__InstrumentationKey=${INSTRUMENTATION_KEY} - ApplicationInsights__InstrumentationKey=${INSTRUMENTATION_KEY}
- OrchestratorType=${ORCHESTRATOR_TYPE}
ports: ports:
- "5102:80" - "5102:80"
@ -95,6 +99,7 @@ services:
- AzureServiceBusEnabled=False - AzureServiceBusEnabled=False
- AzureStorageEnabled=False - AzureStorageEnabled=False
- ApplicationInsights__InstrumentationKey=${INSTRUMENTATION_KEY} - ApplicationInsights__InstrumentationKey=${INSTRUMENTATION_KEY}
- OrchestratorType=${ORCHESTRATOR_TYPE}
ports: ports:
- "5110:80" - "5110:80"
@ -116,6 +121,7 @@ services:
- PaymentUrlHC=http://payment.api/hc - PaymentUrlHC=http://payment.api/hc
- UseCustomizationData=True - UseCustomizationData=True
- ApplicationInsights__InstrumentationKey=${INSTRUMENTATION_KEY} - ApplicationInsights__InstrumentationKey=${INSTRUMENTATION_KEY}
- OrchestratorType=${ORCHESTRATOR_TYPE}
ports: ports:
- "5104:80" - "5104:80"
@ -137,6 +143,7 @@ services:
- PaymentUrlHC=http://payment.api/hc - PaymentUrlHC=http://payment.api/hc
- UseCustomizationData=True - UseCustomizationData=True
- ApplicationInsights__InstrumentationKey=${INSTRUMENTATION_KEY} - ApplicationInsights__InstrumentationKey=${INSTRUMENTATION_KEY}
- OrchestratorType=${ORCHESTRATOR_TYPE}
ports: ports:
- "5100:80" - "5100:80"
@ -154,6 +161,7 @@ services:
- mvc=http://webmvc/hc - mvc=http://webmvc/hc
- spa=http://webspa/hc - spa=http://webspa/hc
- ApplicationInsights__InstrumentationKey=${INSTRUMENTATION_KEY} - ApplicationInsights__InstrumentationKey=${INSTRUMENTATION_KEY}
- OrchestratorType=${ORCHESTRATOR_TYPE}
ports: ports:
- "5107:80" - "5107:80"
@ -182,6 +190,7 @@ services:
- EventBusPassword=${ESHOP_SERVICE_BUS_PASSWORD} - EventBusPassword=${ESHOP_SERVICE_BUS_PASSWORD}
- AzureServiceBusEnabled=False - AzureServiceBusEnabled=False
- ApplicationInsights__InstrumentationKey=${INSTRUMENTATION_KEY} - ApplicationInsights__InstrumentationKey=${INSTRUMENTATION_KEY}
- OrchestratorType=${ORCHESTRATOR_TYPE}
ports: ports:
- "5109:80" - "5109:80"

View File

@ -25,5 +25,7 @@ data:
keystore: keystore-data keystore: keystore-data
GracePeriodManager_GracePeriodTime: "1" GracePeriodManager_GracePeriodTime: "1"
GracePeriodManager_CheckUpdateTime: "15000" GracePeriodManager_CheckUpdateTime: "15000"
Instrumentation_Key: ""

View File

@ -32,11 +32,18 @@ spec:
configMapKeyRef: configMapKeyRef:
name: externalcfg name: externalcfg
key: UseAzureServiceBus key: UseAzureServiceBus
- name: ApplicationInsights__InstrumentationKey
valueFrom:
configMapKeyRef:
name: externalcfg
key: Instrumentation_Key
- name: IdentityUrl - name: IdentityUrl
valueFrom: valueFrom:
configMapKeyRef: configMapKeyRef:
name: urls name: urls
key: IdentityUrl key: IdentityUrl
- name: OrchestratorType
value: 'K8S'
ports: ports:
- containerPort: 80 - containerPort: 80
readinessProbe: readinessProbe:
@ -95,6 +102,13 @@ spec:
configMapKeyRef: configMapKeyRef:
name: externalcfg name: externalcfg
key: CatalogBus key: CatalogBus
- name: ApplicationInsights__InstrumentationKey
valueFrom:
configMapKeyRef:
name: externalcfg
key: Instrumentation_Key
- name: OrchestratorType
value: 'K8S'
ports: ports:
- containerPort: 80 - containerPort: 80
readinessProbe: readinessProbe:
@ -133,7 +147,7 @@ spec:
env: env:
- name: PATH_BASE - name: PATH_BASE
value: /identity value: /identity
- name: ConnectionStrings__DefaultConnection - name: ConnectionString
valueFrom: valueFrom:
configMapKeyRef: configMapKeyRef:
name: externalcfg name: externalcfg
@ -175,6 +189,13 @@ spec:
configMapKeyRef: configMapKeyRef:
name: urls name: urls
key: OrderingApiClient key: OrderingApiClient
- name: ApplicationInsights__InstrumentationKey
valueFrom:
configMapKeyRef:
name: externalcfg
key: Instrumentation_Key
- name: OrchestratorType
value: 'K8S'
ports: ports:
- containerPort: 80 - containerPort: 80
readinessProbe: readinessProbe:
@ -243,6 +264,13 @@ spec:
configMapKeyRef: configMapKeyRef:
name: externalcfg name: externalcfg
key: GracePeriodManager_GracePeriodTime key: GracePeriodManager_GracePeriodTime
- name: ApplicationInsights__InstrumentationKey
valueFrom:
configMapKeyRef:
name: externalcfg
key: Instrumentation_Key
- name: OrchestratorType
value: 'K8S'
ports: ports:
- containerPort: 80 - containerPort: 80
readinessProbe: readinessProbe:
@ -311,6 +339,13 @@ spec:
configMapKeyRef: configMapKeyRef:
name: urls name: urls
key: IdentityUrl key: IdentityUrl
- name: ApplicationInsights__InstrumentationKey
valueFrom:
configMapKeyRef:
name: externalcfg
key: Instrumentation_Key
- name: OrchestratorType
value: 'K8S'
ports: ports:
- containerPort: 80 - containerPort: 80
readinessProbe: readinessProbe:
@ -389,6 +424,13 @@ spec:
configMapKeyRef: configMapKeyRef:
name: urls name: urls
key: Marketing_PicBaseUrl key: Marketing_PicBaseUrl
- name: ApplicationInsights__InstrumentationKey
valueFrom:
configMapKeyRef:
name: externalcfg
key: Instrumentation_Key
- name: OrchestratorType
value: 'K8S'
ports: ports:
- containerPort: 80 - containerPort: 80
readinessProbe: readinessProbe:
@ -437,6 +479,13 @@ spec:
configMapKeyRef: configMapKeyRef:
name: externalcfg name: externalcfg
key: PaymentBus key: PaymentBus
- name: ApplicationInsights__InstrumentationKey
valueFrom:
configMapKeyRef:
name: externalcfg
key: Instrumentation_Key
- name: OrchestratorType
value: 'K8S'
ports: ports:
- containerPort: 80 - containerPort: 80
readinessProbe: readinessProbe:
@ -547,6 +596,13 @@ spec:
configMapKeyRef: configMapKeyRef:
name: urls name: urls
key: PaymentHealthCheckUrl key: PaymentHealthCheckUrl
- name: ApplicationInsights__InstrumentationKey
valueFrom:
configMapKeyRef:
name: externalcfg
key: Instrumentation_Key
- name: OrchestratorType
value: 'K8S'
ports: ports:
- containerPort: 80 - containerPort: 80
readinessProbe: readinessProbe:
@ -630,6 +686,13 @@ spec:
configMapKeyRef: configMapKeyRef:
name: urls name: urls
key: PaymentHealthCheckUrl key: PaymentHealthCheckUrl
- name: ApplicationInsights__InstrumentationKey
valueFrom:
configMapKeyRef:
name: externalcfg
key: Instrumentation_Key
- name: OrchestratorType
value: 'K8S'
ports: ports:
- containerPort: 80 - containerPort: 80
imagePullSecrets: imagePullSecrets:
@ -726,6 +789,13 @@ spec:
configMapKeyRef: configMapKeyRef:
name: urls name: urls
key: PaymentHealthCheckUrl key: PaymentHealthCheckUrl
- name: ApplicationInsights__InstrumentationKey
valueFrom:
configMapKeyRef:
name: externalcfg
key: Instrumentation_Key
- name: OrchestratorType
value: 'K8S'
ports: ports:
- containerPort: 80 - containerPort: 80
readinessProbe: readinessProbe:

View File

@ -17,6 +17,8 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.1.1" /> <PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.1.1" />
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.4.1" />
<PackageReference Include="Microsoft.ApplicationInsights.Kubernetes" Version="1.0.0-beta1" />
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" /> <PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="4.1.0" /> <PackageReference Include="Autofac.Extensions.DependencyInjection" Version="4.1.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="1.0.0" /> <PackageReference Include="Swashbuckle.AspNetCore" Version="1.0.0" />

View File

@ -34,6 +34,7 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API
builder.AddConsole(); builder.AddConsole();
builder.AddDebug(); builder.AddDebug();
}) })
.UseApplicationInsights()
.Build(); .Build();
} }
} }

View File

@ -65,6 +65,12 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API
services.Configure<BasketSettings>(Configuration); services.Configure<BasketSettings>(Configuration);
if(Configuration.GetValue<string>("OrchestratorType").Equals("K8S"))
{
// Enable K8s telemetry initializer
services.EnableKubernetes();
}
//By connecting here we are making sure that our service //By connecting here we are making sure that our service
//cannot start until redis is ready. This might slow down startup, //cannot start until redis is ready. This might slow down startup,
//but given that there is a delay on resolving the ip address //but given that there is a delay on resolving the ip address

View File

@ -36,6 +36,8 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="4.1.0" /> <PackageReference Include="Autofac.Extensions.DependencyInjection" Version="4.1.0" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.1.1" /> <PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.1.1" />
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.4.1" />
<PackageReference Include="Microsoft.ApplicationInsights.Kubernetes" Version="1.0.0-beta1" />
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" /> <PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="1.0.0" /> <PackageReference Include="Swashbuckle.AspNetCore" Version="1.0.0" />
<PackageReference Include="System.IO.Compression.ZipFile" Version="4.3.0" /> <PackageReference Include="System.IO.Compression.ZipFile" Version="4.3.0" />

View File

@ -32,6 +32,7 @@ namespace Microsoft.eShopOnContainers.Services.Catalog.API
public static IWebHost BuildWebHost(string[] args) => public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args) WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>() .UseStartup<Startup>()
.UseApplicationInsights()
.UseHealthChecks("/hc") .UseHealthChecks("/hc")
.UseContentRoot(Directory.GetCurrentDirectory()) .UseContentRoot(Directory.GetCurrentDirectory())
.UseWebRoot("Pics") .UseWebRoot("Pics")
@ -45,7 +46,6 @@ namespace Microsoft.eShopOnContainers.Services.Catalog.API
builder.AddConsole(); builder.AddConsole();
builder.AddDebug(); builder.AddDebug();
}) })
.UseApplicationInsights()
.Build(); .Build();
} }
} }

View File

@ -13,7 +13,6 @@
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions; using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
using Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ; using Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ;
using Microsoft.eShopOnContainers.BuildingBlocks.EventBusServiceBus; using Microsoft.eShopOnContainers.BuildingBlocks.EventBusServiceBus;
using Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF;
using Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF.Services; using Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF.Services;
using Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure; using Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure;
using Microsoft.eShopOnContainers.Services.Catalog.API.IntegrationEvents.EventHandling; using Microsoft.eShopOnContainers.Services.Catalog.API.IntegrationEvents.EventHandling;
@ -43,6 +42,12 @@
services.AddApplicationInsightsTelemetry(Configuration); services.AddApplicationInsightsTelemetry(Configuration);
if (Configuration.GetValue<string>("OrchestratorType").Equals("K8S"))
{
// Enable K8s telemetry initializer
services.EnableKubernetes();
}
services.AddHealthChecks(checks => services.AddHealthChecks(checks =>
{ {
var minutes = 1; var minutes = 1;

View File

@ -17,6 +17,8 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="4.1.0" /> <PackageReference Include="Autofac.Extensions.DependencyInjection" Version="4.1.0" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.1.1" /> <PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.1.1" />
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.4.1" />
<PackageReference Include="Microsoft.ApplicationInsights.Kubernetes" Version="1.0.0-beta1" />
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" /> <PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
<PackageReference Include="IdentityServer4.AspNetIdentity" Version="2.0.0-rc1" /> <PackageReference Include="IdentityServer4.AspNetIdentity" Version="2.0.0-rc1" />
<PackageReference Include="IdentityServer4.EntityFramework" Version="2.0.0-rc1" /> <PackageReference Include="IdentityServer4.EntityFramework" Version="2.0.0-rc1" />

View File

@ -33,6 +33,12 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API
{ {
services.AddApplicationInsightsTelemetry(Configuration); services.AddApplicationInsightsTelemetry(Configuration);
if (Configuration.GetValue<string>("OrchestratorType").Equals("K8S"))
{
// Enable K8s telemetry initializer
services.EnableKubernetes();
}
// Add framework services. // Add framework services.
services.AddDbContext<ApplicationDbContext>(options => services.AddDbContext<ApplicationDbContext>(options =>
options.UseSqlServer(Configuration["ConnectionString"], options.UseSqlServer(Configuration["ConnectionString"],

View File

@ -12,6 +12,8 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="4.1.0" /> <PackageReference Include="Autofac.Extensions.DependencyInjection" Version="4.1.0" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.1.1" /> <PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.1.1" />
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.4.1" />
<PackageReference Include="Microsoft.ApplicationInsights.Kubernetes" Version="1.0.0-beta1" />
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" /> <PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
<PackageReference Include="mongocsharpdriver" Version="2.4.4" /> <PackageReference Include="mongocsharpdriver" Version="2.4.4" />
<PackageReference Include="MongoDB.Bson" Version="2.4.4" /> <PackageReference Include="MongoDB.Bson" Version="2.4.4" />

View File

@ -39,6 +39,12 @@ namespace Microsoft.eShopOnContainers.Services.Locations.API
{ {
services.AddApplicationInsightsTelemetry(Configuration); services.AddApplicationInsightsTelemetry(Configuration);
if (Configuration.GetValue<string>("OrchestratorType").Equals("K8S"))
{
// Enable K8s telemetry initializer
services.EnableKubernetes();
}
services.AddMvc(options => services.AddMvc(options =>
{ {
options.Filters.Add(typeof(HttpGlobalExceptionFilter)); options.Filters.Add(typeof(HttpGlobalExceptionFilter));

View File

@ -22,6 +22,8 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="4.1.0" /> <PackageReference Include="Autofac.Extensions.DependencyInjection" Version="4.1.0" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.1.1" /> <PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.1.1" />
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.4.1" />
<PackageReference Include="Microsoft.ApplicationInsights.Kubernetes" Version="1.0.0-beta1" />
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" /> <PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
<PackageReference Include="mongocsharpdriver" Version="2.4.4" /> <PackageReference Include="mongocsharpdriver" Version="2.4.4" />
<PackageReference Include="MongoDB.Bson" Version="2.4.4" /> <PackageReference Include="MongoDB.Bson" Version="2.4.4" />

View File

@ -46,6 +46,12 @@
{ {
services.AddApplicationInsightsTelemetry(Configuration); services.AddApplicationInsightsTelemetry(Configuration);
if (Configuration.GetValue<string>("OrchestratorType").Equals("K8S"))
{
// Enable K8s telemetry initializer
services.EnableKubernetes();
}
// Add framework services. // Add framework services.
services.AddMvc(options => services.AddMvc(options =>
{ {
@ -200,7 +206,7 @@
ConfigureEventBus(app); ConfigureEventBus(app);
} }
private void ConfigureAuthService(IServiceCollection services) private void ConfigureAuthService(IServiceCollection services, ILoggerFactory loggerFactory)
{ {
// prevent from mapping "sub" claim to nameidentifier. // prevent from mapping "sub" claim to nameidentifier.
JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear(); JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear();

View File

@ -38,6 +38,8 @@
<PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="3.0.0" /> <PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="3.0.0" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="4.1.0" /> <PackageReference Include="Autofac.Extensions.DependencyInjection" Version="4.1.0" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.1.1" /> <PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.1.1" />
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.4.1" />
<PackageReference Include="Microsoft.ApplicationInsights.Kubernetes" Version="1.0.0-beta1" />
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" /> <PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
<PackageReference Include="MediatR" Version="3.0.1" /> <PackageReference Include="MediatR" Version="3.0.1" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="1.0.0" /> <PackageReference Include="Swashbuckle.AspNetCore" Version="1.0.0" />

View File

@ -48,6 +48,12 @@
{ {
services.AddApplicationInsightsTelemetry(Configuration); services.AddApplicationInsightsTelemetry(Configuration);
if (Configuration.GetValue<string>("OrchestratorType").Equals("K8S"))
{
// Enable K8s telemetry initializer
services.EnableKubernetes();
}
// Add framework services. // Add framework services.
services.AddMvc(options => services.AddMvc(options =>
{ {

View File

@ -9,6 +9,8 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="4.1.0" /> <PackageReference Include="Autofac.Extensions.DependencyInjection" Version="4.1.0" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.1.1" /> <PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.1.1" />
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.4.1" />
<PackageReference Include="Microsoft.ApplicationInsights.Kubernetes" Version="1.0.0-beta1" />
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" /> <PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="1.0.0" /> <PackageReference Include="Swashbuckle.AspNetCore" Version="1.0.0" />
</ItemGroup> </ItemGroup>

View File

@ -32,9 +32,16 @@ namespace Payment.API
// This method gets called by the runtime. Use this method to add services to the container. // This method gets called by the runtime. Use this method to add services to the container.
public IServiceProvider ConfigureServices(IServiceCollection services) public IServiceProvider ConfigureServices(IServiceCollection services)
{ {
services.AddApplicationInsightsTelemetry(Configuration);
services.Configure<PaymentSettings>(Configuration); services.Configure<PaymentSettings>(Configuration);
if (Configuration.GetValue<string>("OrchestratorType").Equals("K8S"))
{
// Enable K8s telemetry initializer
services.EnableKubernetes();
}
if (Configuration.GetValue<bool>("AzureServiceBusEnabled")) if (Configuration.GetValue<bool>("AzureServiceBusEnabled"))
{ {
services.AddSingleton<IServiceBusPersisterConnection>(sp => services.AddSingleton<IServiceBusPersisterConnection>(sp =>
@ -84,8 +91,11 @@ namespace Payment.API
} }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env) public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{ {
loggerFactory.AddAzureWebAppDiagnostics();
loggerFactory.AddApplicationInsights(app.ApplicationServices, LogLevel.Trace);
var pathBase = Configuration["PATH_BASE"]; var pathBase = Configuration["PATH_BASE"];
if (!string.IsNullOrEmpty(pathBase)) if (!string.IsNullOrEmpty(pathBase))
{ {

View File

@ -33,6 +33,12 @@ namespace Microsoft.eShopOnContainers.WebMVC
{ {
services.AddApplicationInsightsTelemetry(Configuration); services.AddApplicationInsightsTelemetry(Configuration);
if (Configuration.GetValue<string>("OrchestratorType").Equals("K8S"))
{
// Enable K8s telemetry initializer
services.EnableKubernetes();
}
services.AddMvc(); services.AddMvc();
services.AddSession(); services.AddSession();

View File

@ -37,6 +37,8 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.1.1" /> <PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.1.1" />
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.4.1" />
<PackageReference Include="Microsoft.ApplicationInsights.Kubernetes" Version="1.0.0-beta1" />
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" /> <PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Fabric.MSBuild" Version="1.6.1" /> <PackageReference Include="Microsoft.VisualStudio.Azure.Fabric.MSBuild" Version="1.6.1" />
</ItemGroup> </ItemGroup>

View File

@ -38,6 +38,12 @@ namespace eShopConContainers.WebSPA
{ {
services.AddApplicationInsightsTelemetry(Configuration); services.AddApplicationInsightsTelemetry(Configuration);
if (Configuration.GetValue<string>("OrchestratorType").Equals("K8S"))
{
// Enable K8s telemetry initializer
services.EnableKubernetes();
}
services.AddHealthChecks(checks => services.AddHealthChecks(checks =>
{ {
var minutes = 1; var minutes = 1;

View File

@ -28,6 +28,8 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.1.1" /> <PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.1.1" />
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.4.1" />
<PackageReference Include="Microsoft.ApplicationInsights.Kubernetes" Version="1.0.0-beta1" />
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" /> <PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" /> <PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
</ItemGroup> </ItemGroup>

View File

@ -25,6 +25,12 @@ namespace WebStatus
{ {
services.AddApplicationInsightsTelemetry(Configuration); services.AddApplicationInsightsTelemetry(Configuration);
if (Configuration.GetValue<string>("OrchestratorType").Equals("K8S"))
{
// Enable K8s telemetry initializer
services.EnableKubernetes();
}
services.AddOptions(); services.AddOptions();
// Add framework services. // Add framework services.

View File

@ -6,6 +6,8 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.1.1" /> <PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.1.1" />
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.4.1" />
<PackageReference Include="Microsoft.ApplicationInsights.Kubernetes" Version="1.0.0-beta1" />
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" /> <PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>