Skip to content

Commit 494f86c

Browse files
authored
Disable OTEL telemetry in CLI if not a debug build. (#8612)
1 parent 256b4da commit 494f86c

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/Aspire.Cli/Program.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,13 @@
99
using Microsoft.Extensions.DependencyInjection;
1010
using Microsoft.Extensions.Hosting;
1111
using Microsoft.Extensions.Logging;
12+
13+
#if DEBUG
1214
using OpenTelemetry;
1315
using OpenTelemetry.Resources;
1416
using OpenTelemetry.Trace;
17+
#endif
18+
1519
using RootCommand = Aspire.Cli.Commands.RootCommand;
1620

1721
namespace Aspire.Cli;
@@ -32,6 +36,7 @@ private static IHost BuildApplication(string[] args)
3236
logging.IncludeScopes = true;
3337
});
3438

39+
#if DEBUG
3540
var otelBuilder = builder.Services
3641
.AddOpenTelemetry()
3742
.WithTracing(tracing => {
@@ -56,6 +61,7 @@ private static IHost BuildApplication(string[] args)
5661
// has to finish sending telemetry.
5762
otelBuilder.UseOtlpExporter();
5863
}
64+
#endif
5965

6066
var debugMode = args?.Any(a => a == "--debug" || a == "-d") ?? false;
6167

0 commit comments

Comments
 (0)