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 NET46 from OpenTelemetry sdk #2163

Merged
merged 2 commits into from
Jul 20, 2021
Merged
Show file tree
Hide file tree
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
2 changes: 0 additions & 2 deletions src/OpenTelemetry/BatchLogRecordExportProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
// limitations under the License.
// </copyright>

#if NET461 || NETSTANDARD2_0
using OpenTelemetry.Logs;

namespace OpenTelemetry
Expand Down Expand Up @@ -44,4 +43,3 @@ public override void OnEnd(LogRecord data)
}
}
}
#endif
3 changes: 3 additions & 0 deletions src/OpenTelemetry/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, .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
Expand Down
75 changes: 0 additions & 75 deletions src/OpenTelemetry/Internal/DateTimeOffsetExtensions.net452.cs

This file was deleted.

6 changes: 1 addition & 5 deletions src/OpenTelemetry/Internal/OpenTelemetrySdkEventSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -324,11 +324,7 @@ 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
Debug.WriteLine($"{e.EventSource.Name} - EventId: [{e.EventId}], EventName: [{e.EventName}], Message: [{message}]");
cijothomas marked this conversation as resolved.
Show resolved Hide resolved
}
}
#endif
Expand Down
4 changes: 0 additions & 4 deletions src/OpenTelemetry/Internal/SelfDiagnosticsConfigParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 0 additions & 8 deletions src/OpenTelemetry/Internal/SelfDiagnosticsEventListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,7 @@ public SelfDiagnosticsEventListener(EventLevel logLevel, SelfDiagnosticsConfigRe

foreach (var eventSource in eventSources)
{
#if NET452
this.EnableEvents(eventSource, this.logLevel, (EventKeywords)(-1));
Copy link
Member

@reyang reyang Jul 20, 2021

Choose a reason for hiding this comment

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

Finally 👍

IIRC there are many places where we have (EventKeywords)(-1) (check out this link), probably not fully covered by this PR. Can be a separate PR though - up to you 😺

#else
this.EnableEvents(eventSource, this.logLevel, EventKeywords.All);
#endif
}
}

Expand Down Expand Up @@ -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);
Expand Down
2 changes: 0 additions & 2 deletions src/OpenTelemetry/Logs/LogRecord.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
// limitations under the License.
// </copyright>

#if NET461 || NETSTANDARD2_0
using System;
using System.Collections.Generic;
using System.Diagnostics;
Expand Down Expand Up @@ -174,4 +173,3 @@ public ScopeForEachState(Action<LogRecordScope, TState> callback, TState state)
}
}
}
#endif
2 changes: 0 additions & 2 deletions src/OpenTelemetry/Logs/LogRecordScope.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
// limitations under the License.
// </copyright>

#if NET461 || NETSTANDARD2_0
using System;
using System.Collections;
using System.Collections.Generic;
Expand Down Expand Up @@ -97,4 +96,3 @@ public void Reset()
}
}
}
#endif
2 changes: 0 additions & 2 deletions src/OpenTelemetry/Logs/OpenTelemetryLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
// limitations under the License.
// </copyright>

#if NET461 || NETSTANDARD2_0
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
Expand Down Expand Up @@ -93,4 +92,3 @@ private IReadOnlyList<KeyValuePair<string, object>> ParseState<TState>(TState st
}
}
}
#endif
2 changes: 0 additions & 2 deletions src/OpenTelemetry/Logs/OpenTelemetryLoggerOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
// limitations under the License.
// </copyright>

#if NET461 || NETSTANDARD2_0
using System;
using System.Collections.Generic;
using OpenTelemetry.Resources;
Expand Down Expand Up @@ -83,4 +82,3 @@ public OpenTelemetryLoggerOptions SetResourceBuilder(ResourceBuilder resourceBui
}
}
}
#endif
2 changes: 0 additions & 2 deletions src/OpenTelemetry/Logs/OpenTelemetryLoggerProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
// limitations under the License.
// </copyright>

#if NET461 || NETSTANDARD2_0
using System;
using System.Collections;
using Microsoft.Extensions.Logging;
Expand Down Expand Up @@ -142,4 +141,3 @@ protected override void Dispose(bool disposing)
}
}
}
#endif
2 changes: 0 additions & 2 deletions src/OpenTelemetry/Logs/OpenTelemetryLoggingExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
// limitations under the License.
// </copyright>

#if NET461 || NETSTANDARD2_0
using System;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
Expand Down Expand Up @@ -46,4 +45,3 @@ public static ILoggingBuilder AddOpenTelemetry(this ILoggingBuilder builder, Act
}
}
}
#endif
10 changes: 1 addition & 9 deletions src/OpenTelemetry/OpenTelemetry.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net452;net46;net461</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net461</TargetFrameworks>
Copy link
Member

Choose a reason for hiding this comment

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

After this PR we might be able to consolidate these TargetFrameworks (e.g. using the default setting in the top level .props file).

<Description>OpenTelemetry .NET SDK</Description>
<!--
TODO: Disable this exception, and actually do document all public API.
Expand All @@ -12,14 +12,6 @@
<ItemGroup>
<PackageReference Include="System.Collections.Immutable" Version="$(SystemCollectionsImmutablePkgVer)" />
<PackageReference Include="System.Reflection.Emit.Lightweight" Version="$(SystemReflectionEmitLightweightPkgVer)" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net461'">
<PackageReference Include="Microsoft.Extensions.Logging" Version="$(MicrosoftExtensionsLoggingPkgVer)" />
<PackageReference Include="Microsoft.Extensions.Logging.Configuration" Version="$(MicrosoftExtensionsLoggingConfigurationPkgVer)" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="Microsoft.Extensions.Logging" Version="$(MicrosoftExtensionsLoggingPkgVer)" />
<PackageReference Include="Microsoft.Extensions.Logging.Configuration" Version="$(MicrosoftExtensionsLoggingConfigurationPkgVer)" />
</ItemGroup>
Expand Down
4 changes: 0 additions & 4 deletions src/OpenTelemetry/ProviderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
// limitations under the License.
// </copyright>

#if NET461 || NETSTANDARD2_0
using OpenTelemetry.Logs;
#endif
using OpenTelemetry.Resources;
using OpenTelemetry.Trace;

Expand All @@ -38,12 +36,10 @@ public static Resource GetResource(this BaseProvider baseProvider)
{
return tracerProviderSdk.Resource;
}
#if NET461 || NETSTANDARD2_0
else if (baseProvider is OpenTelemetryLoggerProvider otelLoggerProvider)
{
return otelLoggerProvider.Resource;
}
#endif

return Resource.Empty;
}
Expand Down
2 changes: 0 additions & 2 deletions src/OpenTelemetry/SimpleLogRecordExportProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
// limitations under the License.
// </copyright>

#if NET461 || NETSTANDARD2_0
using OpenTelemetry.Logs;

namespace OpenTelemetry
Expand All @@ -27,4 +26,3 @@ public SimpleLogRecordExportProcessor(BaseExporter<LogRecord> exporter)
}
}
}
#endif