Skip to content

Commit 02e9797

Browse files
jfversluisCopilot
andauthored
Enable OpenTelemetry metrics and tracing for MAUI in Service Defaults (#31900)
* Enable OpenTelemetry metrics and tracing for MAUI Added support for OpenTelemetry metrics and tracing from the .NET MAUI SDK. * Update src/Templates/src/templates/maui-aspire-servicedefaults/Extensions.cs Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]>
1 parent 638f220 commit 02e9797

File tree

1 file changed

+7
-1
lines changed
  • src/Templates/src/templates/maui-aspire-servicedefaults

1 file changed

+7
-1
lines changed

src/Templates/src/templates/maui-aspire-servicedefaults/Extensions.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,18 @@ public static TBuilder ConfigureOpenTelemetry<TBuilder>(this TBuilder builder) w
5252

5353
builder.Services.AddOpenTelemetry()
5454
.WithMetrics(metrics =>
55-
{
55+
{
56+
// Enable reporting metrics coming from the .NET MAUI SDK
57+
metrics.AddMeter("Microsoft.Maui");
58+
5659
metrics.AddHttpClientInstrumentation()
5760
.AddRuntimeInstrumentation();
5861
})
5962
.WithTracing(tracing =>
6063
{
64+
// Enable reporting tracing coming from the .NET MAUI SDK
65+
tracing.AddSource("Microsoft.Maui");
66+
6167
tracing.AddSource(builder.Environment.ApplicationName)
6268
// Uncomment the following line to enable gRPC instrumentation (requires the OpenTelemetry.Instrumentation.GrpcNetClient package)
6369
//.AddGrpcClientInstrumentation()

0 commit comments

Comments
 (0)