File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed
Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -377,6 +377,21 @@ using var tracer = Sdk
377377 .Build ();
378378```
379379
380+ For integration from a plain CLI app with Aspire (or whenever an OLTP endpoint is provided as an
381+ environment variable ), you can simplify it as:
382+
383+ ```csharp
384+ var builder = Host.CreateApplicationBuilder(args);
385+
386+ if (!string.IsNullOrWhiteSpace(builder.Configuration["OTEL_EXPORTER_OTLP_ENDPOINT "]))
387+ {
388+ builder .Services .AddOpenTelemetry ()
389+ .ConfigureResource (x => x .AddService (" MyApp" ))
390+ .WithTracing (x => x .AddSource (" Merq" ).AddOtlpExporter ())
391+ .WithMetrics (x => x .AddMeter (" Merq" ).AddOtlpExporter ());
392+ }
393+ ```
394+
380395Collecting traces via [dotnet -trace ](https:// learn.microsoft.com/en-us/dotnet/core/diagnostics/dotnet-trace):
381396
382397```shell
You can’t perform that action at this time.
0 commit comments