Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Hosting] Remove obsolete methods ahead of 1.4.0 release #4071

Merged
merged 16 commits into from
Feb 23, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
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
2 changes: 1 addition & 1 deletion src/OpenTelemetry.Extensions.DependencyInjection/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
## Installation

```shell
dotnet add package --prerelease OpenTelemetry.Extensions.DependencyInjection
dotnet add package OpenTelemetry.Extensions.DependencyInjection
CodeBlanch marked this conversation as resolved.
Show resolved Hide resolved
```

## Overview
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#nullable enable
Original file line number Diff line number Diff line change
@@ -1,13 +1,2 @@
Microsoft.Extensions.DependencyInjection.OpenTelemetryServicesExtensions
OpenTelemetry.Metrics.MeterProviderBuilderExtensions
OpenTelemetry.OpenTelemetryBuilderHostingExtensions
OpenTelemetry.Trace.TracerProviderBuilderExtensions
static Microsoft.Extensions.DependencyInjection.OpenTelemetryServicesExtensions.AddOpenTelemetryMetrics(this Microsoft.Extensions.DependencyInjection.IServiceCollection services) -> Microsoft.Extensions.DependencyInjection.IServiceCollection
static Microsoft.Extensions.DependencyInjection.OpenTelemetryServicesExtensions.AddOpenTelemetryMetrics(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, System.Action<OpenTelemetry.Metrics.MeterProviderBuilder> configure) -> Microsoft.Extensions.DependencyInjection.IServiceCollection
static Microsoft.Extensions.DependencyInjection.OpenTelemetryServicesExtensions.AddOpenTelemetryTracing(this Microsoft.Extensions.DependencyInjection.IServiceCollection services) -> Microsoft.Extensions.DependencyInjection.IServiceCollection
static Microsoft.Extensions.DependencyInjection.OpenTelemetryServicesExtensions.AddOpenTelemetryTracing(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, System.Action<OpenTelemetry.Trace.TracerProviderBuilder> configure) -> Microsoft.Extensions.DependencyInjection.IServiceCollection
static OpenTelemetry.Metrics.MeterProviderBuilderExtensions.Configure(this OpenTelemetry.Metrics.MeterProviderBuilder meterProviderBuilder, System.Action<System.IServiceProvider, OpenTelemetry.Metrics.MeterProviderBuilder> configure) -> OpenTelemetry.Metrics.MeterProviderBuilder
static OpenTelemetry.Metrics.MeterProviderBuilderExtensions.GetServices(this OpenTelemetry.Metrics.MeterProviderBuilder meterProviderBuilder) -> Microsoft.Extensions.DependencyInjection.IServiceCollection
static OpenTelemetry.OpenTelemetryBuilderHostingExtensions.StartWithHost(this OpenTelemetry.OpenTelemetryBuilder builder) -> OpenTelemetry.OpenTelemetryBuilder
static OpenTelemetry.Trace.TracerProviderBuilderExtensions.Configure(this OpenTelemetry.Trace.TracerProviderBuilder tracerProviderBuilder, System.Action<System.IServiceProvider, OpenTelemetry.Trace.TracerProviderBuilder> configure) -> OpenTelemetry.Trace.TracerProviderBuilder
static OpenTelemetry.Trace.TracerProviderBuilderExtensions.GetServices(this OpenTelemetry.Trace.TracerProviderBuilder tracerProviderBuilder) -> Microsoft.Extensions.DependencyInjection.IServiceCollection
static OpenTelemetry.OpenTelemetryBuilderHostingExtensions.StartWithHost(this OpenTelemetry.OpenTelemetryBuilder! builder) -> OpenTelemetry.OpenTelemetryBuilder!
4 changes: 4 additions & 0 deletions src/OpenTelemetry.Extensions.Hosting/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

* Removed deprecated extensions: `AddOpenTelemetryTracing`,
CodeBlanch marked this conversation as resolved.
Show resolved Hide resolved
`AddOpenTelemetryMetrics`, `Configure`, & `GetServices`.
([#4071](https://github.com/open-telemetry/opentelemetry-dotnet/pull/4071))

## 1.4.0-rc.2

Released 2023-Jan-09
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ internal static void Initialize(IServiceProvider serviceProvider)
{
Debug.Assert(serviceProvider != null, "serviceProvider was null");

var meterProvider = serviceProvider.GetService<MeterProvider>();
var meterProvider = serviceProvider!.GetService<MeterProvider>();
if (meterProvider == null)
{
HostingExtensionsEventSource.Log.MeterProviderNotRegistered();
}

var tracerProvider = serviceProvider.GetService<TracerProvider>();
var tracerProvider = serviceProvider!.GetService<TracerProvider>();
if (tracerProvider == null)
{
HostingExtensionsEventSource.Log.TracerProviderNotRegistered();
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<!-- OmniSharp/VS Code requires TargetFrameworks to be in descending order for IntelliSense and analysis. -->
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<Description>Contains extensions to start OpenTelemetry in applications using Microsoft.Extensions.Hosting</Description>
<RootNamespace>OpenTelemetry</RootNamespace>
<MinVerTagPrefix>core-</MinVerTagPrefix>

<!-- this is temporary. will remove in future PR. -->
<Nullable>disable</Nullable>
CodeBlanch marked this conversation as resolved.
Show resolved Hide resolved
<AnalysisLevel>latest-all</AnalysisLevel>
</PropertyGroup>

<!--Do not run ApiCompat for netstandard2.0 as this is newly added. Remove this property once we have released a stable version.-->
Expand All @@ -17,8 +16,13 @@

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="$(MicrosoftExtensionsHostingAbstractionsPkgVer)" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry\OpenTelemetry.csproj" />
</ItemGroup>

<ItemGroup>
<Compile Include="$(RepoRoot)\src\OpenTelemetry.Api\Internal\ExceptionExtensions.cs" Link="Includes\ExceptionExtensions.cs" />
<Compile Include="$(RepoRoot)\src\OpenTelemetry.Api\Internal\Guard.cs" Link="Includes\Guard.cs" />
</ItemGroup>
Expand Down

This file was deleted.

54 changes: 28 additions & 26 deletions src/OpenTelemetry.Extensions.Hosting/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
## Installation

```shell
dotnet add package --prerelease OpenTelemetry.Extensions.Hosting
dotnet add package OpenTelemetry.Extensions.Hosting
```

## Overview
Expand All @@ -21,7 +21,7 @@ and metrics (`MeterProvider`) in [ASP.NET

## Extension method reference

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

Targeting `OpenTelemetry.OpenTelemetryBuilder`:

Expand All @@ -30,7 +30,32 @@ Targeting `OpenTelemetry.OpenTelemetryBuilder`:
to automatically start tracing and/or metric services in the supplied
[IServiceCollection](https://learn.microsoft.com/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection).

### Obsolete OpenTelemetry SDK pre-1.4.0 extensions
#### Usage

The following example shows how to register OpenTelemetry tracing & metrics in
an ASP.NET Core host using the OpenTelemetry.Extensions.Hosting extensions.

```csharp
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using OpenTelemetry.Metrics;
using OpenTelemetry.Trace;

var appBuilder = WebApplication.CreateBuilder(args);

appBuilder.Services.AddOpenTelemetry()
.WithTracing(builder => builder.AddConsoleExporter())
.WithMetrics(builder => builder.AddConsoleExporter())
.StartWithHost();

var app = appBuilder.Build();

app.Run();
```

### OpenTelemetry SDK v1.3.0 and older extensions

**Note:** The below extension methods were removed in v1.4.0.

**Note:** The below extension methods should be called by application host code
only. Library authors see: [Registration extension method guidance for library
Expand All @@ -57,29 +82,6 @@ Targeting `Microsoft.Extensions.DependencyInjection.IServiceCollection`:
to automatically start metric services in the supplied
[IServiceCollection](https://learn.microsoft.com/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection).

## Usage

The following example shows how to register OpenTelemetry tracing & metrics in
an ASP.NET Core host using the OpenTelemetry.Extensions.Hosting extensions.

```csharp
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using OpenTelemetry.Metrics;
using OpenTelemetry.Trace;

var appBuilder = WebApplication.CreateBuilder(args);

appBuilder.Services.AddOpenTelemetry()
.WithTracing(builder => builder.AddConsoleExporter())
.WithMetrics(builder => builder.AddConsoleExporter())
.StartWithHost();

var app = appBuilder.Build();

app.Run();
```

## References

* [OpenTelemetry Project](https://opentelemetry.io/)
Loading