Skip to content

Add netstandard2.0 compatibility to Microsoft.Extensions.Telemetry and dependencies #6218

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<RootNamespace>Microsoft.Extensions.AmbientMetadata</RootNamespace>
<TargetFrameworks>$(NetCoreTargetFrameworks);netstandard2.0;</TargetFrameworks>
<Description>Runtime information provider for application-level ambient metadata.</Description>
<Workstream>Telemetry</Workstream>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<RootNamespace>Microsoft.Extensions.DependencyInjection</RootNamespace>
<TargetFrameworks>$(NetCoreTargetFrameworks);netstandard2.0;</TargetFrameworks>
<Description>Extensions to auto-activate registered singletons in the dependency injection system.</Description>
<Workstream>Fundamentals</Workstream>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<RootNamespace>Microsoft.Extensions.Telemetry</RootNamespace>
<TargetFrameworks>$(NetCoreTargetFrameworks);netstandard2.0;</TargetFrameworks>
<Description>Common abstractions for high-level telemetry primitives.</Description>
<Workstream>Telemetry</Workstream>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<RootNamespace>Microsoft.Extensions.Diagnostics</RootNamespace>
<TargetFrameworks>$(NetCoreTargetFrameworks);netstandard2.0;</TargetFrameworks>
<Description>Provides canonical implementations of telemetry abstractions.</Description>
<Workstream>Telemetry</Workstream>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

using System;
using System.Linq;
#if !NETFRAMEWORK
#if !NETFRAMEWORK && !NETSTANDARD
using System.Security.Cryptography;
#endif
using Microsoft.Extensions.Logging;
Expand All @@ -22,7 +22,7 @@ internal sealed class RandomProbabilisticSampler : LoggingSampler, IDisposable
{
internal RandomProbabilisticSamplerFilterRule[] LastKnownGoodSamplerRules;

#if NETFRAMEWORK
#if NETFRAMEWORK || NETSTANDARD
private static readonly System.Threading.ThreadLocal<Random> _randomInstance = new(() => new Random());
#endif

Expand Down Expand Up @@ -50,7 +50,7 @@ public override bool ShouldSample<TState>(in LogEntry<TState> logEntry)
return true;
}

#if NETFRAMEWORK
#if NETFRAMEWORK || NETSTANDARD
return _randomInstance.Value!.Next(int.MaxValue) < int.MaxValue * probability;
#else
return RandomNumberGenerator.GetInt32(int.MaxValue) < int.MaxValue * probability;
Expand Down
Loading