diff --git a/src/BugsnagUnity/PerformanceHelper.cs b/src/BugsnagUnity/PerformanceHelper.cs index 145aa5dc..2e899f3c 100644 --- a/src/BugsnagUnity/PerformanceHelper.cs +++ b/src/BugsnagUnity/PerformanceHelper.cs @@ -1,4 +1,3 @@ -//#define PERFORMANCE_HELPER_LOG using System; using System.Linq; using System.Reflection; @@ -15,7 +14,7 @@ internal class PerformanceHelper static MethodInfo _getPerformanceStateMethodInfo; private static bool _isPerformanceLibraryAvailable = true; - [Serializable] + [Serializable] private class PerformanceState { public string currentContextSpanId; @@ -25,60 +24,41 @@ public PerformanceState(string currentContextSpanId, string currentContextTraceI this.currentContextSpanId = currentContextSpanId; this.currentContextTraceId = currentContextTraceId; } - } + } internal static Correlation GetCurrentPerformanceSpanContext() { - Log("Entering GetCurrentPerformanceSpanContext"); - if (!_isPerformanceLibraryAvailable) { - Log("Performance library is not available"); return null; } try { - Log("Initializing GetCurrentContextInternalMethod if needed"); InitializeGetCurrentContextInternalMethodIfNeeded(); - Log("Invoking _getCurrentContextInternalMethod"); string result = (string)_getPerformanceStateMethodInfo?.Invoke(null, null); - Log("Result from _getCurrentContextInternalMethod: " + result); - if (string.IsNullOrEmpty(result)) { - Log("Result is null or empty"); return null; } - Log("Parsing result to CorrelationTransfer"); var performanceState = JsonUtility.FromJson(result); if (performanceState == null) { - Log("Deserialization failed, CorrelationTransfer is null"); return null; } - Log("Performance library context: traceId=" + performanceState.currentContextTraceId + ", spanId=" + performanceState.currentContextSpanId); - var correlation = new Correlation(performanceState.currentContextTraceId, performanceState.currentContextSpanId); - Log("Performance library correlation: spanId=" + correlation.SpanId + ", traceId=" + correlation.TraceId); - - Log("Exiting GetCurrentPerformanceSpanContext with correlation"); return correlation; } catch (Exception ex) { - Log("Exception caught: " + ex.Message); // Silently handle case where performance library is not available or out of date - Log("Performance library is not available or out of date"); _isPerformanceLibraryAvailable = false; - - Log("Exiting GetCurrentPerformanceSpanContext with null due to exception"); return null; } } @@ -92,16 +72,10 @@ private static void InitializeGetCurrentContextInternalMethodIfNeeded() .FirstOrDefault(type => type != null); _getPerformanceStateMethodInfo = bugsnagPerformanceType?.GetMethod( - GET_PERFORMANCE_STATE_METHOD_NAME, + GET_PERFORMANCE_STATE_METHOD_NAME, BindingFlags.NonPublic | BindingFlags.Static ); } - private static void Log(string message) - { - #if PERFORMANCE_HELPER_LOG - UnityEngine.Debug.Log(message); - #endif - } } }