add otel support
This commit is contained in:
parent
1807e952cf
commit
1fdfa6f128
23
deploy/otel/otel-collector-config.yaml
Normal file
23
deploy/otel/otel-collector-config.yaml
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
|
||||||
|
# Data sources: traces, metrics, logs
|
||||||
|
receivers:
|
||||||
|
otlp:
|
||||||
|
protocols:
|
||||||
|
grpc:
|
||||||
|
http:
|
||||||
|
|
||||||
|
processors:
|
||||||
|
batch:
|
||||||
|
|
||||||
|
service:
|
||||||
|
pipelines:
|
||||||
|
traces:
|
||||||
|
receivers: [otlp]
|
||||||
|
processors: [batch]
|
||||||
|
exporters: [zipkin]
|
||||||
|
|
||||||
|
exporters:
|
||||||
|
zipkin:
|
||||||
|
endpoint: "http://zipkin:9411/api/v2/spans"
|
||||||
|
|
||||||
|
|
@ -13,7 +13,12 @@
|
|||||||
</Content>
|
</Content>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="OpenTelemetry" Version="1.2.0" />
|
||||||
|
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.2.0" />
|
||||||
|
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.0.0-rc9" />
|
||||||
|
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.0.0-rc9" />
|
||||||
|
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.0.0-rc9" />
|
||||||
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.12.2" />
|
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.12.2" />
|
||||||
<PackageReference Include="Azure.Identity" Version="1.5.0-beta.3" />
|
<PackageReference Include="Azure.Identity" Version="1.5.0-beta.3" />
|
||||||
<PackageReference Include="AspNetCore.HealthChecks.AzureServiceBus" Version="5.1.1" />
|
<PackageReference Include="AspNetCore.HealthChecks.AzureServiceBus" Version="5.1.1" />
|
||||||
@ -23,7 +28,7 @@
|
|||||||
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.2.0-preview.1" />
|
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.2.0-preview.1" />
|
||||||
<PackageReference Include="Azure.Extensions.AspNetCore.Configuration.Secrets" Version="1.2.1" />
|
<PackageReference Include="Azure.Extensions.AspNetCore.Configuration.Secrets" Version="1.2.1" />
|
||||||
<PackageReference Include="Azure.Identity" Version="1.4.0" />
|
<PackageReference Include="Azure.Identity" Version="1.4.0" />
|
||||||
<PackageReference Include="Google.Protobuf" Version="3.15.0" />
|
<PackageReference Include="Google.Protobuf" Version="3.21.5" />
|
||||||
<PackageReference Include="Grpc.AspNetCore.Server" Version="2.34.0" />
|
<PackageReference Include="Grpc.AspNetCore.Server" Version="2.34.0" />
|
||||||
<PackageReference Include="Grpc.Tools" Version="2.34.0" PrivateAssets="All" />
|
<PackageReference Include="Grpc.Tools" Version="2.34.0" PrivateAssets="All" />
|
||||||
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.18.0" />
|
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.18.0" />
|
||||||
|
@ -1,4 +1,8 @@
|
|||||||
namespace Microsoft.eShopOnContainers.Services.Basket.API;
|
namespace Microsoft.eShopOnContainers.Services.Basket.API;
|
||||||
|
|
||||||
|
using OpenTelemetry.Trace;
|
||||||
|
using OpenTelemetry.Resources;
|
||||||
|
|
||||||
public class Startup
|
public class Startup
|
||||||
{
|
{
|
||||||
public Startup(IConfiguration configuration)
|
public Startup(IConfiguration configuration)
|
||||||
@ -11,6 +15,19 @@ public class Startup
|
|||||||
// 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 virtual IServiceProvider ConfigureServices(IServiceCollection services)
|
public virtual IServiceProvider ConfigureServices(IServiceCollection services)
|
||||||
{
|
{
|
||||||
|
services.AddOpenTelemetryTracing( builder => builder
|
||||||
|
.SetResourceBuilder(
|
||||||
|
ResourceBuilder.CreateDefault()
|
||||||
|
.AddService(Configuration.GetValue<string>("Otlp:ServiceName"))
|
||||||
|
)
|
||||||
|
.AddHttpClientInstrumentation()
|
||||||
|
.AddAspNetCoreInstrumentation()
|
||||||
|
.AddOtlpExporter( otlpOptions => {
|
||||||
|
var url = Configuration.GetValue<string>("Otlp:Endpoint");
|
||||||
|
otlpOptions.Endpoint = new Uri( url );
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
services.AddGrpc(options =>
|
services.AddGrpc(options =>
|
||||||
{
|
{
|
||||||
options.EnableDetailedErrors = true;
|
options.EnableDetailedErrors = true;
|
||||||
|
@ -26,5 +26,9 @@
|
|||||||
"Name": "eshop",
|
"Name": "eshop",
|
||||||
"ClientId": "your-client-id",
|
"ClientId": "your-client-id",
|
||||||
"ClientSecret": "your-client-secret"
|
"ClientSecret": "your-client-secret"
|
||||||
|
},
|
||||||
|
"Otlp": {
|
||||||
|
"ServiceName": "Basket API",
|
||||||
|
"Endpoint": "http://otel-collector:4317"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,6 +41,11 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="OpenTelemetry" Version="1.2.0" />
|
||||||
|
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.2.0" />
|
||||||
|
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.0.0-rc9" />
|
||||||
|
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.0.0-rc9" />
|
||||||
|
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.0.0-rc9" />
|
||||||
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.12.2" />
|
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.12.2" />
|
||||||
<PackageReference Include="Azure.Identity" Version="1.5.0-beta.3" />
|
<PackageReference Include="Azure.Identity" Version="1.5.0-beta.3" />
|
||||||
<PackageReference Include="AspNetCore.HealthChecks.AzureServiceBus" Version="5.1.1" />
|
<PackageReference Include="AspNetCore.HealthChecks.AzureServiceBus" Version="5.1.1" />
|
||||||
@ -49,7 +54,7 @@
|
|||||||
<PackageReference Include="AspNetCore.HealthChecks.SqlServer" Version="5.0.3" />
|
<PackageReference Include="AspNetCore.HealthChecks.SqlServer" Version="5.0.3" />
|
||||||
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="5.0.1" />
|
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="5.0.1" />
|
||||||
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.2.0-preview.1" />
|
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.2.0-preview.1" />
|
||||||
<PackageReference Include="Google.Protobuf" Version="3.15.0" />
|
<PackageReference Include="Google.Protobuf" Version="3.21.5" />
|
||||||
<PackageReference Include="Grpc.AspNetCore.Server" Version="2.34.0" />
|
<PackageReference Include="Grpc.AspNetCore.Server" Version="2.34.0" />
|
||||||
<PackageReference Include="Grpc.Tools" Version="2.34.0" PrivateAssets="All" />
|
<PackageReference Include="Grpc.Tools" Version="2.34.0" PrivateAssets="All" />
|
||||||
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.18.0" />
|
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.18.0" />
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
namespace Microsoft.eShopOnContainers.Services.Catalog.API;
|
namespace Microsoft.eShopOnContainers.Services.Catalog.API;
|
||||||
|
|
||||||
|
using OpenTelemetry.Trace;
|
||||||
|
using OpenTelemetry.Resources;
|
||||||
|
|
||||||
public class Startup
|
public class Startup
|
||||||
{
|
{
|
||||||
public Startup(IConfiguration configuration)
|
public Startup(IConfiguration configuration)
|
||||||
@ -11,6 +14,19 @@ public class Startup
|
|||||||
|
|
||||||
public IServiceProvider ConfigureServices(IServiceCollection services)
|
public IServiceProvider ConfigureServices(IServiceCollection services)
|
||||||
{
|
{
|
||||||
|
services.AddOpenTelemetryTracing( builder => builder
|
||||||
|
.SetResourceBuilder(
|
||||||
|
ResourceBuilder.CreateDefault()
|
||||||
|
.AddService(Configuration.GetValue<string>("Otlp:ServiceName"))
|
||||||
|
)
|
||||||
|
.AddHttpClientInstrumentation()
|
||||||
|
.AddAspNetCoreInstrumentation()
|
||||||
|
.AddOtlpExporter( otlpOptions => {
|
||||||
|
var url = Configuration.GetValue<string>("Otlp:Endpoint");
|
||||||
|
otlpOptions.Endpoint = new Uri( url );
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
services.AddAppInsight(Configuration)
|
services.AddAppInsight(Configuration)
|
||||||
.AddGrpc().Services
|
.AddGrpc().Services
|
||||||
.AddCustomMVC(Configuration)
|
.AddCustomMVC(Configuration)
|
||||||
|
@ -24,7 +24,10 @@
|
|||||||
"Name": "eshop",
|
"Name": "eshop",
|
||||||
"ClientId": "your-client-id",
|
"ClientId": "your-client-id",
|
||||||
"ClientSecret": "your-client-secret"
|
"ClientSecret": "your-client-secret"
|
||||||
|
},
|
||||||
|
"Otlp": {
|
||||||
|
"ServiceName": "Catelog API",
|
||||||
|
"Endpoint": "http://otel-collector:4317"
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,6 +36,11 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="OpenTelemetry" Version="1.2.0" />
|
||||||
|
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.2.0" />
|
||||||
|
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.0.0-rc9" />
|
||||||
|
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.0.0-rc9" />
|
||||||
|
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.0.0-rc9" />
|
||||||
<PackageReference Include="AspNetCore.HealthChecks.AzureServiceBus" Version="5.1.1" />
|
<PackageReference Include="AspNetCore.HealthChecks.AzureServiceBus" Version="5.1.1" />
|
||||||
<PackageReference Include="AspNetCore.HealthChecks.Rabbitmq" Version="5.0.1" />
|
<PackageReference Include="AspNetCore.HealthChecks.Rabbitmq" Version="5.0.1" />
|
||||||
<PackageReference Include="AspNetCore.HealthChecks.SqlServer" Version="5.0.3" />
|
<PackageReference Include="AspNetCore.HealthChecks.SqlServer" Version="5.0.3" />
|
||||||
@ -45,7 +50,7 @@
|
|||||||
<PackageReference Include="Azure.Identity" Version="1.4.0" />
|
<PackageReference Include="Azure.Identity" Version="1.4.0" />
|
||||||
<PackageReference Include="Dapper" Version="2.0.78" />
|
<PackageReference Include="Dapper" Version="2.0.78" />
|
||||||
<PackageReference Include="FluentValidation.AspNetCore" Version="9.3.0" />
|
<PackageReference Include="FluentValidation.AspNetCore" Version="9.3.0" />
|
||||||
<PackageReference Include="Google.Protobuf" Version="3.15.0" />
|
<PackageReference Include="Google.Protobuf" Version="3.21.5" />
|
||||||
<PackageReference Include="Grpc.AspNetCore.Server" Version="2.34.0" />
|
<PackageReference Include="Grpc.AspNetCore.Server" Version="2.34.0" />
|
||||||
<PackageReference Include="Grpc.Tools" Version="2.34.0" PrivateAssets="All" />
|
<PackageReference Include="Grpc.Tools" Version="2.34.0" PrivateAssets="All" />
|
||||||
<PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="10.0.1" />
|
<PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="10.0.1" />
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
namespace Microsoft.eShopOnContainers.Services.Ordering.API;
|
namespace Microsoft.eShopOnContainers.Services.Ordering.API;
|
||||||
|
|
||||||
|
using OpenTelemetry.Trace;
|
||||||
|
using OpenTelemetry.Resources;
|
||||||
|
|
||||||
public class Startup
|
public class Startup
|
||||||
{
|
{
|
||||||
public Startup(IConfiguration configuration)
|
public Startup(IConfiguration configuration)
|
||||||
@ -11,6 +14,19 @@ public class Startup
|
|||||||
|
|
||||||
public virtual IServiceProvider ConfigureServices(IServiceCollection services)
|
public virtual IServiceProvider ConfigureServices(IServiceCollection services)
|
||||||
{
|
{
|
||||||
|
services.AddOpenTelemetryTracing( builder => builder
|
||||||
|
.SetResourceBuilder(
|
||||||
|
ResourceBuilder.CreateDefault()
|
||||||
|
.AddService(Configuration.GetValue<string>("Otlp:ServiceName"))
|
||||||
|
)
|
||||||
|
.AddHttpClientInstrumentation()
|
||||||
|
.AddAspNetCoreInstrumentation()
|
||||||
|
.AddOtlpExporter( otlpOptions => {
|
||||||
|
var url = Configuration.GetValue<string>("Otlp:Endpoint");
|
||||||
|
otlpOptions.Endpoint = new Uri( url );
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
services
|
services
|
||||||
.AddGrpc(options =>
|
.AddGrpc(options =>
|
||||||
{
|
{
|
||||||
|
@ -28,5 +28,9 @@
|
|||||||
"Name": "eshop",
|
"Name": "eshop",
|
||||||
"ClientId": "your-client-id",
|
"ClientId": "your-client-id",
|
||||||
"ClientSecret": "your-client-secret"
|
"ClientSecret": "your-client-secret"
|
||||||
|
},
|
||||||
|
"Otlp": {
|
||||||
|
"ServiceName": "Ordering API",
|
||||||
|
"Endpoint": "http://otel-collector:4317"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
namespace Microsoft.eShopOnContainers.WebMVC;
|
namespace Microsoft.eShopOnContainers.WebMVC;
|
||||||
|
|
||||||
|
using OpenTelemetry.Trace;
|
||||||
|
using OpenTelemetry.Resources;
|
||||||
|
|
||||||
public class Startup
|
public class Startup
|
||||||
{
|
{
|
||||||
public Startup(IConfiguration configuration)
|
public Startup(IConfiguration configuration)
|
||||||
@ -12,6 +15,19 @@ public class Startup
|
|||||||
// This method gets called by the runtime. Use this method to add services to the IoC container.
|
// This method gets called by the runtime. Use this method to add services to the IoC container.
|
||||||
public void ConfigureServices(IServiceCollection services)
|
public void ConfigureServices(IServiceCollection services)
|
||||||
{
|
{
|
||||||
|
services.AddOpenTelemetryTracing( builder => builder
|
||||||
|
.SetResourceBuilder(
|
||||||
|
ResourceBuilder.CreateDefault()
|
||||||
|
.AddService(Configuration.GetValue<string>("Otlp:ServiceName"))
|
||||||
|
)
|
||||||
|
.AddHttpClientInstrumentation()
|
||||||
|
.AddAspNetCoreInstrumentation()
|
||||||
|
.AddOtlpExporter( otlpOptions => {
|
||||||
|
var url = Configuration.GetValue<string>("Otlp:Endpoint");
|
||||||
|
otlpOptions.Endpoint = new Uri( url );
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
services.AddControllersWithViews()
|
services.AddControllersWithViews()
|
||||||
.Services
|
.Services
|
||||||
.AddAppInsight(Configuration)
|
.AddAppInsight(Configuration)
|
||||||
|
@ -21,6 +21,12 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="OpenTelemetry" Version="1.2.0" />
|
||||||
|
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.2.0" />
|
||||||
|
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.0.0-rc9" />
|
||||||
|
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.0.0-rc9" />
|
||||||
|
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.0.0-rc9" />
|
||||||
|
|
||||||
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="5.0.1" />
|
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="5.0.1" />
|
||||||
<PackageReference Include="AspNetCore.HealthChecks.Uris" Version="5.0.1" />
|
<PackageReference Include="AspNetCore.HealthChecks.Uris" Version="5.0.1" />
|
||||||
<PackageReference Include="BuildBundlerMinifier" Version="3.2.449" />
|
<PackageReference Include="BuildBundlerMinifier" Version="3.2.449" />
|
||||||
|
@ -21,5 +21,9 @@
|
|||||||
},
|
},
|
||||||
"HttpClientRetryCount": 8,
|
"HttpClientRetryCount": 8,
|
||||||
"HttpClientExceptionsAllowedBeforeBreaking": 7,
|
"HttpClientExceptionsAllowedBeforeBreaking": 7,
|
||||||
"SessionCookieLifetimeMinutes": 60
|
"SessionCookieLifetimeMinutes": 60,
|
||||||
|
"Otlp": {
|
||||||
|
"ServiceName": "Catelog API",
|
||||||
|
"Endpoint": "http://otel-collector:4317"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
19
src/docker-compose.otel.yml
Normal file
19
src/docker-compose.otel.yml
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
version: '3.4'
|
||||||
|
|
||||||
|
services:
|
||||||
|
# Collector
|
||||||
|
otel-collector:
|
||||||
|
image: otel/opentelemetry-collector-contrib
|
||||||
|
command: ["--config=/etc/otel-collector-config.yaml"]
|
||||||
|
volumes:
|
||||||
|
- ../deploy/otel/otel-collector-config.yaml:/etc/otel-collector-config.yaml
|
||||||
|
ports:
|
||||||
|
- "4317:4317" # OTLP gRPC receiver
|
||||||
|
- "4318:4318" # OTLP http receiver
|
||||||
|
|
||||||
|
zipkin:
|
||||||
|
image: openzipkin/zipkin
|
||||||
|
ports:
|
||||||
|
- "9411:9411"
|
||||||
|
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user