From d7252780626540680defbbdf1387129a2eb1e417 Mon Sep 17 00:00:00 2001
From: Marty T <120425148+tippmar-nr@users.noreply.github.com>
Date: Tue, 20 Aug 2024 14:43:45 -0500
Subject: [PATCH] chore: Update Serilog to latest (#2694)
* Updated Serilog to latest everywhere
* Fix ilrepack issues for serilog
* Refactor GuidGenerator to work around ILRepack of System.Diagnostics.DiagnosticSource
* Null checking
* Visibility bypasser caching
---
src/Agent/NewRelic/Agent/Core/Core.csproj | 19 ++--
.../Agent/Core/Utilities/GuidGenerator.cs | 90 +++++++++++++++----
.../NewRelic.Agent.TestUtilities.csproj | 6 +-
3 files changed, 88 insertions(+), 27 deletions(-)
diff --git a/src/Agent/NewRelic/Agent/Core/Core.csproj b/src/Agent/NewRelic/Agent/Core/Core.csproj
index 9a792198f..9c95c4286 100644
--- a/src/Agent/NewRelic/Agent/Core/Core.csproj
+++ b/src/Agent/NewRelic/Agent/Core/Core.csproj
@@ -43,12 +43,12 @@
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
-
-
+
+
+
+
-
+
all
@@ -56,6 +56,7 @@
+
@@ -79,7 +80,6 @@
-
@@ -110,6 +110,9 @@
+
+
+
@@ -132,8 +135,8 @@
- 18
- 15
+ 20
+ 17
diff --git a/src/Agent/NewRelic/Agent/Core/Utilities/GuidGenerator.cs b/src/Agent/NewRelic/Agent/Core/Utilities/GuidGenerator.cs
index a3c3f5c12..617db6611 100644
--- a/src/Agent/NewRelic/Agent/Core/Utilities/GuidGenerator.cs
+++ b/src/Agent/NewRelic/Agent/Core/Utilities/GuidGenerator.cs
@@ -2,14 +2,14 @@
// SPDX-License-Identifier: Apache-2.0
using NewRelic.Agent.Extensions.Logging;
+using NewRelic.Reflection;
using System;
-using System.Diagnostics;
-using System.IO;
using System.Security.Cryptography;
using System.Threading;
namespace NewRelic.Agent.Core.Utilities
{
+ [NrExcludeFromCodeCoverage]
public static class GuidGenerator
{
/// Our testing shows that RngCryptoServiceProvider library is threadsafe and is more performant
@@ -17,6 +17,15 @@ public static class GuidGenerator
private static readonly RNGCryptoServiceProvider RngCryptoServiceProvider = new RNGCryptoServiceProvider();
private static Func _traceGeneratorFunc = GetTraceIdFromCurrentActivity;
+ private static bool _initialized;
+ private static object _lockObj = new();
+ private static bool _hasDiagnosticSourceReference;
+
+ private static Func