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

Remove Net452 from API project #2164

Merged
merged 1 commit into from
Jul 20, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
override OpenTelemetry.Context.AsyncLocalRuntimeContextSlot<T>.Get() -> T
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these were part of netstandard2.0 already and now it'll be part of net461 as well. since we haven't shipped this in net461, putting this under unshipped.txt

override OpenTelemetry.Context.AsyncLocalRuntimeContextSlot<T>.Set(T value) -> void
OpenTelemetry.Context.AsyncLocalRuntimeContextSlot<T>
OpenTelemetry.Context.AsyncLocalRuntimeContextSlot<T>.AsyncLocalRuntimeContextSlot(string name) -> void
3 changes: 3 additions & 0 deletions src/OpenTelemetry.Api/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
// limitations under the License.
// </copyright>

#if !NET452
using System.Runtime.CompilerServices;
using System.Threading;

Expand Down Expand Up @@ -53,4 +52,3 @@ public override void Set(T value)
}
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// limitations under the License.
// </copyright>

#if NET452
#if NET461
using System.Collections;
using System.Reflection;
using System.Runtime.CompilerServices;
Expand Down
4 changes: 0 additions & 4 deletions src/OpenTelemetry.Api/Context/RuntimeContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,7 @@ public static class RuntimeContext
/// <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.
Expand Down
8 changes: 7 additions & 1 deletion src/OpenTelemetry.Api/OpenTelemetry.Api.csproj
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net452</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net461</TargetFrameworks>
<Description>OpenTelemetry .NET API</Description>
<RootNamespace>OpenTelemetry</RootNamespace>

<NoWarn>$(NoWarn),CS0618</NoWarn>
<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)" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
25 changes: 0 additions & 25 deletions src/OpenTelemetry.Exporter.Zipkin/ZipkinExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,7 @@
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;
Expand All @@ -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>
Expand All @@ -53,9 +47,7 @@ public class ZipkinExporter : BaseExporter<Activity>
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();
}

Expand Down Expand Up @@ -196,12 +188,7 @@ private class JsonContent : HttpContent

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)
{
Expand All @@ -213,10 +200,6 @@ public JsonContent(ZipkinExporter exporter, in Batch<Activity> batch)

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);
Expand All @@ -225,7 +208,6 @@ protected override Task SerializeToStreamAsync(Stream stream, TransportContext c
{
this.writer.Reset(stream);
}
#endif

this.writer.WriteStartArray();

Expand All @@ -236,23 +218,16 @@ protected override Task SerializeToStreamAsync(Stream stream, TransportContext c
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)
Expand Down
4 changes: 0 additions & 4 deletions src/OpenTelemetry.Exporter.Zipkin/ZipkinExporterOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -39,12 +37,10 @@ public sealed class ZipkinExporterOptions
/// </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.
Expand Down