Update docs for StartWithHost removal. (#4178)

This commit is contained in:
Mikel Blanchard 2023-02-10 12:41:36 -08:00 committed by GitHub
parent 74212a2402
commit 3c592361eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 11 additions and 16 deletions

View File

@ -34,13 +34,12 @@ using OpenTelemetry.Trace;
var appBuilder = WebApplication.CreateBuilder(args);
appBuilder.Services.AddOpenTelemetry()
.WithTracing(builder => builder.AddConsoleExporter())
.StartWithHost();
.WithTracing(builder => builder.AddConsoleExporter());
```
> **Note**
> The
[StartWithHost](../../../src/OpenTelemetry.Extensions.Hosting/README.md#extension-method-reference)
[AddOpenTelemetry](../../../src/OpenTelemetry.Extensions.Hosting/README.md#extension-method-reference)
extension automatically starts and stops the `TracerProvider` with the host.
### Using Sdk.CreateTracerProviderBuilder
@ -442,8 +441,7 @@ appBuilder.Services.AddSingleton<MyCustomService>();
appBuilder.Services.AddOpenTelemetry()
.WithTracing(builder => builder
.AddProcessor<MyCustomProcessor>())
.StartWithHost();
.AddProcessor<MyCustomProcessor>());
```
When using the `AddOpenTelemetry` & `WithTracing` extension methods the
@ -451,7 +449,7 @@ When using the `AddOpenTelemetry` & `WithTracing` extension methods the
into an existing collection (typically the collection used is the one managed by
the application host). The `TracerProviderBuilder` will be able to access all
services registered into that collection. For lifecycle management, the
`StartWithHost` registers an [IHostedService
`AddOpenTelemetry` registers an [IHostedService
](https://learn.microsoft.com/dotnet/api/microsoft.extensions.hosting.ihostedservice)
which is used to automatically start the `TracerProvider` when the host starts
and the host will automatically shutdown and dispose the `TracerProvider` when
@ -651,8 +649,7 @@ appBuilder.Services.Configure<JaegerExporterOptions>(
appBuilder.Configuration.GetSection("OpenTelemetry:Jaeger"));
appBuilder.Services.AddOpenTelemetry()
.WithTracing(builder => builder.AddJaegerExporter())
.StartWithHost();
.WithTracing(builder => builder.AddJaegerExporter());
```
The OpenTelemetry .NET SDK supports running multiple `TracerProvider`s inside
@ -696,6 +693,5 @@ appBuilder.Services.Configure<JaegerExporterOptions>(
appBuilder.Services.AddOpenTelemetry()
.WithTracing(builder => builder
.AddJaegerExporter(name: "JaegerPrimary", configure: null)
.AddJaegerExporter(name: "JaegerSecondary", configure: null))
.StartWithHost();
.AddJaegerExporter(name: "JaegerSecondary", configure: null));
```

View File

@ -635,7 +635,7 @@ this case).
> **Note**
> `ConfigureOpenTelemetryTracerProvider` and
`ConfigureOpenTelemetryMeterProvider` do not automatically start OpenTelemetry.
The host is responsible for either calling `StartWithHost` in the
The host is responsible for either calling `AddOpenTelemetry` in the
[OpenTelemetry.Extensions.Hosting](../../../src/OpenTelemetry.Extensions.Hosting/README.md)
package, calling `Build` when using the `Sdk.CreateTracerProviderBuilder` and
`Sdk.CreateMeterProviderBuilder` methods, or by accessing the `TracerProvider`

View File

@ -78,12 +78,11 @@ appBuilder.Services.AddOpenTelemetry()
.AddService(serviceName: "OTel.NET Getting Started"))
.WithTracing(builder => builder
.AddAspNetCoreInstrumentation()
.AddConsoleExporter())
.StartWithHost();
.AddConsoleExporter());
```
> **Note**
> The `StartWithHost` extension is part of the
> The `AddOpenTelemetry` extension is part of the
[OpenTelemetry.Extensions.Hosting](../../../src/OpenTelemetry.Extensions.Hosting/README.md)
package.

View File

@ -39,7 +39,7 @@ public static class OpenTelemetryDependencyInjectionMetricsServiceCollectionExte
/// <item>A <see cref="MeterProvider"/> will not be created automatically
/// using this method. To begin collecting metrics use the
/// <c>IServiceCollection.AddOpenTelemetry</c> extension in the
/// <c>OpenTelemetry</c> package.</item>
/// <c>OpenTelemetry.Extensions.Hosting</c> package.</item>
/// </list>
/// </remarks>
/// <param name="services">The <see cref="IServiceCollection" /> to add

View File

@ -39,7 +39,7 @@ public static class OpenTelemetryDependencyInjectionTracingServiceCollectionExte
/// <item>A <see cref="TracerProvider"/> will not be created automatically
/// using this method. To begin collecting metrics use the
/// <c>IServiceCollection.AddOpenTelemetry</c> extension in the
/// <c>OpenTelemetry</c> package.</item>
/// <c>OpenTelemetry.Extensions.Hosting</c> package.</item>
/// </list>
/// </remarks>
/// <param name="services">The <see cref="IServiceCollection" /> to add