diff --git a/src/OpenTelemetry/BatchLogRecordExportProcessor.cs b/src/OpenTelemetry/BatchLogRecordExportProcessor.cs index c94abd6a973..d06089b8b44 100644 --- a/src/OpenTelemetry/BatchLogRecordExportProcessor.cs +++ b/src/OpenTelemetry/BatchLogRecordExportProcessor.cs @@ -14,7 +14,6 @@ // limitations under the License. // -#if NET461 || NETSTANDARD2_0 using OpenTelemetry.Logs; namespace OpenTelemetry @@ -44,4 +43,3 @@ public override void OnEnd(LogRecord data) } } } -#endif diff --git a/src/OpenTelemetry/CHANGELOG.md b/src/OpenTelemetry/CHANGELOG.md index 108419d6e85..3edf87d84c5 100644 --- a/src/OpenTelemetry/CHANGELOG.md +++ b/src/OpenTelemetry/CHANGELOG.md @@ -9,6 +9,9 @@ please check the latest changes ## Unreleased +* Removes .NET Framework 4.5.2, .NET 4.6 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 diff --git a/src/OpenTelemetry/Internal/DateTimeOffsetExtensions.net452.cs b/src/OpenTelemetry/Internal/DateTimeOffsetExtensions.net452.cs deleted file mode 100644 index 9aba76103b5..00000000000 --- a/src/OpenTelemetry/Internal/DateTimeOffsetExtensions.net452.cs +++ /dev/null @@ -1,75 +0,0 @@ -// -// Copyright The OpenTelemetry Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#if NET452 -using System; -using System.Globalization; - -namespace OpenTelemetry.Internal -{ - internal static class DateTimeOffsetExtensions - { - private const int DaysPerYear = 365; - private const int DaysPer4Years = (DaysPerYear * 4) + 1; // 1461 - private const int DaysPer100Years = (DaysPer4Years * 25) - 1; // 36524 - private const int DaysPer400Years = (DaysPer100Years * 4) + 1; // 146097 - private const int DaysTo1970 = (DaysPer400Years * 4) + (DaysPer100Years * 3) + (DaysPer4Years * 17) + DaysPerYear; // 719,162 - private const int DaysTo10000 = (DaysPer400Years * 25) - 366; // 3652059 - - private const long TicksPerMillisecond = 10000; - private const long TicksPerSecond = TicksPerMillisecond * 1000; - private const long TicksPerMinute = TicksPerSecond * 60; - private const long TicksPerHour = TicksPerMinute * 60; - private const long TicksPerDay = TicksPerHour * 24; - - private const long UnixEpochTicks = TimeSpan.TicksPerDay * DaysTo1970; // 621,355,968,000,000,000 - private const long UnixEpochSeconds = UnixEpochTicks / TimeSpan.TicksPerSecond; // 62,135,596,800 - private const long UnixEpochMilliseconds = UnixEpochTicks / TimeSpan.TicksPerMillisecond; // 62,135,596,800,000 - private const long MinTicks = 0; - private const long MaxTicks = (DaysTo10000 * TicksPerDay) - 1; - - public static long ToUnixTimeMilliseconds(this DateTimeOffset dateTimeOffset) - { - // Truncate sub-millisecond precision before offsetting by the Unix Epoch to avoid - // the last digit being off by one for dates that result in negative Unix times - long milliseconds = dateTimeOffset.Ticks / TimeSpan.TicksPerMillisecond; - return milliseconds - UnixEpochMilliseconds; - } - - public static DateTimeOffset FromUnixTimeMilliseconds(long milliseconds) - { - const long MinMilliseconds = (MinTicks / TimeSpan.TicksPerMillisecond) - UnixEpochMilliseconds; - const long MaxMilliseconds = (MaxTicks / TimeSpan.TicksPerMillisecond) - UnixEpochMilliseconds; - - if (milliseconds < MinMilliseconds || milliseconds > MaxMilliseconds) - { - throw new ArgumentOutOfRangeException( - nameof(milliseconds), - milliseconds, - string.Format(CultureInfo.InvariantCulture, "milliseconds must be between {0} and {1}", MinMilliseconds, MaxMilliseconds)); - } - - long ticks = (milliseconds * TimeSpan.TicksPerMillisecond) + UnixEpochTicks; - return new DateTimeOffset(ticks, TimeSpan.Zero); - } - - public static long ToUnixTimeSeconds(this DateTimeOffset dateTimeOffset) - { - long seconds = dateTimeOffset.Ticks / TimeSpan.TicksPerSecond; - return seconds - UnixEpochSeconds; - } - } -} -#endif diff --git a/src/OpenTelemetry/Internal/OpenTelemetrySdkEventSource.cs b/src/OpenTelemetry/Internal/OpenTelemetrySdkEventSource.cs index ba98e3b72c9..c316b79cfc2 100644 --- a/src/OpenTelemetry/Internal/OpenTelemetrySdkEventSource.cs +++ b/src/OpenTelemetry/Internal/OpenTelemetrySdkEventSource.cs @@ -324,11 +324,8 @@ protected override void OnEventWritten(EventWrittenEventArgs e) { message = e.Message; } -#if NET452 - Debug.WriteLine($"{e.EventSource.Name} - EventId: [{e.EventId}], Message: [{message}]"); -#else + Debug.WriteLine($"{e.EventSource.Name} - EventId: [{e.EventId}], EventName: [{e.EventName}], Message: [{message}]"); -#endif } } #endif diff --git a/src/OpenTelemetry/Internal/SelfDiagnosticsConfigParser.cs b/src/OpenTelemetry/Internal/SelfDiagnosticsConfigParser.cs index e126a6c7c40..e4570e20ae5 100644 --- a/src/OpenTelemetry/Internal/SelfDiagnosticsConfigParser.cs +++ b/src/OpenTelemetry/Internal/SelfDiagnosticsConfigParser.cs @@ -59,11 +59,7 @@ public bool TryGetConfiguration(out string logDirectory, out int fileSizeInKB, o // First check using current working directory if (!File.Exists(configFilePath)) { -#if NET452 - configFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, ConfigFileName); -#else configFilePath = Path.Combine(AppContext.BaseDirectory, ConfigFileName); -#endif // Second check using application base directory if (!File.Exists(configFilePath)) diff --git a/src/OpenTelemetry/Internal/SelfDiagnosticsConfigRefresher.cs b/src/OpenTelemetry/Internal/SelfDiagnosticsConfigRefresher.cs index 4a548a95cb7..9d9153a0513 100644 --- a/src/OpenTelemetry/Internal/SelfDiagnosticsConfigRefresher.cs +++ b/src/OpenTelemetry/Internal/SelfDiagnosticsConfigRefresher.cs @@ -234,13 +234,6 @@ private void OpenLogFile(string newLogDirectory, int newFileSize) null, newFileSize, MemoryMappedFileAccess.ReadWrite, -#if NET452 - // Only .NET Framework 4.5.2 among all .NET Framework versions is lacking a method omitting this - // default value for MemoryMappedFileSecurity. - // https://docs.microsoft.com/dotnet/api/system.io.memorymappedfiles.memorymappedfile.createfromfile?view=netframework-4.5.2 - // .NET Core simply doesn't support this parameter. - null, -#endif HandleInheritability.None, false); this.logDirectory = newLogDirectory; diff --git a/src/OpenTelemetry/Internal/SelfDiagnosticsEventListener.cs b/src/OpenTelemetry/Internal/SelfDiagnosticsEventListener.cs index 923e781a8ac..dfc3c01f1c9 100644 --- a/src/OpenTelemetry/Internal/SelfDiagnosticsEventListener.cs +++ b/src/OpenTelemetry/Internal/SelfDiagnosticsEventListener.cs @@ -55,11 +55,7 @@ public SelfDiagnosticsEventListener(EventLevel logLevel, SelfDiagnosticsConfigRe foreach (var eventSource in eventSources) { -#if NET452 - this.EnableEvents(eventSource, this.logLevel, (EventKeywords)(-1)); -#else this.EnableEvents(eventSource, this.logLevel, EventKeywords.All); -#endif } } @@ -310,11 +306,7 @@ protected override void OnEventSourceCreated(EventSource eventSource) } } -#if NET452 - this.EnableEvents(eventSource, this.logLevel, (EventKeywords)(-1)); -#else this.EnableEvents(eventSource, this.logLevel, EventKeywords.All); -#endif } base.OnEventSourceCreated(eventSource); diff --git a/src/OpenTelemetry/Logs/LogRecord.cs b/src/OpenTelemetry/Logs/LogRecord.cs index 5efb6947a41..a0aa6fff8c0 100644 --- a/src/OpenTelemetry/Logs/LogRecord.cs +++ b/src/OpenTelemetry/Logs/LogRecord.cs @@ -14,7 +14,6 @@ // limitations under the License. // -#if NET461 || NETSTANDARD2_0 using System; using System.Collections.Generic; using System.Diagnostics; @@ -174,4 +173,3 @@ public ScopeForEachState(Action callback, TState state) } } } -#endif diff --git a/src/OpenTelemetry/Logs/LogRecordScope.cs b/src/OpenTelemetry/Logs/LogRecordScope.cs index 5c99dbdd791..c322ef7abe0 100644 --- a/src/OpenTelemetry/Logs/LogRecordScope.cs +++ b/src/OpenTelemetry/Logs/LogRecordScope.cs @@ -14,7 +14,6 @@ // limitations under the License. // -#if NET461 || NETSTANDARD2_0 using System; using System.Collections; using System.Collections.Generic; @@ -97,4 +96,3 @@ public void Reset() } } } -#endif diff --git a/src/OpenTelemetry/Logs/OpenTelemetryLogger.cs b/src/OpenTelemetry/Logs/OpenTelemetryLogger.cs index 69ef50c9ddd..bc0cfeb25ba 100644 --- a/src/OpenTelemetry/Logs/OpenTelemetryLogger.cs +++ b/src/OpenTelemetry/Logs/OpenTelemetryLogger.cs @@ -14,7 +14,6 @@ // limitations under the License. // -#if NET461 || NETSTANDARD2_0 using System; using System.Collections.Generic; using System.Runtime.CompilerServices; @@ -93,4 +92,3 @@ private IReadOnlyList> ParseState(TState st } } } -#endif diff --git a/src/OpenTelemetry/Logs/OpenTelemetryLoggerOptions.cs b/src/OpenTelemetry/Logs/OpenTelemetryLoggerOptions.cs index f1e09804c4d..2ef00398638 100644 --- a/src/OpenTelemetry/Logs/OpenTelemetryLoggerOptions.cs +++ b/src/OpenTelemetry/Logs/OpenTelemetryLoggerOptions.cs @@ -14,7 +14,6 @@ // limitations under the License. // -#if NET461 || NETSTANDARD2_0 using System; using System.Collections.Generic; using OpenTelemetry.Resources; @@ -83,4 +82,3 @@ public OpenTelemetryLoggerOptions SetResourceBuilder(ResourceBuilder resourceBui } } } -#endif diff --git a/src/OpenTelemetry/Logs/OpenTelemetryLoggerProvider.cs b/src/OpenTelemetry/Logs/OpenTelemetryLoggerProvider.cs index 6fe39c7aca4..16d0f1f6b0d 100644 --- a/src/OpenTelemetry/Logs/OpenTelemetryLoggerProvider.cs +++ b/src/OpenTelemetry/Logs/OpenTelemetryLoggerProvider.cs @@ -14,7 +14,6 @@ // limitations under the License. // -#if NET461 || NETSTANDARD2_0 using System; using System.Collections; using Microsoft.Extensions.Logging; @@ -142,4 +141,3 @@ protected override void Dispose(bool disposing) } } } -#endif diff --git a/src/OpenTelemetry/Logs/OpenTelemetryLoggingExtensions.cs b/src/OpenTelemetry/Logs/OpenTelemetryLoggingExtensions.cs index 216cf329c0a..5e957170bf7 100644 --- a/src/OpenTelemetry/Logs/OpenTelemetryLoggingExtensions.cs +++ b/src/OpenTelemetry/Logs/OpenTelemetryLoggingExtensions.cs @@ -14,7 +14,6 @@ // limitations under the License. // -#if NET461 || NETSTANDARD2_0 using System; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; @@ -46,4 +45,3 @@ public static ILoggingBuilder AddOpenTelemetry(this ILoggingBuilder builder, Act } } } -#endif diff --git a/src/OpenTelemetry/OpenTelemetry.csproj b/src/OpenTelemetry/OpenTelemetry.csproj index 7db4596ba98..63ccf44e246 100644 --- a/src/OpenTelemetry/OpenTelemetry.csproj +++ b/src/OpenTelemetry/OpenTelemetry.csproj @@ -1,6 +1,6 @@  - netstandard2.0;net452;net46;net461 + netstandard2.0;net461 OpenTelemetry .NET SDK