示例#1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PipelineElementDiagnostics"/> class.
 /// </summary>
 /// <param name="id">Pipeline element ID.</param>
 /// <param name="name">Pipeline element name.</param>
 /// <param name="typeName">Pipeline element type name.</param>
 /// <param name="kind">Pipeline element kind.</param>
 /// <param name="isRunning">Whether the pipeline element is running (after started, before stopped).</param>
 /// <param name="finalized">Whether the pipeline element is finalized.</param>
 /// <param name="diagnosticState">Diagnostic state for the pipeline element.</param>
 /// <param name="pipelineId">ID of pipeline to which this element belongs.</param>
 /// <param name="emitters">Pipeline element emitters.</param>
 /// <param name="receivers">Pipeline element receivers.</param>
 /// <param name="representsSubpipeline">Pipeline which this element represents (e.g. Subpipeline).</param>
 /// <param name="connectorBridgeToPipelineElement">Bridge to pipeline element in another pipeline (e.g. Connectors).</param>
 public PipelineElementDiagnostics(
     int id,
     string name,
     string typeName,
     PipelineElementKind kind,
     bool isRunning,
     bool finalized,
     string diagnosticState,
     int pipelineId,
     EmitterDiagnostics[] emitters,
     ReceiverDiagnostics[] receivers,
     PipelineDiagnostics representsSubpipeline,
     PipelineElementDiagnostics connectorBridgeToPipelineElement)
 {
     this.Id                               = id;
     this.Name                             = name;
     this.TypeName                         = typeName;
     this.Kind                             = kind;
     this.IsRunning                        = isRunning;
     this.Finalized                        = finalized;
     this.DiagnosticState                  = diagnosticState;
     this.PipelineId                       = pipelineId;
     this.Emitters                         = emitters;
     this.Receivers                        = receivers;
     this.RepresentsSubpipeline            = representsSubpipeline;
     this.ConnectorBridgeToPipelineElement = connectorBridgeToPipelineElement;
 }
示例#2
0
        /// <summary>
        /// Gets all pipeline diagnostics (including descendant subpipelines).
        /// </summary>
        /// <param name="pipeline">Root pipeline diagnostics.</param>
        /// <returns>All pipeline diagnostics.</returns>
        public static IEnumerable <PipelineDiagnostics> GetAllPipelineDiagnostics(this PipelineDiagnostics pipeline)
        {
            yield return(pipeline);

            foreach (var child in pipeline.SubpipelineDiagnostics)
            {
                foreach (var descendant in child.GetAllPipelineDiagnostics())
                {
                    yield return(descendant);
                }
            }
        }
示例#3
0
        /// <summary>
        /// Pipeline creation.
        /// </summary>
        /// <remarks>Called upon pipeline construction.</remarks>
        /// <param name="pipeline">Pipeline being created.</param>
        public void PipelineCreate(Pipeline pipeline)
        {
            var graph = new PipelineDiagnostics(pipeline.Id, pipeline.Name);

            if (!this.graphs.TryAdd(pipeline.Id, graph))
            {
                throw new InvalidOperationException("Failed to add created graph");
            }

            if (this.CurrentRoot == null && !(pipeline is Subpipeline))
            {
                this.CurrentRoot = graph;
            }
        }
示例#4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PipelineDiagnostics"/> class.
 /// </summary>
 /// <param name="id">Pipeline ID.</param>
 /// <param name="name">Pipeline name.</param>
 /// <param name="isPipelineRunning">Whether the pipeline is running (after started, before stopped).</param>
 /// <param name="parentPipelineDiagnostics">Parent pipeline of this pipeline (it any).</param>
 /// <param name="subpipelineDiagnostics">Subpipelines of this pipeline.</param>
 /// <param name="pipelineElements">Elements in this pipeline.</param>
 public PipelineDiagnostics(
     int id,
     string name,
     bool isPipelineRunning,
     PipelineDiagnostics parentPipelineDiagnostics,
     PipelineDiagnostics[] subpipelineDiagnostics,
     PipelineElementDiagnostics[] pipelineElements)
 {
     this.Id   = id;
     this.Name = name;
     this.IsPipelineRunning         = isPipelineRunning;
     this.ParentPipelineDiagnostics = parentPipelineDiagnostics;
     this.SubpipelineDiagnostics    = subpipelineDiagnostics ?? new PipelineDiagnostics[0];
     this.PipelineElements          = pipelineElements ?? new PipelineElementDiagnostics[0];
 }
示例#5
0
 /// <summary>
 /// Gets throttled receiver count across receivers within pipeline and descendant.
 /// </summary>
 /// <param name="pipeline">Root pipeline diagnostics.</param>
 /// <param name="predicate">Predicate expression filtering receiver diagnostics.</param>
 /// <returns>Throttled receiver count.</returns>
 public static int GetThrottledReceiverCount(this PipelineDiagnostics pipeline, Func <PipelineDiagnostics.ReceiverDiagnostics, bool> predicate = null)
 {
     return(pipeline.GetAllReceiverDiagnostics().Where(r => r.ReceiverIsThrottled && (predicate == null ? true : predicate(r))).Count());
 }
示例#6
0
 /// <summary>
 /// Gets processed message count in last averaging time span across receivers within pipeline and descendant.
 /// </summary>
 /// <param name="pipeline">Root pipeline diagnostics.</param>
 /// <param name="predicate">Predicate expression filtering receiver diagnostics.</param>
 /// <returns>Processed message count.</returns>
 public static int GetProcessedMessageAveragePerTimeSpan(this PipelineDiagnostics pipeline, Func <PipelineDiagnostics.ReceiverDiagnostics, bool> predicate = null)
 {
     return(pipeline.GetAllReceiverDiagnostics().Where(r => predicate == null ? true : predicate(r)).Select(r => r.WindowMessageProcessedCount).Sum());
 }
示例#7
0
 /// <summary>
 /// Gets dropped message count across receivers within pipeline and descendant.
 /// </summary>
 /// <param name="pipeline">Root pipeline diagnostics.</param>
 /// <param name="predicate">Predicate expression filtering receiver diagnostics.</param>
 /// <returns>Dropped message count.</returns>
 public static int GetDroppedMessageCount(this PipelineDiagnostics pipeline, Func <PipelineDiagnostics.ReceiverDiagnostics, bool> predicate = null)
 {
     return(pipeline.GetAllReceiverDiagnostics().Where(r => predicate == null ? true : predicate(r)).Select(r => r.TotalMessageDroppedCount).Sum());
 }
示例#8
0
 /// <summary>
 /// Gets throttled receiver count within pipeline and descendant.
 /// </summary>
 /// <param name="pipeline">Root pipeline diagnostics.</param>
 /// <param name="predicate">Predicate expression filtering receiver diagnostics.</param>
 /// <returns>Average queued message count.</returns>
 public static double GetAverageQueuedMessageCount(this PipelineDiagnostics pipeline, Func <PipelineDiagnostics.ReceiverDiagnostics, bool> predicate = null)
 {
     return(pipeline.GetAllReceiverDiagnostics().Where(r => predicate == null ? true : predicate(r)).Select(r => r.AvgDeliveryQueueSize).Sum());
 }
示例#9
0
 /// <summary>
 /// Gets emitter count within pipeline and descendant.
 /// </summary>
 /// <param name="pipeline">Root pipeline diagnostics.</param>
 /// <param name="predicate">Predicate expression filtering emitter diagnostics.</param>
 /// <returns>Emitter count.</returns>
 public static int GetEmitterCount(this PipelineDiagnostics pipeline, Func <PipelineDiagnostics.EmitterDiagnostics, bool> predicate = null)
 {
     return(pipeline.GetAllEmitterDiagnostics().Where(e => predicate == null ? true : predicate(e)).Count());
 }
示例#10
0
 /// <summary>
 /// Get or create external pipeline diagnostics representation.
 /// </summary>
 /// <param name="pipelineDiagnosticsInternal">Internal pipeline diagnostics representation.</param>
 /// <param name="parentPipelineDiagnostics">Parent pipeline diagnostics.</param>
 /// <param name="includeStoppedPipelines">Whether to include stopped pipelines.</param>
 /// <param name="includeStoppedPipelineElements">Whether to include stopped pipeline element .</param>
 /// <returns>External pipeline diagnostics representation.</returns>
 public PipelineDiagnostics GetOrCreatePipelineDiagnostics(PipelineDiagnosticsInternal pipelineDiagnosticsInternal, PipelineDiagnostics parentPipelineDiagnostics, bool includeStoppedPipelines, bool includeStoppedPipelineElements)
 {
     return(this.GetOrCreate(this.Pipelines, pipelineDiagnosticsInternal, p => p.Id, (p, c) => new PipelineDiagnostics(p, parentPipelineDiagnostics, c, includeStoppedPipelines, includeStoppedPipelineElements)));
 }
示例#11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PipelineDiagnostics"/> class.
 /// </summary>
 /// <param name="pipelineDiagnosticsInternal">Internal pipeline diagnostics.</param>
 /// <param name="parent">Parent pipeline diagnostics to this pipeline diagnostics.</param>
 /// <param name="builder">Builder of pipeline parts used during construction.</param>
 /// <param name="includeStoppedPipelines">Whether to include stopped pipelines.</param>
 /// <param name="includeStoppedPipelineElements">Whether to include stopped pipeline elements.</param>
 private PipelineDiagnostics(PipelineDiagnosticsInternal pipelineDiagnosticsInternal, PipelineDiagnostics parent, Builder builder, bool includeStoppedPipelines, bool includeStoppedPipelineElements)
 {
     this.Initialize(pipelineDiagnosticsInternal, parent, builder, includeStoppedPipelines, includeStoppedPipelineElements);
 }
示例#12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PipelineDiagnostics"/> class.
 /// </summary>
 /// <param name="pipelineDiagnosticsInternal">Internal pipeline diagnostics.</param>
 /// <param name="parent">Parent pipeline diagnostics to this pipeline diagnostics.</param>
 /// <param name="builder">Builder of pipeline parts used during construction.</param>
 /// <param name="includeStoppedPipelines">Whether to include stopped pipelines.</param>
 /// <param name="includeStoppedPipelineElements">Whether to include stopped pipeline element .</param>
 private void Initialize(PipelineDiagnosticsInternal pipelineDiagnosticsInternal, PipelineDiagnostics parent, Builder builder, bool includeStoppedPipelines, bool includeStoppedPipelineElements)
 {
     this.Id   = pipelineDiagnosticsInternal.Id;
     this.Name = pipelineDiagnosticsInternal.Name;
     this.IsPipelineRunning         = pipelineDiagnosticsInternal.IsPipelineRunning;
     this.ParentPipelineDiagnostics = parent;
     this.SubpipelineDiagnostics    =
         pipelineDiagnosticsInternal.Subpipelines.Values
         .Where(s => includeStoppedPipelines || s.IsPipelineRunning)
         .Select(s => builder.GetOrCreatePipelineDiagnostics(s, this, includeStoppedPipelines, includeStoppedPipelineElements))
         .ToArray();
     this.PipelineElements =
         pipelineDiagnosticsInternal.PipelineElements.Values
         .Where(pe => includeStoppedPipelineElements || (pe.IsRunning && (pe.RepresentsSubpipeline == null || pe.RepresentsSubpipeline.IsPipelineRunning)))
         .Select(pe => builder.GetOrCreatePipelineElementDiagnostics(pe))
         .ToArray();
 }
示例#13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PipelineElementDiagnostics"/> class.
 /// </summary>
 /// <param name="element">Pipeline element which this diagnostic information represents.</param>
 /// <param name="pipeline">Pipeline to which this pipeline element belongs.</param>
 internal PipelineElementDiagnostics(PipelineElement element, PipelineDiagnostics pipeline)
     : this(element.Id, element.Name, element.IsConnector ? PipelineElementKind.Connector : element.StateObject is Subpipeline ? PipelineElementKind.Subpipeline : element.IsSource ? PipelineElementKind.Source : PipelineElementKind.Reactive, pipeline)
 {
 }
示例#14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PipelineElementDiagnostics"/> class.
 /// </summary>
 /// <param name="id">Pipeline element ID.</param>
 /// <param name="name">Pipeline element name.</param>
 /// <param name="kind">Pipeline element kind.</param>
 /// <param name="parentPipeline">Pipeline to which this element belongs.</param>
 public PipelineElementDiagnostics(int id, string name, PipelineElementKind kind, PipelineDiagnostics parentPipeline)
 {
     this.Id             = id;
     this.Name           = name;
     this.Kind           = kind;
     this.ParentPipeline = parentPipeline;
     this.Emitters       = new Dictionary <int, EmitterDiagnostics>();
     this.Receivers      = new Dictionary <int, ReceiverDiagnostics>();
 }
示例#15
0
 /// <summary>
 /// Gets all pipeline element diagnostics within a pipeline diagnostics (and all descendant subpipelines).
 /// </summary>
 /// <param name="pipeline">Root pipeline diagnostics.</param>
 /// <returns>Collection of all pipeline element diagnostics within.</returns>
 public static IEnumerable <PipelineDiagnostics.PipelineElementDiagnostics> GetAllPipelineElementDiagnostics(this PipelineDiagnostics pipeline)
 {
     return(pipeline.GetAllPipelineDiagnostics().GetAllPipelineElements());
 }
示例#16
0
 /// <summary>
 /// Gets all emitter diagnostics within a pipeline diagnostics (and all descendant subpipelines).
 /// </summary>
 /// <param name="pipeline">Root pipeline diagnostics.</param>
 /// <returns>Collection of all emitter diagnostics within.</returns>
 public static IEnumerable <PipelineDiagnostics.EmitterDiagnostics> GetAllEmitterDiagnostics(this PipelineDiagnostics pipeline)
 {
     return(pipeline.GetAllPipelineDiagnostics().GetAllEmitterDiagnostics());
 }
示例#17
0
 /// <summary>
 /// Gets count of pipeline elements.
 /// </summary>
 /// <param name="pipeline">Root pipeline diagnostics.</param>
 /// <param name="predicate">Predicate expression filtering pipeline element diagnostics.</param>
 /// <returns>Pipeline element count.</returns>
 public static int GetPipelineElementCount(this PipelineDiagnostics pipeline, Func <PipelineDiagnostics.PipelineElementDiagnostics, bool> predicate = null)
 {
     return(pipeline.GetAllPipelineElementDiagnostics().Where(e => predicate == null ? true : predicate(e)).Count());
 }