Skip to content

Commit a57c102

Browse files
Remove BuiltInMeters() (#2900)
* Remove BuiltInMeters() Remove some extra `BuiltInMeters()` code that snuck in after #1948. * Sync playgrounds with template Apply review feedback. * Fix-up extensions - Add gRPC back to the test shop. - Remove incorrect AWS references. * Restore Grpc reference Put it back so it builds... * Restore package reference Add another one back. * PR feedback - Remove OpenTelemetry.Instrumentation.Process from Directory.Packages.props - Sync a few more ServiceDefaults with the template --------- Co-authored-by: Eric Erhardt <[email protected]>
1 parent 16679d3 commit a57c102

File tree

13 files changed

+88
-64
lines changed

13 files changed

+88
-64
lines changed

Directory.Packages.props

-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@
112112
<PackageVersion Include="OpenTelemetry.Instrumentation.GrpcNetClient" Version="1.6.0-beta.3" />
113113
<PackageVersion Include="OpenTelemetry.Instrumentation.Http" Version="1.7.0" />
114114
<PackageVersion Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.7.0" />
115-
<PackageVersion Include="OpenTelemetry.Instrumentation.Process" Version="0.5.0-beta.4" />
116115
<PackageVersion Include="OpenTelemetry.Instrumentation.Runtime" Version="1.7.0" />
117116
<PackageVersion Include="OpenTelemetry.Instrumentation.SqlClient" Version="1.6.0-beta.3" />
118117
<PackageVersion Include="OpenTelemetry.Instrumentation.StackExchangeRedis" Version="1.0.0-rc9.13" />

playground/AWS/AWS.ServiceDefaults/AWS.ServiceDefaults.csproj

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" />
1212
<PackageReference Include="OpenTelemetry.Extensions.Hosting" />
1313
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" />
14-
<PackageReference Include="OpenTelemetry.Instrumentation.GrpcNetClient" />
1514
<PackageReference Include="OpenTelemetry.Instrumentation.Http" />
1615
<PackageReference Include="OpenTelemetry.Instrumentation.Runtime" />
1716

playground/AWS/AWS.ServiceDefaults/Extensions.cs

+20-16
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ public static IHostApplicationBuilder AddServiceDefaults(this IHostApplicationBu
3131
http.UseServiceDiscovery();
3232
});
3333

34+
// Uncomment the following to restrict the allowed schemes for service discovery.
35+
// builder.Services.Configure<ServiceDiscoveryOptions>(options =>
36+
// {
37+
// options.AllowedSchemes = ["https"];
38+
// });
39+
3440
return builder;
3541
}
3642

@@ -45,8 +51,9 @@ public static IHostApplicationBuilder ConfigureOpenTelemetry(this IHostApplicati
4551
builder.Services.AddOpenTelemetry()
4652
.WithMetrics(metrics =>
4753
{
48-
metrics.AddRuntimeInstrumentation()
49-
.AddBuiltInMeters();
54+
metrics.AddAspNetCoreInstrumentation()
55+
.AddHttpClientInstrumentation()
56+
.AddRuntimeInstrumentation();
5057
})
5158
.WithTracing(tracing =>
5259
{
@@ -57,11 +64,11 @@ public static IHostApplicationBuilder ConfigureOpenTelemetry(this IHostApplicati
5764
}
5865

5966
tracing.AddAspNetCoreInstrumentation()
60-
.AddGrpcClientInstrumentation()
61-
.AddHttpClientInstrumentation()
62-
63-
// Add instrumentation for the AWS .NET SDK.
64-
.AddAWSInstrumentation();
67+
// Uncomment the following line to enable gRPC instrumentation (requires the OpenTelemetry.Instrumentation.GrpcNetClient package)
68+
//.AddGrpcClientInstrumentation()
69+
.AddHttpClientInstrumentation()
70+
// Add instrumentation for the AWS .NET SDK.
71+
.AddAWSInstrumentation();
6572
});
6673

6774
builder.AddOpenTelemetryExporters();
@@ -84,9 +91,12 @@ private static IHostApplicationBuilder AddOpenTelemetryExporters(this IHostAppli
8491
// builder.Services.AddOpenTelemetry()
8592
// .WithMetrics(metrics => metrics.AddPrometheusExporter());
8693

87-
// Uncomment the following lines to enable the Azure Monitor exporter (requires the Azure.Monitor.OpenTelemetry.Exporter package)
88-
// builder.Services.AddOpenTelemetry()
89-
// .UseAzureMonitor();
94+
// Uncomment the following lines to enable the Azure Monitor exporter (requires the Azure.Monitor.OpenTelemetry.AspNetCore package)
95+
//if (!string.IsNullOrEmpty(builder.Configuration["APPLICATIONINSIGHTS_CONNECTION_STRING"]))
96+
//{
97+
// builder.Services.AddOpenTelemetry()
98+
// .UseAzureMonitor();
99+
//}
90100

91101
return builder;
92102
}
@@ -116,10 +126,4 @@ public static WebApplication MapDefaultEndpoints(this WebApplication app)
116126

117127
return app;
118128
}
119-
120-
private static MeterProviderBuilder AddBuiltInMeters(this MeterProviderBuilder meterProviderBuilder) =>
121-
meterProviderBuilder.AddMeter(
122-
"Microsoft.AspNetCore.Hosting",
123-
"Microsoft.AspNetCore.Server.Kestrel",
124-
"System.Net.Http");
125129
}

playground/Playground.ServiceDefaults/Extensions.cs

+12-6
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ public static IHostApplicationBuilder AddServiceDefaults(this IHostApplicationBu
3131
http.UseServiceDiscovery();
3232
});
3333

34+
// Uncomment the following to restrict the allowed schemes for service discovery.
35+
// builder.Services.Configure<ServiceDiscoveryOptions>(options =>
36+
// {
37+
// options.AllowedSchemes = ["https"];
38+
// });
39+
3440
return builder;
3541
}
3642

@@ -46,9 +52,8 @@ public static IHostApplicationBuilder ConfigureOpenTelemetry(this IHostApplicati
4652
.WithMetrics(metrics =>
4753
{
4854
metrics.AddAspNetCoreInstrumentation()
49-
.AddHttpClientInstrumentation()
50-
.AddProcessInstrumentation()
51-
.AddRuntimeInstrumentation();
55+
.AddHttpClientInstrumentation()
56+
.AddRuntimeInstrumentation();
5257
})
5358
.WithTracing(tracing =>
5459
{
@@ -59,8 +64,9 @@ public static IHostApplicationBuilder ConfigureOpenTelemetry(this IHostApplicati
5964
}
6065

6166
tracing.AddAspNetCoreInstrumentation()
62-
.AddGrpcClientInstrumentation()
63-
.AddHttpClientInstrumentation();
67+
// Uncomment the following line to enable gRPC instrumentation (requires the OpenTelemetry.Instrumentation.GrpcNetClient package)
68+
//.AddGrpcClientInstrumentation()
69+
.AddHttpClientInstrumentation();
6470
});
6571

6672
builder.AddOpenTelemetryExporters();
@@ -87,7 +93,7 @@ private static IHostApplicationBuilder AddOpenTelemetryExporters(this IHostAppli
8793
//if (!string.IsNullOrEmpty(builder.Configuration["APPLICATIONINSIGHTS_CONNECTION_STRING"]))
8894
//{
8995
// builder.Services.AddOpenTelemetry()
90-
// .UseAzureMonitor();
96+
// .UseAzureMonitor();
9197
//}
9298

9399
return builder;

playground/Playground.ServiceDefaults/Playground.ServiceDefaults.csproj

-2
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@
1515
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" />
1616
<PackageReference Include="OpenTelemetry.Extensions.Hosting" />
1717
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" />
18-
<PackageReference Include="OpenTelemetry.Instrumentation.GrpcNetClient" />
1918
<PackageReference Include="OpenTelemetry.Instrumentation.Http" />
20-
<PackageReference Include="OpenTelemetry.Instrumentation.Process" />
2119
<PackageReference Include="OpenTelemetry.Instrumentation.Runtime" />
2220

2321
<ProjectReference Include="..\..\src\Microsoft.Extensions.ServiceDiscovery.Dns\Microsoft.Extensions.ServiceDiscovery.Dns.csproj" />

playground/TestShop/ServiceDefaults/Extensions.cs

+8-3
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ public static IHostApplicationBuilder AddServiceDefaults(this IHostApplicationBu
2828
http.UseServiceDiscovery();
2929
});
3030

31+
// Uncomment the following to restrict the allowed schemes for service discovery.
32+
// builder.Services.Configure<ServiceDiscoveryOptions>(options =>
33+
// {
34+
// options.AllowedSchemes = ["https"];
35+
// });
36+
3137
return builder;
3238
}
3339

@@ -44,7 +50,6 @@ public static IHostApplicationBuilder ConfigureOpenTelemetry(this IHostApplicati
4450
{
4551
metrics.AddAspNetCoreInstrumentation()
4652
.AddHttpClientInstrumentation()
47-
.AddProcessInstrumentation()
4853
.AddRuntimeInstrumentation();
4954
})
5055
.WithTracing(tracing =>
@@ -56,8 +61,8 @@ public static IHostApplicationBuilder ConfigureOpenTelemetry(this IHostApplicati
5661
}
5762

5863
tracing.AddAspNetCoreInstrumentation()
59-
.AddGrpcClientInstrumentation()
60-
.AddHttpClientInstrumentation();
64+
.AddGrpcClientInstrumentation()
65+
.AddHttpClientInstrumentation();
6166
});
6267

6368
builder.AddOpenTelemetryExporters();

playground/TestShop/ServiceDefaults/ServiceDefaults.csproj

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" />
1414
<PackageReference Include="OpenTelemetry.Instrumentation.GrpcNetClient" />
1515
<PackageReference Include="OpenTelemetry.Instrumentation.Http" />
16-
<PackageReference Include="OpenTelemetry.Instrumentation.Process" />
1716
<PackageReference Include="OpenTelemetry.Instrumentation.Runtime" />
1817

1918
<PackageReference Include="Microsoft.Extensions.Http.Resilience" />

playground/orleans/OrleansServiceDefaults/Extensions.cs

+13-5
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ public static IHostApplicationBuilder AddServiceDefaults(this IHostApplicationBu
2828
http.UseServiceDiscovery();
2929
});
3030

31+
// Uncomment the following to restrict the allowed schemes for service discovery.
32+
// builder.Services.Configure<ServiceDiscoveryOptions>(options =>
33+
// {
34+
// options.AllowedSchemes = ["https"];
35+
// });
36+
3137
return builder;
3238
}
3339

@@ -44,7 +50,6 @@ public static IHostApplicationBuilder ConfigureOpenTelemetry(this IHostApplicati
4450
{
4551
metrics.AddAspNetCoreInstrumentation()
4652
.AddHttpClientInstrumentation()
47-
.AddProcessInstrumentation()
4853
.AddRuntimeInstrumentation()
4954
.AddMeter("Microsoft.Orleans");
5055
})
@@ -60,8 +65,8 @@ public static IHostApplicationBuilder ConfigureOpenTelemetry(this IHostApplicati
6065
tracing.AddSource("Microsoft.Orleans.Application");
6166

6267
tracing.AddAspNetCoreInstrumentation()
63-
.AddGrpcClientInstrumentation()
64-
.AddHttpClientInstrumentation();
68+
.AddGrpcClientInstrumentation()
69+
.AddHttpClientInstrumentation();
6570
});
6671

6772
builder.AddOpenTelemetryExporters();
@@ -85,8 +90,11 @@ private static IHostApplicationBuilder AddOpenTelemetryExporters(this IHostAppli
8590
// .WithMetrics(metrics => metrics.AddPrometheusExporter());
8691

8792
// Uncomment the following lines to enable the Azure Monitor exporter (requires the Azure.Monitor.OpenTelemetry.AspNetCore package)
88-
// builder.Services.AddOpenTelemetry()
89-
// .UseAzureMonitor();
93+
//if (!string.IsNullOrEmpty(builder.Configuration["APPLICATIONINSIGHTS_CONNECTION_STRING"]))
94+
//{
95+
// builder.Services.AddOpenTelemetry()
96+
// .UseAzureMonitor();
97+
//}
9098

9199
return builder;
92100
}

playground/orleans/OrleansServiceDefaults/OrleansServiceDefaults.csproj

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" />
1414
<PackageReference Include="OpenTelemetry.Instrumentation.GrpcNetClient" />
1515
<PackageReference Include="OpenTelemetry.Instrumentation.Http" />
16-
<PackageReference Include="OpenTelemetry.Instrumentation.Process" />
1716
<PackageReference Include="OpenTelemetry.Instrumentation.Runtime" />
1817

1918
<PackageReference Include="Microsoft.Extensions.Http.Resilience" />

playground/seq/Seq.ServiceDefaults/Extensions.cs

+18-13
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ public static IHostApplicationBuilder AddServiceDefaults(this IHostApplicationBu
3232
http.UseServiceDiscovery();
3333
});
3434

35+
// Uncomment the following to restrict the allowed schemes for service discovery.
36+
// builder.Services.Configure<ServiceDiscoveryOptions>(options =>
37+
// {
38+
// options.AllowedSchemes = ["https"];
39+
// });
40+
3541
return builder;
3642
}
3743

@@ -46,8 +52,9 @@ public static IHostApplicationBuilder ConfigureOpenTelemetry(this IHostApplicati
4652
builder.Services.AddOpenTelemetry()
4753
.WithMetrics(metrics =>
4854
{
49-
metrics.AddRuntimeInstrumentation()
50-
.AddBuiltInMeters();
55+
metrics.AddAspNetCoreInstrumentation()
56+
.AddHttpClientInstrumentation()
57+
.AddRuntimeInstrumentation();
5158
})
5259
.WithTracing(tracing =>
5360
{
@@ -60,8 +67,9 @@ public static IHostApplicationBuilder ConfigureOpenTelemetry(this IHostApplicati
6067
tracing.AddSource("MyApp.Source");
6168

6269
tracing.AddAspNetCoreInstrumentation()
63-
.AddGrpcClientInstrumentation()
64-
.AddHttpClientInstrumentation();
70+
// Uncomment the following line to enable gRPC instrumentation (requires the OpenTelemetry.Instrumentation.GrpcNetClient package)
71+
//.AddGrpcClientInstrumentation()
72+
.AddHttpClientInstrumentation();
6573
});
6674

6775
builder.AddOpenTelemetryExporters();
@@ -84,9 +92,12 @@ private static IHostApplicationBuilder AddOpenTelemetryExporters(this IHostAppli
8492
// builder.Services.AddOpenTelemetry()
8593
// .WithMetrics(metrics => metrics.AddPrometheusExporter());
8694

87-
// Uncomment the following lines to enable the Azure Monitor exporter (requires the Azure.Monitor.OpenTelemetry.Exporter package)
88-
// builder.Services.AddOpenTelemetry()
89-
// .UseAzureMonitor();
95+
// Uncomment the following lines to enable the Azure Monitor exporter (requires the Azure.Monitor.OpenTelemetry.AspNetCore package)
96+
//if (!string.IsNullOrEmpty(builder.Configuration["APPLICATIONINSIGHTS_CONNECTION_STRING"]))
97+
//{
98+
// builder.Services.AddOpenTelemetry()
99+
// .UseAzureMonitor();
100+
//}
90101

91102
return builder;
92103
}
@@ -116,10 +127,4 @@ public static WebApplication MapDefaultEndpoints(this WebApplication app)
116127

117128
return app;
118129
}
119-
120-
private static MeterProviderBuilder AddBuiltInMeters(this MeterProviderBuilder meterProviderBuilder) =>
121-
meterProviderBuilder.AddMeter(
122-
"Microsoft.AspNetCore.Hosting",
123-
"Microsoft.AspNetCore.Server.Kestrel",
124-
"System.Net.Http");
125130
}

playground/seq/Seq.ServiceDefaults/Seq.ServiceDefaults.csproj

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" />
1717
<PackageReference Include="OpenTelemetry.Extensions.Hosting" />
1818
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" />
19-
<PackageReference Include="OpenTelemetry.Instrumentation.GrpcNetClient" />
2019
<PackageReference Include="OpenTelemetry.Instrumentation.Http" />
2120
<PackageReference Include="OpenTelemetry.Instrumentation.Runtime" />
2221
<ProjectReference Include="..\..\..\src\Components\Aspire.Seq\Aspire.Seq.csproj" />

tests/TestingAppHost1/TestingAppHost1.ServiceDefaults/Extensions.cs

+17-12
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ public static IHostApplicationBuilder AddServiceDefaults(this IHostApplicationBu
2828
http.UseServiceDiscovery();
2929
});
3030

31+
// Uncomment the following to restrict the allowed schemes for service discovery.
32+
// builder.Services.Configure<ServiceDiscoveryOptions>(options =>
33+
// {
34+
// options.AllowedSchemes = ["https"];
35+
// });
36+
3137
return builder;
3238
}
3339

@@ -42,8 +48,9 @@ public static IHostApplicationBuilder ConfigureOpenTelemetry(this IHostApplicati
4248
builder.Services.AddOpenTelemetry()
4349
.WithMetrics(metrics =>
4450
{
45-
metrics.AddRuntimeInstrumentation()
46-
.AddBuiltInMeters();
51+
metrics.AddAspNetCoreInstrumentation()
52+
.AddHttpClientInstrumentation()
53+
.AddRuntimeInstrumentation();
4754
})
4855
.WithTracing(tracing =>
4956
{
@@ -54,8 +61,9 @@ public static IHostApplicationBuilder ConfigureOpenTelemetry(this IHostApplicati
5461
}
5562

5663
tracing.AddAspNetCoreInstrumentation()
57-
.AddGrpcClientInstrumentation()
58-
.AddHttpClientInstrumentation();
64+
// Uncomment the following line to enable gRPC instrumentation (requires the OpenTelemetry.Instrumentation.GrpcNetClient package)
65+
//.AddGrpcClientInstrumentation()
66+
.AddHttpClientInstrumentation();
5967
});
6068

6169
builder.AddOpenTelemetryExporters();
@@ -79,8 +87,11 @@ private static IHostApplicationBuilder AddOpenTelemetryExporters(this IHostAppli
7987
// .WithMetrics(metrics => metrics.AddPrometheusExporter());
8088

8189
// Uncomment the following lines to enable the Azure Monitor exporter (requires the Azure.Monitor.OpenTelemetry.AspNetCore package)
82-
// builder.Services.AddOpenTelemetry()
83-
// .UseAzureMonitor();
90+
//if (!string.IsNullOrEmpty(builder.Configuration["APPLICATIONINSIGHTS_CONNECTION_STRING"]))
91+
//{
92+
// builder.Services.AddOpenTelemetry()
93+
// .UseAzureMonitor();
94+
//}
8495

8596
return builder;
8697
}
@@ -110,10 +121,4 @@ public static WebApplication MapDefaultEndpoints(this WebApplication app)
110121

111122
return app;
112123
}
113-
114-
private static MeterProviderBuilder AddBuiltInMeters(this MeterProviderBuilder meterProviderBuilder) =>
115-
meterProviderBuilder.AddMeter(
116-
"Microsoft.AspNetCore.Hosting",
117-
"Microsoft.AspNetCore.Server.Kestrel",
118-
"System.Net.Http");
119124
}

tests/TestingAppHost1/TestingAppHost1.ServiceDefaults/TestingAppHost1.ServiceDefaults.csproj

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<OutputType>Library</OutputType>
54
<TargetFramework>net8.0</TargetFramework>
65
<ImplicitUsings>enable</ImplicitUsings>
76
<Nullable>enable</Nullable>
@@ -15,7 +14,6 @@
1514
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" />
1615
<PackageReference Include="OpenTelemetry.Extensions.Hosting" />
1716
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" />
18-
<PackageReference Include="OpenTelemetry.Instrumentation.GrpcNetClient" />
1917
<PackageReference Include="OpenTelemetry.Instrumentation.Http" />
2018
<PackageReference Include="OpenTelemetry.Instrumentation.Runtime" />
2119
</ItemGroup>

0 commit comments

Comments
 (0)