< Summary

Class:Microsoft.Azure.EventHubs.ServiceFabricProcessor.EventProcessorEventSource
Assembly:Microsoft.Azure.EventHubs.ServiceFabricProcessor
File(s):C:\Git\azure-sdk-for-net\sdk\eventhub\Microsoft.Azure.EventHubs.ServiceFabricProcessor\src\EventProcessorEventSource.cs
Covered lines:6
Uncovered lines:25
Coverable lines:31
Total lines:124
Line coverage:19.3% (6 of 31)
Covered branches:2
Total branches:6
Branch coverage:33.3% (2 of 6)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.cctor()-100%100%
.ctor()-100%100%
Message(...)-50%50%
Message(...)-66.67%50%
ServiceMessage(...)-0%0%
ServiceMessage(...)-0%100%
ServiceTypeRegistered(...)-0%100%
ServiceHostInitializationFailed(...)-0%100%
ServiceRequestStart(...)-0%100%
ServiceRequestStop(...)-0%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\eventhub\Microsoft.Azure.EventHubs.ServiceFabricProcessor\src\EventProcessorEventSource.cs

#LineLine coverage
 1// Copyright (c) Microsoft. All rights reserved.
 2// Licensed under the MIT license. See LICENSE file in the project root for full license information.using System;
 3
 4namespace Microsoft.Azure.EventHubs.ServiceFabricProcessor
 5{
 6    using System;
 7    using System.Diagnostics.Tracing;
 8    using System.Fabric;
 9
 10    [EventSource(Name = "Microsoft-Azure-EventHubs-ServiceFabricProcessor")]
 11    internal sealed class EventProcessorEventSource : EventSource
 12    {
 213        public static readonly EventProcessorEventSource Current = new EventProcessorEventSource();
 14
 15        // Instance constructor is private to enforce singleton semantics
 416        private EventProcessorEventSource() : base() { }
 17
 18        #region Keywords
 19        // Event keywords can be used to categorize events.
 20        // Each keyword is a bit flag. A single event can be associated with multiple keywords (via EventAttribute.Keywo
 21        // Keywords must be defined as a public class named 'Keywords' inside EventSource that uses them.
 22        public static class Keywords
 23        {
 24            public const EventKeywords Requests = (EventKeywords)0x1L;
 25            public const EventKeywords ServiceInitialization = (EventKeywords)0x2L;
 26        }
 27        #endregion
 28
 29        #region Events
 30        // Define an instance method for each event you want to record and apply an [Event] attribute to it.
 31        // The method name is the name of the event.
 32        // Pass any parameters you want to record with the event (only primitive integer types, DateTime, Guid & string 
 33        // Each event method implementation should check whether the event source is enabled, and if it is, call WriteEv
 34        // The number and types of arguments passed to every event method must exactly match what is passed to WriteEven
 35        // Put [NonEvent] attribute on all methods that do not define an event.
 36        // For more information see https://msdn.microsoft.com/en-us/library/system.diagnostics.tracing.eventsource.aspx
 37
 38        [NonEvent]
 39        public void Message(string message, params object[] args)
 40        {
 441            if (this.IsEnabled())
 42            {
 043                string finalMessage = string.Format(message, args);
 044                Message(finalMessage);
 45            }
 446        }
 47
 48        private const int MessageEventId = 1;
 49        [Event(MessageEventId, Level = EventLevel.Informational, Message = "{0}")]
 50        public void Message(string message)
 51        {
 90052            if (this.IsEnabled())
 53            {
 054                WriteEvent(MessageEventId, message);
 55            }
 90056        }
 57
 58        [NonEvent]
 59        public void ServiceMessage(StatefulServiceContext serviceContext, string message, params object[] args)
 60        {
 061            if (this.IsEnabled())
 62            {
 063                string finalMessage = string.Format(message, args);
 064                ServiceMessage(
 065                    serviceContext.ServiceName.ToString(),
 066                    serviceContext.ServiceTypeName,
 067                    serviceContext.ReplicaId,
 068                    serviceContext.PartitionId,
 069                    serviceContext.CodePackageActivationContext.ApplicationName,
 070                    serviceContext.CodePackageActivationContext.ApplicationTypeName,
 071                    serviceContext.NodeContext.NodeName,
 072                    finalMessage);
 73            }
 074        }
 75
 76        private const int ServiceMessageEventId = 2;
 77        [Event(ServiceMessageEventId, Level = EventLevel.Informational, Message = "{7}")]
 78        private
 79        void ServiceMessage(
 80            string serviceName,
 81            string serviceTypeName,
 82            long replicaOrInstanceId,
 83            Guid partitionId,
 84            string applicationName,
 85            string applicationTypeName,
 86            string nodeName,
 87            string message)
 88        {
 089            WriteEvent(ServiceMessageEventId, serviceName, serviceTypeName, replicaOrInstanceId, partitionId, applicatio
 090        }
 91
 92        private const int ServiceTypeRegisteredEventId = 3;
 93        [Event(ServiceTypeRegisteredEventId, Level = EventLevel.Informational, Message = "Service host process {0} regis
 94        public void ServiceTypeRegistered(int hostProcessId, string serviceType)
 95        {
 096            WriteEvent(ServiceTypeRegisteredEventId, hostProcessId, serviceType);
 097        }
 98
 99        private const int ServiceHostInitializationFailedEventId = 4;
 100        [Event(ServiceHostInitializationFailedEventId, Level = EventLevel.Error, Message = "Service host initialization 
 101        public void ServiceHostInitializationFailed(string exception)
 102        {
 0103            WriteEvent(ServiceHostInitializationFailedEventId, exception);
 0104        }
 105
 106        // A pair of events sharing the same name prefix with a "Start"/"Stop" suffix implicitly marks boundaries of an 
 107        // These activities can be automatically picked up by debugging and profiling tools, which can compute their exe
 108        // and other statistics.
 109        private const int ServiceRequestStartEventId = 5;
 110        [Event(ServiceRequestStartEventId, Level = EventLevel.Informational, Message = "Service request '{0}' started", 
 111        public void ServiceRequestStart(string requestTypeName)
 112        {
 0113            WriteEvent(ServiceRequestStartEventId, requestTypeName);
 0114        }
 115
 116        private const int ServiceRequestStopEventId = 6;
 117        [Event(ServiceRequestStopEventId, Level = EventLevel.Informational, Message = "Service request '{0}' finished", 
 118        public void ServiceRequestStop(string requestTypeName, string exception = "")
 119        {
 0120            WriteEvent(ServiceRequestStopEventId, requestTypeName, exception);
 0121        }
 122        #endregion
 123    }
 124}