Example #1
0
        internal static void StopSendActivity(Activity activity, EventHubsConnectionStringBuilder csb, string activePartitionRouting, IEnumerable <EventData> eventDatas, Task sendTask)
        {
            if (activity == null)
            {
                return;
            }

            DiagnosticListener.StopActivity(activity,
                                            new
            {
                csb.Endpoint,
                Entity = csb.EntityPath,
                ActivePartitionRouting = activePartitionRouting,
                EventDatas             = eventDatas.Select(TransformEvent),
                sendTask?.Status
            });
        }
Example #2
0
        internal static void FailSendActivity(Activity activity, EventHubsConnectionStringBuilder csb, string activePartitionRouting, IEnumerable <EventData> eventDatas, Exception ex)
        {
            if (!DiagnosticListener.IsEnabled() || !DiagnosticListener.IsEnabled(SendActivityExceptionName))
            {
                return;
            }

            DiagnosticListener.Write(SendActivityExceptionName,
                                     new
            {
                csb.Endpoint,
                Entity = csb.EntityPath,
                ActivePartitionRouting = activePartitionRouting,
                EventDatas             = eventDatas.Select(TransformEvent),
                Exception = ex
            });
        }
Example #3
0
        internal static void StopSendActivity(Activity activity, EventHubsConnectionStringBuilder csb, string partitionKey, IEnumerable <EventData> eventDatas, Task sendTask)
        {
            if (activity == null)
            {
                return;
            }

            DiagnosticListener.StopActivity(activity,
                                            new
            {
                csb.Endpoint,
                Entity       = csb.EntityPath,
                PartitionKey = partitionKey,
                EventDatas   = eventDatas,
                sendTask?.Status
            });
        }
Example #4
0
        internal static void FailReceiveActivity(Activity activity, EventHubsConnectionStringBuilder csb, string activePartitionRouting, string consumerGroup, Exception ex)
        {
            // TODO consider enriching activity with data from exception
            if (!DiagnosticListener.IsEnabled() || !DiagnosticListener.IsEnabled(ReceiveActivityExceptionName))
            {
                return;
            }

            DiagnosticListener.Write(ReceiveActivityExceptionName,
                                     new
            {
                csb.Endpoint,
                Entity = csb.EntityPath,
                ActivePartitionRouting = activePartitionRouting,
                ConsumerGroup          = consumerGroup,
                Exception = ex
            });
        }
Example #5
0
        internal static Activity StartSendActivity(string clientId, EventHubsConnectionStringBuilder csb, string activePartitionRouting, IEnumerable <EventData> eventDatas, int count)
        {
            // skip if diagnostic source not enabled
            if (!DiagnosticListener.IsEnabled())
            {
                return(null);
            }

            // skip if no listeners for this "Send" activity
            if (!DiagnosticListener.IsEnabled(SendActivityName, csb.Endpoint, csb.EntityPath))
            {
                return(null);
            }

            Activity activity = new Activity(SendActivityName);

            activity.AddTag("peer.hostname", csb.Endpoint.Host);
            activity.AddTag("eh.event_hub_name", csb.EntityPath);
            activity.AddTag("eh.active_partition_routing", activePartitionRouting);
            activity.AddTag("eh.event_count", count.ToString());
            activity.AddTag("eh.client_id", clientId);

            // in many cases activity start event is not interesting,
            // in that case start activity without firing event
            if (DiagnosticListener.IsEnabled(SendActivityStartName))
            {
                DiagnosticListener.StartActivity(activity,
                                                 new
                {
                    csb.Endpoint,
                    Entity = csb.EntityPath,
                    ActivePartitionRouting = activePartitionRouting,
                    EventDatas             = eventDatas.Select(TransformEvent)
                });
            }
            else
            {
                activity.Start();
            }

            Inject(eventDatas);

            return(activity);
        }
Example #6
0
        internal static void StopReceiveActivity(Activity activity, EventHubsConnectionStringBuilder csb, string activePartitionRouting, string consumerGroup, IList <EventData> events, Task receiveTask)
        {
            if (activity == null)
            {
                return;
            }

            SetRelatedOperations(activity, events);
            activity.AddTag("eh.event_count", (events?.Count ?? 0).ToString());

            DiagnosticListener.StopActivity(activity,
                                            new
            {
                csb.Endpoint,
                Entity = csb.EntityPath,
                ActivePartitionRouting = activePartitionRouting,
                ConsumerGroup          = consumerGroup,
                EventDatas             = events.Select(TransformEvent),
                receiveTask?.Status
            });
        }