public static void ImportFileErrorHandler(
            [ErrorTrigger] TraceEvent error, string message, TextWriter log)
        {
            // Here you could send an error notification

            log.WriteLine(string.Format("{0} : {1}", message, error.ToString()));
        }
        /// <summary>
        /// Print data.  Note that this method is called FROM DIFFERNET THREADS which means you need to properly
        /// lock any read-write data you access.   It turns out Out.Writeline is already thread safe so
        /// there is nothing I have to do in this case.
        /// </summary>
        static void Print(TraceEvent data, SymbolReader symbolReader)
        {
            // There are a lot of data collection start on entry that I don't want to see (but often they are quite handy
            if (data.Opcode == TraceEventOpcode.DataCollectionStart)
            {
                return;
            }
            // V3.5 runtimes don't log the stack and in fact don't event log the exception name (it shows up as an empty string)
            // Just ignore these as they are not that interesting.
            if (data is ExceptionTraceData && ((ExceptionTraceData)data).ExceptionType.Length == 0)
            {
                return;
            }

            Out.WriteLine("EVENT: {0}", data.ToString());
            var callStack = data.CallStack();

            if (callStack != null)
            {
                // Because symbol lookup is complex, error prone, and expensive TraceLog requires you to be explicit.
                // Here we look up names in this call stack using the symbol reader.
                ResolveNativeCode(callStack, symbolReader);
                Out.WriteLine("CALLSTACK: {0}", callStack.ToString());
            }
        }
Exemplo n.º 3
0
        private void IAddEvent(TraceEvent te)
        {
            var p = new Paragraph
            {
                TextAlignment = TextAlignment.Left,
                Margin        = new Thickness(0),
                Inlines       =
                {
                    //new Line() { X1 = 0, X2 = 40, Y1 = -4, Y2 = -4, StrokeThickness = 2, Stroke = TurnBrush },
                    new Run(te.ToString())
                    {
                        Foreground = _turnBrush, FontWeight = FontWeights.Bold
                    }
                    //new Line() { X1 = 0, X2 = 40, Y1 = -4, Y2 = -4, StrokeThickness = 2, Stroke = TurnBrush }
                }
            };

            if (output.Document.Blocks.LastBlock != null)
            {
                if (((Paragraph)output.Document.Blocks.LastBlock).Inlines.Count == 0)
                {
                    output.Document.Blocks.Remove(output.Document.Blocks.LastBlock);
                }
            }
            output.Document.Blocks.Add(p);
            output.Document.Blocks.Add(new Paragraph {
                Margin = new Thickness()
            });                                                                   // Restore left alignment
            output.ScrollToEnd();
        }
        /// <summary>
        /// Print data.  Note that this method is called FROM DIFFERENT THREADS which means you need to properly
        /// lock any read-write data you access.   It turns out Out.WriteLine is already thread safe so
        /// there is nothing I have to do in this case.
        /// </summary>
        static void Print(TraceEvent data)
        {
            // There are a lot of data collection start on entry that I don't want to see (but often they are quite handy
            if (data.Opcode == TraceEventOpcode.DataCollectionStart)
            {
                return;
            }

            Out.WriteLine(data.ToString());
            if (data is UnhandledTraceEvent)
            {
                Out.WriteLine(data.Dump());
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Print data.  Note that this method is called FROM DIFFERNET THREADS which means you need to properly
        /// lock any read-write data you access.   It turns out Out.Writeline is already thread safe so
        /// there is nothing I have to do in this case.
        /// </summary>
        private static void Print(TraceEvent data)
        {
            if (s_stopping)        // Ctrl-C will stop the sessions, but buffered events may still come in, ignore these.
            {
                return;
            }

            // There are a lot of data collection start on entry that I don't want to see (but often they are quite handy
            if (data.Opcode == TraceEventOpcode.DataCollectionStart)
            {
                return;
            }

            Out.WriteLine(data.ToString());
            if (data is UnhandledTraceEvent)
            {
                Out.WriteLine(data.Dump());
            }
        }
Exemplo n.º 6
0
        private void InternalSendTraceTelemetry(TraceEvent eventData)
        {
            if (this.telemetryClient.TelemetryConfiguration.TelemetryChannel == null)
            {
                return;
            }

            var traceTelemetry = new TraceTelemetry
            {
                Message = eventData.ToString(),
            };

            if (!string.IsNullOrEmpty(this.DiagnosticsInstrumentationKey))
            {
                traceTelemetry.Context.InstrumentationKey = this.DiagnosticsInstrumentationKey;
            }

            traceTelemetry.Context.Operation.SyntheticSource = SdkTelemetrySyntheticSourceName;

            this.telemetryClient.TrackTrace(traceTelemetry);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Print data.  Note that this method is called FROM DIFFERNET THREADS which means you need to properly
        /// lock any read-write data you access.   It turns out Out.Writeline is already thread safe so
        /// there is nothing I have to do in this case.
        /// </summary>
        private static void Print(TraceEvent data)
        {
            // There are a lot of data collection start on entry that I don't want to see (but often they are quite handy
            if (data.Opcode == TraceEventOpcode.DataCollectionStart || data.Opcode == TraceEventOpcode.DataCollectionStop)
            {
                return;
            }

            // Merging inject some 'symbol' events that are not that interesting so we ignore those too.
            if (data.ProviderGuid == SymbolTraceEventParser.ProviderGuid)
            {
                return;
            }

            // To avoid 'rundown' events that happen in the beginning and end of the trace filter out things during those times
            if (data.TimeStampRelativeMSec < 1000 || 9000 < data.TimeStampRelativeMSec)
            {
                return;
            }

            Out.WriteLine(data.ToString());
        }
Exemplo n.º 8
0
        private void ProcessEvent(TraceEvent evt)
        {
            try
            {
                if (evt.ID == TraceEventUtil.ManifestEventID)
                {
                    XElement element = XElement.Parse(evt.ToString());

                    byte[]           eventData = Encoding.UTF8.GetBytes(element.FirstNode.ToString());
                    ProviderManifest manifest  = new ProviderManifest(new MemoryStream(eventData), eventData.Length);
                    this.OnManifestReceived(manifest);
                }
                else
                {
                    this.sink.OnNext(this.CreateEventEntry(evt));
                }
            }
            catch (Exception exception)
            {
                this.logger.TraceEventServiceSinkUnhandledFault(this.sessionName, exception.ToString());
            }
        }
Exemplo n.º 9
0
 static void Print(TraceEvent data)
 {
     if (data.ProviderName.StartsWith("Microsoft.Streaming"))
     {
         var line = Encoding.UTF8.GetBytes(data.TimeStamp.ToString("hh.mm.ss.ffffff") + " " + data.ToString() + "\n");
         fs.Write(line, 0, line.Length);
     }
 }
Exemplo n.º 10
0
 public void WriteMessage(TraceEvent traceEvent, string message)
 {
     WriteMessage(string.Concat(traceEvent.ToString().ToUpperInvariant(), ": ", message));
 }