/// <summary>
 /// Constructor
 /// </summary>
 /// <param name="Name">Event name</param>
 /// <param name="StartTime">Time of the event</param>
 /// <param name="FinishTime">Finish time for the event. May be null.</param>
 public Event(string Name, TimeSpan StartTime, TimeSpan?FinishTime)
 {
     this.Name       = Name;
     this.StartTime  = StartTime;
     this.FinishTime = FinishTime;
     this.Span       = TraceSpan.Create(Name);
 }
        /// <summary>
        /// Get properties to include in tracing info
        /// </summary>
        /// <param name="Span">The span to add metadata to</param>
        /// <param name="Prefix">Prefix for all metadata keys</param>
        public override void GetTraceMetadata(ITraceSpan Span, string Prefix)
        {
            base.GetTraceMetadata(Span, Prefix);

            Span.AddMetadata(Prefix + "target.name", Parameters.Target);
            Span.AddMetadata(Prefix + "target.config", Parameters.Configuration.ToString());
            Span.AddMetadata(Prefix + "target.platform", Parameters.Platform.ToString());

            if (Parameters.Project != null)
            {
                Span.AddMetadata(Prefix + "target.project", Parameters.Project);
            }
        }
Beispiel #3
0
 public TracingDbDataReader(ITraceSpan span, DbDataReader reader)
 {
     m_span   = span;
     m_reader = reader;
 }
Beispiel #4
0
        /// <summary>
        /// Build all the tasks for this node
        /// </summary>
        /// <param name="Job">Information about the current job</param>
        /// <param name="TagNameToFileSet">Mapping from tag names to the set of files they include. Should be set to contain the node inputs on entry.</param>
        /// <returns>Whether the task succeeded or not. Exiting with an exception will be caught and treated as a failure.</returns>
        public bool Build(JobContext Job, Dictionary <string, HashSet <FileReference> > TagNameToFileSet)
        {
            // Run each of the tasks in order
            HashSet <FileReference> BuildProducts = TagNameToFileSet[DefaultOutput.TagName];

            for (int Idx = 0; Idx < Tasks.Count; Idx++)
            {
                using (ITraceSpan Span = TraceSpan.Create("Task", Tasks[Idx].GetTraceName()))
                {
                    ITaskExecutor Executor = Tasks[Idx].GetExecutor();
                    if (Executor == null)
                    {
                        // Execute this task directly
                        try
                        {
                            Tasks[Idx].GetTraceMetadata(Span, "");
                            Tasks[Idx].Execute(Job, BuildProducts, TagNameToFileSet);
                        }
                        catch (Exception Ex)
                        {
                            ExceptionUtils.AddContext(Ex, "while executing task {0}", Tasks[Idx].GetTraceString());
                            if (Tasks[Idx].SourceLocation != null)
                            {
                                ExceptionUtils.AddContext(Ex, "at {0}({1})", GetReadablePathForDiagnostics(Tasks[Idx].SourceLocation.Item1), Tasks[Idx].SourceLocation.Item2);
                            }
                            throw;
                        }
                    }
                    else
                    {
                        Tasks[Idx].GetTraceMetadata(Span, "1.");

                        // The task has a custom executor, which may be able to execute several tasks simultaneously. Try to add the following tasks.
                        int FirstIdx = Idx;
                        while (Idx + 1 < Tasks.Count && Executor.Add(Tasks[Idx + 1]))
                        {
                            Idx++;
                            Tasks[Idx].GetTraceMetadata(Span, string.Format("{0}.", 1 + Idx - FirstIdx));
                        }
                        try
                        {
                            Executor.Execute(Job, BuildProducts, TagNameToFileSet);
                        }
                        catch (Exception Ex)
                        {
                            for (int TaskIdx = FirstIdx; TaskIdx <= Idx; TaskIdx++)
                            {
                                ExceptionUtils.AddContext(Ex, "while executing {0}", Tasks[TaskIdx].GetTraceString());
                            }
                            if (Tasks[FirstIdx].SourceLocation != null)
                            {
                                ExceptionUtils.AddContext(Ex, "at {0}({1})", GetReadablePathForDiagnostics(Tasks[FirstIdx].SourceLocation.Item1), Tasks[FirstIdx].SourceLocation.Item2);
                            }
                            throw;
                        }
                    }
                }
            }

            // Remove anything that doesn't exist, since these files weren't explicitly tagged
            BuildProducts.RemoveWhere(x => !FileReference.Exists(x));
            return(true);
        }
Beispiel #5
0
 /// <summary>
 /// Get properties to include in tracing info
 /// </summary>
 /// <param name="Span">The scope to add properties to</param>
 /// <param name="Prefix">Prefix for metadata entries</param>
 public virtual void GetTraceMetadata(ITraceSpan Span, string Prefix)
 {
     Span.AddMetadata(Prefix + "source.file", SourceLocation.Item1.MakeRelativeTo(CommandUtils.RootDirectory));
     Span.AddMetadata(Prefix + "source.line", SourceLocation.Item2.ToString());
 }
Beispiel #6
0
 public RequestActionTraceSpanProvider(ITraceSpan requestSpan)
 {
     m_spans    = new ITraceSpan[4];
     m_spans[0] = requestSpan ?? throw new ArgumentNullException(nameof(requestSpan));
 }
Beispiel #7
0
 private static ITraceSpan SetHttpHeadersAndCreateSpan(ITraceSpan currentSpan, Uri requestUri, Action <string, string> setHeader)
 {
     var requestSpan = currentSpan?.StartChildSpan(TraceSpanKind.Client,
                                                   new[]
Beispiel #8
0
 /// <summary>
 /// Starts a new <see cref="ITraceSpan"/> that is a child of <paramref name="traceSpan"/>.
 /// </summary>
 /// <param name="traceSpan">(Optional) The current span. If this is <c>null</c>, this method returns <c>null</c>.</param>
 /// <param name="kind">The <see cref="TraceSpanKind"/>.</param>
 /// <param name="tags">A sequence of span tags; see <see cref="ITraceSpan.SetTag"/>.</param>
 /// <returns>A new <see cref="ITraceSpan"/>, or <c>null</c>.</returns>
 public static ITraceSpan StartChildSpan(this ITraceSpan traceSpan, TraceSpanKind kind, IEnumerable <(string Name, string Value)> tags) =>
Beispiel #9
0
 public ITraceSpan StartSpan(ITraceSpan parent, TraceSpanKind kind, IEnumerable <(string Name, string Value)> tags)
Beispiel #10
0
 public void InjectSpan(ITraceSpan traceSpan, Action <string, string> inject)
 {
     s_injector.Inject(((ZipkinTraceSpan)traceSpan).WrappedTrace.CurrentSpan, inject);
 }