public void LogMessage(Activity?activity, string category, LogLevel level, EventId eventId, int threadId, string message, Exception?exception)
        {
            if (!IsEnabled(level))
            {
                return;
            }

            // NOTE: Currently, we're not doing anything with the exception as the message when an exception is logged will already contain the exception details.
            // However, in the future, it's possible we might want to log details, such as exception type or exception message, in separate columns.

            Guid   partitionId     = m_serviceContext.PartitionId;
            long   replicaId       = m_serviceContext.ReplicaOrInstanceId;
            string applicationName = m_executionContext.ApplicationName;
            string serviceName     = m_executionContext.ServiceName;
            string buildVersion    = m_executionContext.BuildVersion;
            string machineId       = m_executionContext.MachineId;

            string tagName = eventId.Name ?? string.Empty;
            // In case if tag created using Tag.Create (line number and file in description) it's better to display decimal number
            string tagId = string.IsNullOrWhiteSpace(eventId.Name)
#pragma warning disable CS0618 // Need to be used for to process reserved tags from GitTagger
                                ? eventId.ToTagId()
#pragma warning restore CS0618
                                : eventId.Id.ToString(CultureInfo.InvariantCulture);

            string          activityId            = string.Empty;
            ActivityTraceId activityTraceId       = default;
            Guid            obsoleteCorrelationId = Guid.Empty;
            uint            obsoleteTransactionId = 0u;

            if (activity != null)
            {
                activityId      = activity.Id ?? string.Empty;
                activityTraceId = activity.TraceId;

                if (m_options.Value.AddObsoleteCorrelationToActivity)
                {
#pragma warning disable CS0618 // We are using obsolete correlation to support logging correlation from old Omex services
                    obsoleteCorrelationId = activity.GetObsoleteCorrelationId() ?? Guid.Empty;
                    obsoleteTransactionId = activity.GetObsolteteTransactionId() ?? 0u;
#pragma warning restore CS0618
                }
            }

            string traceIdAsString = activityTraceId.ToHexString();

            //Event methods should have all information as parameters so we are passing them each time
            // Posible Breaking changes:
            // 1. ThreadId type Changed from string to avoid useless string creation
            // 2. New fileds added:
            //  a. tagName to events since it will have more useful information
            //  b. activityId required for tracking net core activity
            //  c. activityTraceId required for tracking net core activity
            switch (level)
            {
            case LogLevel.None:
                break;

            case LogLevel.Trace:
                m_eventSource.LogSpamServiceMessage(applicationName, serviceName, machineId, buildVersion, s_processName, partitionId, replicaId,
                                                    activityId, traceIdAsString, obsoleteCorrelationId, obsoleteTransactionId, "Spam", category, tagId, tagName, threadId, message);
                break;

            case LogLevel.Debug:
                m_eventSource.LogVerboseServiceMessage(applicationName, serviceName, machineId, buildVersion, s_processName, partitionId, replicaId,
                                                       activityId, traceIdAsString, obsoleteCorrelationId, obsoleteTransactionId, "Verbose", category, tagId, tagName, threadId, message);
                break;

            case LogLevel.Information:
                m_eventSource.LogInfoServiceMessage(applicationName, serviceName, machineId, buildVersion, s_processName, partitionId, replicaId,
                                                    activityId, traceIdAsString, obsoleteCorrelationId, obsoleteTransactionId, "Info", category, tagId, tagName, threadId, message);
                break;

            case LogLevel.Warning:
                m_eventSource.LogWarningServiceMessage(applicationName, serviceName, machineId, buildVersion, s_processName, partitionId, replicaId,
                                                       activityId, traceIdAsString, obsoleteCorrelationId, obsoleteTransactionId, "Warning", category, tagId, tagName, threadId, message);
                break;

            case LogLevel.Error:
            case LogLevel.Critical:
                m_eventSource.LogErrorServiceMessage(applicationName, serviceName, machineId, buildVersion, s_processName, partitionId, replicaId,
                                                     activityId, traceIdAsString, obsoleteCorrelationId, obsoleteTransactionId, "Error", category, tagId, tagName, threadId, message);
                break;

            default:
                throw new ArgumentException(FormattableString.Invariant($"Unknown EventLevel: {level}"));
            }
        }