diff --git a/Directory.Packages.props b/Directory.Packages.props index 1c75df395be..964f88fe2a1 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -112,7 +112,6 @@ - diff --git a/playground/AWS/AWS.ServiceDefaults/AWS.ServiceDefaults.csproj b/playground/AWS/AWS.ServiceDefaults/AWS.ServiceDefaults.csproj index 90f5af72dc5..011bbd7bd2d 100644 --- a/playground/AWS/AWS.ServiceDefaults/AWS.ServiceDefaults.csproj +++ b/playground/AWS/AWS.ServiceDefaults/AWS.ServiceDefaults.csproj @@ -11,7 +11,6 @@ - diff --git a/playground/AWS/AWS.ServiceDefaults/Extensions.cs b/playground/AWS/AWS.ServiceDefaults/Extensions.cs index ae56ebbbea8..65949135f65 100644 --- a/playground/AWS/AWS.ServiceDefaults/Extensions.cs +++ b/playground/AWS/AWS.ServiceDefaults/Extensions.cs @@ -31,6 +31,12 @@ public static IHostApplicationBuilder AddServiceDefaults(this IHostApplicationBu http.UseServiceDiscovery(); }); + // Uncomment the following to restrict the allowed schemes for service discovery. + // builder.Services.Configure(options => + // { + // options.AllowedSchemes = ["https"]; + // }); + return builder; } @@ -45,8 +51,9 @@ public static IHostApplicationBuilder ConfigureOpenTelemetry(this IHostApplicati builder.Services.AddOpenTelemetry() .WithMetrics(metrics => { - metrics.AddRuntimeInstrumentation() - .AddBuiltInMeters(); + metrics.AddAspNetCoreInstrumentation() + .AddHttpClientInstrumentation() + .AddRuntimeInstrumentation(); }) .WithTracing(tracing => { @@ -57,11 +64,11 @@ public static IHostApplicationBuilder ConfigureOpenTelemetry(this IHostApplicati } tracing.AddAspNetCoreInstrumentation() - .AddGrpcClientInstrumentation() - .AddHttpClientInstrumentation() - - // Add instrumentation for the AWS .NET SDK. - .AddAWSInstrumentation(); + // Uncomment the following line to enable gRPC instrumentation (requires the OpenTelemetry.Instrumentation.GrpcNetClient package) + //.AddGrpcClientInstrumentation() + .AddHttpClientInstrumentation() + // Add instrumentation for the AWS .NET SDK. + .AddAWSInstrumentation(); }); builder.AddOpenTelemetryExporters(); @@ -84,9 +91,12 @@ private static IHostApplicationBuilder AddOpenTelemetryExporters(this IHostAppli // builder.Services.AddOpenTelemetry() // .WithMetrics(metrics => metrics.AddPrometheusExporter()); - // Uncomment the following lines to enable the Azure Monitor exporter (requires the Azure.Monitor.OpenTelemetry.Exporter package) - // builder.Services.AddOpenTelemetry() - // .UseAzureMonitor(); + // Uncomment the following lines to enable the Azure Monitor exporter (requires the Azure.Monitor.OpenTelemetry.AspNetCore package) + //if (!string.IsNullOrEmpty(builder.Configuration["APPLICATIONINSIGHTS_CONNECTION_STRING"])) + //{ + // builder.Services.AddOpenTelemetry() + // .UseAzureMonitor(); + //} return builder; } @@ -116,10 +126,4 @@ public static WebApplication MapDefaultEndpoints(this WebApplication app) return app; } - - private static MeterProviderBuilder AddBuiltInMeters(this MeterProviderBuilder meterProviderBuilder) => - meterProviderBuilder.AddMeter( - "Microsoft.AspNetCore.Hosting", - "Microsoft.AspNetCore.Server.Kestrel", - "System.Net.Http"); } diff --git a/playground/Playground.ServiceDefaults/Extensions.cs b/playground/Playground.ServiceDefaults/Extensions.cs index 29f639b74c4..0a17073ea35 100644 --- a/playground/Playground.ServiceDefaults/Extensions.cs +++ b/playground/Playground.ServiceDefaults/Extensions.cs @@ -31,6 +31,12 @@ public static IHostApplicationBuilder AddServiceDefaults(this IHostApplicationBu http.UseServiceDiscovery(); }); + // Uncomment the following to restrict the allowed schemes for service discovery. + // builder.Services.Configure(options => + // { + // options.AllowedSchemes = ["https"]; + // }); + return builder; } @@ -46,9 +52,8 @@ public static IHostApplicationBuilder ConfigureOpenTelemetry(this IHostApplicati .WithMetrics(metrics => { metrics.AddAspNetCoreInstrumentation() - .AddHttpClientInstrumentation() - .AddProcessInstrumentation() - .AddRuntimeInstrumentation(); + .AddHttpClientInstrumentation() + .AddRuntimeInstrumentation(); }) .WithTracing(tracing => { @@ -59,8 +64,9 @@ public static IHostApplicationBuilder ConfigureOpenTelemetry(this IHostApplicati } tracing.AddAspNetCoreInstrumentation() - .AddGrpcClientInstrumentation() - .AddHttpClientInstrumentation(); + // Uncomment the following line to enable gRPC instrumentation (requires the OpenTelemetry.Instrumentation.GrpcNetClient package) + //.AddGrpcClientInstrumentation() + .AddHttpClientInstrumentation(); }); builder.AddOpenTelemetryExporters(); @@ -87,7 +93,7 @@ private static IHostApplicationBuilder AddOpenTelemetryExporters(this IHostAppli //if (!string.IsNullOrEmpty(builder.Configuration["APPLICATIONINSIGHTS_CONNECTION_STRING"])) //{ // builder.Services.AddOpenTelemetry() - // .UseAzureMonitor(); + // .UseAzureMonitor(); //} return builder; diff --git a/playground/Playground.ServiceDefaults/Playground.ServiceDefaults.csproj b/playground/Playground.ServiceDefaults/Playground.ServiceDefaults.csproj index f518cfc4346..d8f0bcf1d38 100644 --- a/playground/Playground.ServiceDefaults/Playground.ServiceDefaults.csproj +++ b/playground/Playground.ServiceDefaults/Playground.ServiceDefaults.csproj @@ -15,9 +15,7 @@ - - diff --git a/playground/TestShop/ServiceDefaults/Extensions.cs b/playground/TestShop/ServiceDefaults/Extensions.cs index fd1b5e226a8..806cdc988a2 100644 --- a/playground/TestShop/ServiceDefaults/Extensions.cs +++ b/playground/TestShop/ServiceDefaults/Extensions.cs @@ -28,6 +28,12 @@ public static IHostApplicationBuilder AddServiceDefaults(this IHostApplicationBu http.UseServiceDiscovery(); }); + // Uncomment the following to restrict the allowed schemes for service discovery. + // builder.Services.Configure(options => + // { + // options.AllowedSchemes = ["https"]; + // }); + return builder; } @@ -44,7 +50,6 @@ public static IHostApplicationBuilder ConfigureOpenTelemetry(this IHostApplicati { metrics.AddAspNetCoreInstrumentation() .AddHttpClientInstrumentation() - .AddProcessInstrumentation() .AddRuntimeInstrumentation(); }) .WithTracing(tracing => @@ -56,8 +61,8 @@ public static IHostApplicationBuilder ConfigureOpenTelemetry(this IHostApplicati } tracing.AddAspNetCoreInstrumentation() - .AddGrpcClientInstrumentation() - .AddHttpClientInstrumentation(); + .AddGrpcClientInstrumentation() + .AddHttpClientInstrumentation(); }); builder.AddOpenTelemetryExporters(); diff --git a/playground/TestShop/ServiceDefaults/ServiceDefaults.csproj b/playground/TestShop/ServiceDefaults/ServiceDefaults.csproj index a821462d1b2..80de516c7a6 100644 --- a/playground/TestShop/ServiceDefaults/ServiceDefaults.csproj +++ b/playground/TestShop/ServiceDefaults/ServiceDefaults.csproj @@ -13,7 +13,6 @@ - diff --git a/playground/orleans/OrleansServiceDefaults/Extensions.cs b/playground/orleans/OrleansServiceDefaults/Extensions.cs index aa85604fa87..7b654807f2a 100644 --- a/playground/orleans/OrleansServiceDefaults/Extensions.cs +++ b/playground/orleans/OrleansServiceDefaults/Extensions.cs @@ -28,6 +28,12 @@ public static IHostApplicationBuilder AddServiceDefaults(this IHostApplicationBu http.UseServiceDiscovery(); }); + // Uncomment the following to restrict the allowed schemes for service discovery. + // builder.Services.Configure(options => + // { + // options.AllowedSchemes = ["https"]; + // }); + return builder; } @@ -44,7 +50,6 @@ public static IHostApplicationBuilder ConfigureOpenTelemetry(this IHostApplicati { metrics.AddAspNetCoreInstrumentation() .AddHttpClientInstrumentation() - .AddProcessInstrumentation() .AddRuntimeInstrumentation() .AddMeter("Microsoft.Orleans"); }) @@ -60,8 +65,8 @@ public static IHostApplicationBuilder ConfigureOpenTelemetry(this IHostApplicati tracing.AddSource("Microsoft.Orleans.Application"); tracing.AddAspNetCoreInstrumentation() - .AddGrpcClientInstrumentation() - .AddHttpClientInstrumentation(); + .AddGrpcClientInstrumentation() + .AddHttpClientInstrumentation(); }); builder.AddOpenTelemetryExporters(); @@ -85,8 +90,11 @@ private static IHostApplicationBuilder AddOpenTelemetryExporters(this IHostAppli // .WithMetrics(metrics => metrics.AddPrometheusExporter()); // Uncomment the following lines to enable the Azure Monitor exporter (requires the Azure.Monitor.OpenTelemetry.AspNetCore package) - // builder.Services.AddOpenTelemetry() - // .UseAzureMonitor(); + //if (!string.IsNullOrEmpty(builder.Configuration["APPLICATIONINSIGHTS_CONNECTION_STRING"])) + //{ + // builder.Services.AddOpenTelemetry() + // .UseAzureMonitor(); + //} return builder; } diff --git a/playground/orleans/OrleansServiceDefaults/OrleansServiceDefaults.csproj b/playground/orleans/OrleansServiceDefaults/OrleansServiceDefaults.csproj index a821462d1b2..80de516c7a6 100644 --- a/playground/orleans/OrleansServiceDefaults/OrleansServiceDefaults.csproj +++ b/playground/orleans/OrleansServiceDefaults/OrleansServiceDefaults.csproj @@ -13,7 +13,6 @@ - diff --git a/playground/seq/Seq.ServiceDefaults/Extensions.cs b/playground/seq/Seq.ServiceDefaults/Extensions.cs index c3b505b62af..0706f133be1 100644 --- a/playground/seq/Seq.ServiceDefaults/Extensions.cs +++ b/playground/seq/Seq.ServiceDefaults/Extensions.cs @@ -32,6 +32,12 @@ public static IHostApplicationBuilder AddServiceDefaults(this IHostApplicationBu http.UseServiceDiscovery(); }); + // Uncomment the following to restrict the allowed schemes for service discovery. + // builder.Services.Configure(options => + // { + // options.AllowedSchemes = ["https"]; + // }); + return builder; } @@ -46,8 +52,9 @@ public static IHostApplicationBuilder ConfigureOpenTelemetry(this IHostApplicati builder.Services.AddOpenTelemetry() .WithMetrics(metrics => { - metrics.AddRuntimeInstrumentation() - .AddBuiltInMeters(); + metrics.AddAspNetCoreInstrumentation() + .AddHttpClientInstrumentation() + .AddRuntimeInstrumentation(); }) .WithTracing(tracing => { @@ -60,8 +67,9 @@ public static IHostApplicationBuilder ConfigureOpenTelemetry(this IHostApplicati tracing.AddSource("MyApp.Source"); tracing.AddAspNetCoreInstrumentation() - .AddGrpcClientInstrumentation() - .AddHttpClientInstrumentation(); + // Uncomment the following line to enable gRPC instrumentation (requires the OpenTelemetry.Instrumentation.GrpcNetClient package) + //.AddGrpcClientInstrumentation() + .AddHttpClientInstrumentation(); }); builder.AddOpenTelemetryExporters(); @@ -84,9 +92,12 @@ private static IHostApplicationBuilder AddOpenTelemetryExporters(this IHostAppli // builder.Services.AddOpenTelemetry() // .WithMetrics(metrics => metrics.AddPrometheusExporter()); - // Uncomment the following lines to enable the Azure Monitor exporter (requires the Azure.Monitor.OpenTelemetry.Exporter package) - // builder.Services.AddOpenTelemetry() - // .UseAzureMonitor(); + // Uncomment the following lines to enable the Azure Monitor exporter (requires the Azure.Monitor.OpenTelemetry.AspNetCore package) + //if (!string.IsNullOrEmpty(builder.Configuration["APPLICATIONINSIGHTS_CONNECTION_STRING"])) + //{ + // builder.Services.AddOpenTelemetry() + // .UseAzureMonitor(); + //} return builder; } @@ -116,10 +127,4 @@ public static WebApplication MapDefaultEndpoints(this WebApplication app) return app; } - - private static MeterProviderBuilder AddBuiltInMeters(this MeterProviderBuilder meterProviderBuilder) => - meterProviderBuilder.AddMeter( - "Microsoft.AspNetCore.Hosting", - "Microsoft.AspNetCore.Server.Kestrel", - "System.Net.Http"); } diff --git a/playground/seq/Seq.ServiceDefaults/Seq.ServiceDefaults.csproj b/playground/seq/Seq.ServiceDefaults/Seq.ServiceDefaults.csproj index af91386fdfe..f7bd71a3cbf 100644 --- a/playground/seq/Seq.ServiceDefaults/Seq.ServiceDefaults.csproj +++ b/playground/seq/Seq.ServiceDefaults/Seq.ServiceDefaults.csproj @@ -16,7 +16,6 @@ - diff --git a/tests/TestingAppHost1/TestingAppHost1.ServiceDefaults/Extensions.cs b/tests/TestingAppHost1/TestingAppHost1.ServiceDefaults/Extensions.cs index 4921efee9ab..ecbc1fd83b1 100644 --- a/tests/TestingAppHost1/TestingAppHost1.ServiceDefaults/Extensions.cs +++ b/tests/TestingAppHost1/TestingAppHost1.ServiceDefaults/Extensions.cs @@ -28,6 +28,12 @@ public static IHostApplicationBuilder AddServiceDefaults(this IHostApplicationBu http.UseServiceDiscovery(); }); + // Uncomment the following to restrict the allowed schemes for service discovery. + // builder.Services.Configure(options => + // { + // options.AllowedSchemes = ["https"]; + // }); + return builder; } @@ -42,8 +48,9 @@ public static IHostApplicationBuilder ConfigureOpenTelemetry(this IHostApplicati builder.Services.AddOpenTelemetry() .WithMetrics(metrics => { - metrics.AddRuntimeInstrumentation() - .AddBuiltInMeters(); + metrics.AddAspNetCoreInstrumentation() + .AddHttpClientInstrumentation() + .AddRuntimeInstrumentation(); }) .WithTracing(tracing => { @@ -54,8 +61,9 @@ public static IHostApplicationBuilder ConfigureOpenTelemetry(this IHostApplicati } tracing.AddAspNetCoreInstrumentation() - .AddGrpcClientInstrumentation() - .AddHttpClientInstrumentation(); + // Uncomment the following line to enable gRPC instrumentation (requires the OpenTelemetry.Instrumentation.GrpcNetClient package) + //.AddGrpcClientInstrumentation() + .AddHttpClientInstrumentation(); }); builder.AddOpenTelemetryExporters(); @@ -79,8 +87,11 @@ private static IHostApplicationBuilder AddOpenTelemetryExporters(this IHostAppli // .WithMetrics(metrics => metrics.AddPrometheusExporter()); // Uncomment the following lines to enable the Azure Monitor exporter (requires the Azure.Monitor.OpenTelemetry.AspNetCore package) - // builder.Services.AddOpenTelemetry() - // .UseAzureMonitor(); + //if (!string.IsNullOrEmpty(builder.Configuration["APPLICATIONINSIGHTS_CONNECTION_STRING"])) + //{ + // builder.Services.AddOpenTelemetry() + // .UseAzureMonitor(); + //} return builder; } @@ -110,10 +121,4 @@ public static WebApplication MapDefaultEndpoints(this WebApplication app) return app; } - - private static MeterProviderBuilder AddBuiltInMeters(this MeterProviderBuilder meterProviderBuilder) => - meterProviderBuilder.AddMeter( - "Microsoft.AspNetCore.Hosting", - "Microsoft.AspNetCore.Server.Kestrel", - "System.Net.Http"); } diff --git a/tests/TestingAppHost1/TestingAppHost1.ServiceDefaults/TestingAppHost1.ServiceDefaults.csproj b/tests/TestingAppHost1/TestingAppHost1.ServiceDefaults/TestingAppHost1.ServiceDefaults.csproj index c315411ff55..5dae395dd97 100644 --- a/tests/TestingAppHost1/TestingAppHost1.ServiceDefaults/TestingAppHost1.ServiceDefaults.csproj +++ b/tests/TestingAppHost1/TestingAppHost1.ServiceDefaults/TestingAppHost1.ServiceDefaults.csproj @@ -1,7 +1,6 @@ - Library net8.0 enable enable @@ -15,7 +14,6 @@ -