/// <summary>
        /// Initializes the async-aware diagnostic stack, including a domain-wide hook to place the stack on all raised exceptions.
        /// </summary>
        static AsyncDiagnosticStack()
        {
            Stack = new AsyncLocalStack<string>();
            AppDomain.CurrentDomain.FirstChanceException += (_, e) =>
            {
                if (e.Exception.Data.Contains(DataKey))
                    return;

                var sb = new StringBuilder();
                foreach (var context in Current)
                    sb.AppendLine("   " + context);
                var current = sb.ToString();
                if (current != string.Empty)
                    e.Exception.Data.Add(DataKey, current);
            };
        }
        /// <summary>
        /// Initializes the async-aware diagnostic stack, including a domain-wide hook to place the stack on all raised exceptions.
        /// </summary>
        static AsyncDiagnosticStack()
        {
            Stack = new AsyncLocalStack <string>();
            AppDomain.CurrentDomain.FirstChanceException += (_, e) =>
            {
                if (e.Exception.Data.Contains(DataKey))
                {
                    return;
                }

                var sb = new StringBuilder();
                foreach (var context in Current)
                {
                    sb.AppendLine("   " + context);
                }
                var current = sb.ToString();
                if (current != string.Empty)
                {
                    e.Exception.Data.Add(DataKey, current);
                }
            };
        }