protected override void RecordMessageInternal(
            string eventName,
            Guid activityId,
            Guid parentActivityId,
            EventLevel level,
            Keywords keywords,
            EventOpcode opcode,
            string jsonPayload)
        {
            EventSourceOptions options = this.CreateOptions(level, keywords, opcode);

            EventSource.SetCurrentThreadActivityId(activityId);

            if (string.IsNullOrEmpty(jsonPayload))
            {
                jsonPayload = "{}";
            }

            if (string.IsNullOrEmpty(this.ikey))
            {
                Payload payload = new Payload(jsonPayload, this.enlistmentId, this.mountId);
                this.eventSource.Write(eventName, ref options, ref activityId, ref parentActivityId, ref payload);
            }
            else
            {
                PayloadWithIKey payload = new PayloadWithIKey(jsonPayload, this.enlistmentId, this.mountId, this.ikey);
                this.eventSource.Write(eventName, ref options, ref activityId, ref parentActivityId, ref payload);
            }
        }
        protected override void RecordMessageInternal(
            string eventName,
            Guid activityId,
            Guid parentActivityId,
            EventLevel level,
            Keywords keywords,
            EventOpcode opcode,
            string jsonPayload)
        {
            EventSourceOptions options = this.CreateOptions(level, keywords, opcode);

            EventSource.SetCurrentThreadActivityId(activityId);

            if (jsonPayload != null)
            {
                JsonPayload payload = new JsonPayload(jsonPayload);
                this.eventSource.Write(eventName, ref options, ref activityId, ref parentActivityId, ref payload);
            }
            else
            {
                EmptyStruct payload = new EmptyStruct();
                this.eventSource.Write(eventName, ref options, ref activityId, ref parentActivityId, ref payload);
            }
        }
        private EventSourceOptions CreateOptions(EventLevel level, Keywords keywords, EventOpcode opcode)
        {
            EventSourceOptions options = new EventSourceOptions();

            options.Keywords  = (EventKeywords)keywords;
            options.Keywords |= (EventKeywords)MeasureKeyword;

            options.Level  = (Microsoft.Diagnostics.Tracing.EventLevel)level;
            options.Opcode = (Microsoft.Diagnostics.Tracing.EventOpcode)opcode;

            return(options);
        }