Remove Net452 from API project (#2164)

This commit is contained in:
Cijo Thomas 2021-07-19 23:30:52 -07:00 committed by GitHub
parent d894c16f36
commit bb08e7b914
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 16 additions and 38 deletions

View File

@ -0,0 +1,4 @@
override OpenTelemetry.Context.AsyncLocalRuntimeContextSlot<T>.Get() -> T
override OpenTelemetry.Context.AsyncLocalRuntimeContextSlot<T>.Set(T value) -> void
OpenTelemetry.Context.AsyncLocalRuntimeContextSlot<T>
OpenTelemetry.Context.AsyncLocalRuntimeContextSlot<T>.AsyncLocalRuntimeContextSlot(string name) -> void

View File

@ -9,6 +9,9 @@ please check the latest changes
## Unreleased
* Removes .NET Framework 4.5.2 support. The minimum .NET Framework
version supported is .NET 4.6.1. ([#2138](https://github.com/open-telemetry/opentelemetry-dotnet/issues/2138))
## 1.1.0
Released 2021-Jul-12

View File

@ -14,7 +14,6 @@
// limitations under the License.
// </copyright>
#if !NET452
using System.Runtime.CompilerServices;
using System.Threading;
@ -53,4 +52,3 @@ namespace OpenTelemetry.Context
}
}
}
#endif

View File

@ -14,7 +14,7 @@
// limitations under the License.
// </copyright>
#if NET452
#if NET461
using System.Collections;
using System.Reflection;
using System.Runtime.CompilerServices;

View File

@ -30,11 +30,7 @@ namespace OpenTelemetry.Context
/// <summary>
/// Gets or sets the actual context carrier implementation.
/// </summary>
#if !NET452
public static Type ContextSlotType { get; set; } = typeof(AsyncLocalRuntimeContextSlot<>);
#else
public static Type ContextSlotType { get; set; } = typeof(RemotingRuntimeContextSlot<>);
#endif
/// <summary>
/// Register a named context slot.

View File

@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net452</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net461</TargetFrameworks>
<Description>OpenTelemetry .NET API</Description>
<RootNamespace>OpenTelemetry</RootNamespace>
@ -8,6 +8,12 @@
<MinVerTagPrefix>core-</MinVerTagPrefix>
</PropertyGroup>
<!--Do not run ApiCopmat for net461 as this is newly added. There is no existing contract for net461 against which we could compare the implementation.
Remove this property once we have released a stable net461 version.-->
<PropertyGroup Condition="'$(TargetFramework)' == 'net461'">
<RunApiCompat>false</RunApiCompat>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="$(SystemDiagnosticSourcePkgVer)" />
<PackageReference Include="System.Reflection.Emit.Lightweight" Version="$(SystemReflectionEmitLightweightPkgVer)" />

View File

@ -22,7 +22,7 @@
<ItemGroup>
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry\OpenTelemetry.csproj" />
<PackageReference Include="System.Text.Json" Version="$(SystemTextJsonPkgVer)" Condition="'$(TargetFramework)' != 'net452'" />
<PackageReference Include="System.Text.Json" Version="$(SystemTextJsonPkgVer)" />
</ItemGroup>
</Project>

View File

@ -22,11 +22,7 @@ using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Net.Sockets;
#if NET452
using Newtonsoft.Json;
#else
using System.Text.Json;
#endif
using System.Threading;
using System.Threading.Tasks;
using OpenTelemetry.Exporter.Zipkin.Implementation;
@ -40,9 +36,7 @@ namespace OpenTelemetry.Exporter
public class ZipkinExporter : BaseExporter<Activity>
{
private readonly ZipkinExporterOptions options;
#if !NET452
private readonly int maxPayloadSizeInBytes;
#endif
private readonly HttpClient httpClient;
/// <summary>
@ -53,9 +47,7 @@ namespace OpenTelemetry.Exporter
public ZipkinExporter(ZipkinExporterOptions options, HttpClient client = null)
{
this.options = options ?? throw new ArgumentNullException(nameof(options));
#if !NET452
this.maxPayloadSizeInBytes = (!options.MaxPayloadSizeInBytes.HasValue || options.MaxPayloadSizeInBytes <= 0) ? ZipkinExporterOptions.DefaultMaxPayloadSizeInBytes : options.MaxPayloadSizeInBytes.Value;
#endif
this.httpClient = client ?? new HttpClient();
}
@ -196,12 +188,7 @@ namespace OpenTelemetry.Exporter
private readonly ZipkinExporter exporter;
private readonly Batch<Activity> batch;
#if NET452
private JsonWriter writer;
#else
private Utf8JsonWriter writer;
#endif
public JsonContent(ZipkinExporter exporter, in Batch<Activity> batch)
{
@ -213,10 +200,6 @@ namespace OpenTelemetry.Exporter
protected override Task SerializeToStreamAsync(Stream stream, TransportContext context)
{
#if NET452
StreamWriter streamWriter = new StreamWriter(stream);
this.writer = new JsonTextWriter(streamWriter);
#else
if (this.writer == null)
{
this.writer = new Utf8JsonWriter(stream);
@ -225,7 +208,6 @@ namespace OpenTelemetry.Exporter
{
this.writer.Reset(stream);
}
#endif
this.writer.WriteStartArray();
@ -236,23 +218,16 @@ namespace OpenTelemetry.Exporter
zipkinSpan.Write(this.writer);
zipkinSpan.Return();
#if !NET452
if (this.writer.BytesPending >= this.exporter.maxPayloadSizeInBytes)
{
this.writer.Flush();
}
#endif
}
this.writer.WriteEndArray();
this.writer.Flush();
#if NET452
return Task.FromResult(true);
#else
return Task.CompletedTask;
#endif
}
protected override bool TryComputeLength(out long length)

View File

@ -24,9 +24,7 @@ namespace OpenTelemetry.Exporter
/// </summary>
public sealed class ZipkinExporterOptions
{
#if !NET452
internal const int DefaultMaxPayloadSizeInBytes = 4096;
#endif
/// <summary>
/// Gets or sets Zipkin endpoint address. See https://zipkin.io/zipkin-api/#/default/post_spans.
@ -39,12 +37,10 @@ namespace OpenTelemetry.Exporter
/// </summary>
public bool UseShortTraceIds { get; set; }
#if !NET452
/// <summary>
/// Gets or sets the maximum payload size in bytes. Default value: 4096.
/// </summary>
public int? MaxPayloadSizeInBytes { get; set; } = DefaultMaxPayloadSizeInBytes;
#endif
/// <summary>
/// Gets or sets the export processor type to be used with Zipkin Exporter.