Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Hosting README updates.
  • Loading branch information
CodeBlanch committed Feb 9, 2023
commit 89988494c8e1198dad4a2b88c067ec32cf5b4ce9
34 changes: 31 additions & 3 deletions src/OpenTelemetry.Extensions.Hosting/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,40 @@ and metrics (`MeterProvider`) in [ASP.NET

### Current OpenTelemetry SDK v1.4.0 and newer extensions

Targeting `OpenTelemetry.OpenTelemetryBuilder`:
Targeting `Microsoft.Extensions.DependencyInjection.IServiceCollection`:

* `StartWithHost`: Registers an
* `AddOpenTelemetry`: Registers an
[IHostedService](https://learn.microsoft.com/dotnet/api/microsoft.extensions.hosting.ihostedservice)
to automatically start tracing and/or metric services in the supplied
[IServiceCollection](https://learn.microsoft.com/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection).
[IServiceCollection](https://learn.microsoft.com/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection)
and then returns an `OpenTelemetryBuilder` class.

> **Note**
> `AddOpenTelemetry` should be called by application host code only. Library
authors see: [Registration extension method guidance for library
authors](../../docs/trace/extending-the-sdk/README.md#registration-extension-method-guidance-for-library-authors).
<!-- This comment is to make sure the two notes above and below are not merged -->
> **Note**
> Multiple calls to `AddOpenTelemetry` will **NOT** result in multiple
providers. Only a single `TracerProvider` and/or `MeterProvider` will be
created in the target `IServiceCollection`. To establish multiple providers
use the `Sdk.CreateTracerProviderBuilder()` and/or
`Sdk.CreateMeterProviderBuilder()` methods. See [TracerProvider
configuration](../../docs/trace/customizing-the-sdk/README.md#tracerprovider-configuration)
and [Building a
MeterProvider](../../docs/metrics/customizing-the-sdk/README.md#building-a-meterprovider)
for more details.

`OpenTelemetryBuilder` methods:

* `ConfigureResource`: Registers a callback action to configure the
`ResourceBuilder` for tracing and metric providers.

* `WithTracing`: Enables tracing and optionally configures the
`TracerProvider`.

* `WithMetrics`: Enables metrics and optionally configures the
`MeterProvider`.

### Obsolete OpenTelemetry SDK pre-1.4.0 extensions

Expand Down