diff --git a/src/Aspire.Hosting.Orleans/OrleansService.cs b/src/Aspire.Hosting.Orleans/OrleansService.cs index 7034f83e59f..c426dc16dda 100644 --- a/src/Aspire.Hosting.Orleans/OrleansService.cs +++ b/src/Aspire.Hosting.Orleans/OrleansService.cs @@ -59,4 +59,12 @@ public class OrleansService(IDistributedApplicationBuilder builder, string name) /// Gets the stream providers. /// public Dictionary Streaming { get; } = []; + + /// + /// Gets or sets a value indicating whether to enable tracing of grain calls. + /// + /// + /// Distributed tracing is enabled by default. + /// + public bool? EnableDistributedTracing { get; set; } } diff --git a/src/Aspire.Hosting.Orleans/OrleansServiceExtensions.cs b/src/Aspire.Hosting.Orleans/OrleansServiceExtensions.cs index 2c832012dfa..2db53004e5a 100644 --- a/src/Aspire.Hosting.Orleans/OrleansServiceExtensions.cs +++ b/src/Aspire.Hosting.Orleans/OrleansServiceExtensions.cs @@ -358,6 +358,12 @@ public static IResourceBuilder WithReference( builder.WithEnvironment("Orleans__ServiceId", res.ServiceId); } + // Enable distributed tracing by default + if (res.EnableDistributedTracing != false) + { + builder.WithEnvironment("Orleans__EnableDistributedTracing", "true"); + } + return builder; } }