static void enableOption( string s ) { switch(s) { case "-test": testOption = 1; break; case "-Test": testOption = 2; break; case "-dump": dumpCodeOption = true; break; case "-traceOps": traceOption |= TraceOptions.TraceOps; break; case "-traceCalls": traceOption |= TraceOptions.TraceCalls; break; case "-traceStack": traceOption |= TraceOptions.TraceStack; break; case "-traceAll": traceOption = (TraceOptions)255; break; default: Usage(); break; } }
/// <summary> /// Initializes a named instance of <see cref="FlatFileTraceListenerData"/>. /// </summary> /// <param name="name">The name.</param> /// <param name="fileName">The file name.</param> /// <param name="header">The header.</param> /// <param name="footer">The footer.</param> /// <param name="formatterName">The formatter name.</param> /// <param name="traceOutputOptions">The trace options.</param> public FlatFileTraceListenerData(string name, string fileName, string header, string footer, string formatterName, TraceOptions traceOutputOptions) : this(name, typeof(FlatFileTraceListener), fileName, formatterName, traceOutputOptions) { this.Header = header; this.Footer = footer; }
public DomainObject(string name, string surName, int numberProperty, TraceOptions enumProperty) { this.name = name; this.surName = surName; this.numberProperty = numberProperty; this.enumProperty = enumProperty; }
/// <summary> /// Initializes the traceHandlerStreamWriter object /// </summary> /// <param name="traceSource">Trace source that holds a set of handlers</param> /// <param name="filterLevels">The level of trace message filtered by trace listener</param> /// <param name="traceOptions">Trace data options that has to be written in the trace output</param> /// <param name="traceFileFormat">File format component for the handler</param> /// <param name="fileExtension">Extension of trace file name for each handler</param> public Writer(TraceSource traceSource, SourceLevels filterLevels, TraceOptions traceOptions, ITraceFileFormat traceFileFormat, string fileExtension = "txt") { this.traceSource = traceSource; this.filterLevels = filterLevels; this.traceOptions = traceOptions; this.traceFileFormat = traceFileFormat; this.fileExtension = fileExtension; }
public BindingListener(TraceOptions options) { IsFirstWrite = true; PresentationTraceSources.Refresh(); PresentationTraceSources.DataBindingSource.Listeners.Add(this); PresentationTraceSources.DataBindingSource.Switch.Level = SourceLevels.Error; TraceOutputOptions = options; DetermineInformationPropertyCount(); }
public static void SetupFileTrace(string filePath, TraceOptions options) { Trace.AutoFlush = true; Directory.CreateDirectory(Path.GetDirectoryName(filePath)); FileStream fileStream = new FileStream(filePath, FileMode.OpenOrCreate); fileStream.Seek(0L, SeekOrigin.End); TextWriterTraceListener writerTraceListener = new TextWriterTraceListener((Stream)fileStream); writerTraceListener.TraceOutputOptions = options; Trace.Listeners.Add((TraceListener)writerTraceListener); }
public static void SetTrace(SourceLevels level, TraceOptions options) { if (_listener == null) { _listener = new BindingErrorTraceListener(); PresentationTraceSources.DataBindingSource.Listeners.Add(_listener); } _listener.TraceOutputOptions = options; PresentationTraceSources.DataBindingSource.Switch.Level = level; }
/// <summary> /// Initializes a new instance of the <see cref="RollingXmlTraceListenerData"/> class. /// </summary> /// <param name="name">The name for the configuration object.</param> /// <param name="traceOutputOptions">The trace options.</param> /// <param name="fileName"></param> /// <param name="rollSizeKB"></param> /// <param name="timeStampPattern"></param> /// <param name="rollFileExistsBehavior"></param> /// <param name="rollInterval"></param> public RollingXmlTraceListenerData(string name, string fileName, int rollSizeKB, string timeStampPattern, RollFileExistsBehavior rollFileExistsBehavior, RollInterval rollInterval, TraceOptions traceOutputOptions) : base(name, typeof(RollingXmlTraceListener), traceOutputOptions) { FileName = fileName; RollSizeKB = rollSizeKB; RollFileExistsBehavior = rollFileExistsBehavior; RollInterval = rollInterval; TimeStampPattern = timeStampPattern; }
public bool Run( TraceOptions traceFlags ) { CompiledFunction ep; if (!function.TryGetValue("Main", out ep)) { Console.WriteLine("No Main function found"); return false; } if (ep.NumArguments != 0) { Console.WriteLine("The Main function takes 0 arguments"); return false; } this.traceFlags = traceFlags; stack = new SMValue[stackSizeInitial]; stackHeight = 0; bool resultCode = executeFunction( ep ); return resultCode; }
/// <summary> /// Initializes a new instance of the <see cref="RollingFlatFileTraceListenerData"/> class. /// </summary> /// <param name="name">The name for the configuration object.</param> /// <param name="traceOutputOptions">The trace options.</param> /// <param name="fileName"></param> /// <param name="footer"></param> /// <param name="header"></param> /// <param name="rollSizeKB"></param> /// <param name="timeStampPattern"></param> /// <param name="rollFileExistsBehavior"></param> /// <param name="rollInterval"></param> /// <param name="formatter"></param> public RollingFlatFileTraceListenerData(string name, string fileName, string header, string footer, int rollSizeKB, string timeStampPattern, RollFileExistsBehavior rollFileExistsBehavior, RollInterval rollInterval, TraceOptions traceOutputOptions, string formatter) : base(name, typeof(RollingFlatFileTraceListener), traceOutputOptions) { FileName = fileName; Header = header; Footer = footer; RollSizeKB = rollSizeKB; RollFileExistsBehavior = rollFileExistsBehavior; RollInterval = rollInterval; TimeStampPattern = timeStampPattern; Formatter = formatter; }
public static void setTracing(TraceLevel level, TraceOptions options, string traceFileName) { m_level = level; if (m_level != TraceLevel.Off) { TextWriterTraceListener tr1; try { tr1 = new TextWriterTraceListener(File.CreateText(traceFileName)); tr1.TraceOutputOptions = options; Trace.Listeners.Add(tr1); } catch (Exception e) { log(TraceEventType.Error, e.StackTrace); } } }
/// <summary> /// Initializes a named instance of <see cref="FormattedDatabaseTraceListenerData"/> with /// name, stored procedure name, databse instance name, and formatter name. /// </summary> /// <param name="name">The name.</param> /// <param name="writeLogStoredProcName">The stored procedure name for writing the log.</param> /// <param name="addCategoryStoredProcName">The stored procedure name for adding a category for this log.</param> /// <param name="databaseInstanceName">The database instance name.</param> /// <param name="formatterName">The formatter name.</param> /// <param name="traceOutputOptions">The trace options.</param> /// <param name="filter">The filter to be applied</param> public ExtendedFormattedDatabaseTraceListenerData(string name, string writeLogStoredProcName, string addCategoryStoredProcName, string databaseInstanceName, string formatterName, TraceOptions traceOutputOptions, SourceLevels filter) : base(name, typeof(ExtendedFormattedDatabaseTraceListener), traceOutputOptions, filter) { DatabaseInstanceName = databaseInstanceName; WriteLogStoredProcName = writeLogStoredProcName; AddCategoryStoredProcName = addCategoryStoredProcName; Formatter = formatterName; }
/// <summary> /// Initializes an instance of <see cref="TraceListenerData"/> with a name, a <see cref="TraceOptions"/> for /// a TraceListenerType and a <see cref="SourceLevels"/> for a Filter. /// </summary> /// <param name="name">The name for the instance.</param> /// <param name="traceListenerType">The trace listener type.</param> /// <param name="traceOutputOptions">The trace options.</param> /// <param name="filter">The filter.</param> protected TraceListenerData(string name, Type traceListenerType, TraceOptions traceOutputOptions, SourceLevels filter) : base(name, traceListenerType) { this.ListenerDataType = this.GetType(); this.TraceOutputOptions = traceOutputOptions; this.Filter = filter; }
public void TraceOutputOptionsTest_Invalid(TraceOptions options) { var listener = new TestTraceListener(); Assert.Throws <ArgumentOutOfRangeException>(() => listener.TraceOutputOptions = options); }
public void GetTraceOptions() { Assert.Equal(TraceOptions.DEFAULT, First.TraceOptions); Assert.Equal(TraceOptions.Builder().SetIsSampled(true).Build(), Second.TraceOptions); }
/// <summary> /// Initializes a new instance of the <see cref="T:SystemDiagnosticsTraceListenerData"/> class. /// </summary> /// <param name="name">The name.</param> /// <param name="type">The type.</param> /// <param name="initData">The init data.</param> /// <param name="traceOutputOptions">The trace output options.</param> public SystemDiagnosticsTraceListenerData(string name, Type type, string initData, TraceOptions traceOutputOptions) : base(name, type, initData, traceOutputOptions) { }
/// <summary> /// Initializes an instance of <see cref="TraceListenerData"/> with a name and <see cref="TraceOptions"/> for /// a TraceListenerType. /// </summary> /// <param name="name">The name for the instance.</param> /// <param name="traceListenerType">The trace listener type.</param> /// <param name="traceOutputOptions">The trace options.</param> protected TraceListenerData(string name, Type traceListenerType, TraceOptions traceOutputOptions) : base(name, traceListenerType) { this.ListenerDataType = this.GetType(); this.TraceOutputOptions = traceOutputOptions; }
private bool IsEnabled(TraceOptions opts) { return (opts & TraceOutputOptions) != 0; }
/// <summary> /// Initializes a new instance of the <see cref="CommonLoggingEntlibTraceListenerData"/> class. /// </summary> /// <param name="name">The name.</param> /// <param name="loggerNameFormat">The logger name format.</param> /// <param name="formatterName">Name of the formatter.</param> /// <param name="traceOutputOptions">The trace output options.</param> public CommonLoggingEntlibTraceListenerData(string name, string loggerNameFormat, string formatterName, TraceOptions traceOutputOptions) : this(name, typeof(CommonLoggingEntlibTraceListener), loggerNameFormat, formatterName, traceOutputOptions) { }
public void traceOptions_ToString() { Assert.Contains("sampled=False", TraceOptions.DEFAULT.ToString()); Assert.Contains("sampled=True", TraceOptions.Builder().SetIsSampled(true).Build().ToString()); }
private bool TryExtractTraceparent(string traceparent, out TraceId traceId, out SpanId spanId, out TraceOptions traceoptions) { // from https://github.com/w3c/distributed-tracing/blob/master/trace_context/HTTP_HEADER_FORMAT.md // traceparent: 00-0af7651916cd43dd8448eb211c80319c-00f067aa0ba902b7-01 traceId = TraceId.Invalid; spanId = SpanId.Invalid; traceoptions = TraceOptions.Default; var bestAttempt = false; if (string.IsNullOrWhiteSpace(traceparent)) { return(false); } // if version does not end with delimeter if (traceparent.Length < VersionPrefixIdLength || traceparent[VersionPrefixIdLength - 1] != '-') { return(false); } // or version is not a hex (will throw) var versionArray = Arrays.StringToByteArray(traceparent, 0, VersionLength); if (versionArray[0] == 255) { return(false); } if (versionArray[0] > 0) { // expected version is 00 // for higher versions - best attempt parsing of trace id, span id, etc. bestAttempt = true; } if (traceparent.Length < VersionAndTraceIdLength || traceparent[VersionAndTraceIdLength - 1] != '-') { return(false); } try { traceId = TraceId.FromBytes(Arrays.StringToByteArray(traceparent, VersionPrefixIdLength, TraceIdLength)); } catch (ArgumentOutOfRangeException) { // it's ok to still parse tracestate return(false); } if (traceparent.Length < VersionAndTraceIdAndSpanIdLength || traceparent[VersionAndTraceIdAndSpanIdLength - 1] != '-') { return(false); } try { spanId = SpanId.FromBytes(Arrays.StringToByteArray(traceparent, VersionAndTraceIdLength, SpanIdLength)); } catch (ArgumentOutOfRangeException) { // it's ok to still parse tracestate return(false); } if (traceparent.Length < VersionAndTraceIdAndSpanIdLength + OptionsLength) { return(false); } byte[] optionsArray; try { optionsArray = Arrays.StringToByteArray(traceparent, VersionAndTraceIdAndSpanIdLength, OptionsLength); } catch (ArgumentOutOfRangeException) { // it's ok to still parse tracestate return(false); } if ((optionsArray[0] | 1) == 1) { traceoptions = TraceOptions.Builder().SetIsSampled(true).Build(); } if ((!bestAttempt) && (traceparent.Length != VersionAndTraceIdAndSpanIdLength + OptionsLength)) { return(false); } if (bestAttempt) { if ((traceparent.Length > VersionAndTraceIdAndSpanIdLength + OptionsLength) && (traceparent[VersionAndTraceIdAndSpanIdLength + OptionsLength] != '-')) { return(false); } } return(true); }
public void ToFromBytes() { Assert.Equal(firstBytes, TraceOptions.FromBytes(firstBytes).Bytes); Assert.Equal(secondBytes, TraceOptions.FromBytes(secondBytes).Bytes); Assert.Equal(thirdBytes, TraceOptions.FromBytes(thirdBytes).Bytes); }
public void IsSampled() { Assert.False(TraceOptions.DEFAULT.IsSampled); Assert.True(TraceOptions.Builder().SetIsSampled(true).Build().IsSampled); }
protected override void Act() { trOption = TraceOptions.Callstack | TraceOptions.DateTime; base.SystemDiagnosticsListenerBuilder.WithTraceOptions(trOption); }
/// <summary> /// Initializes a new instance of the <see cref="MsmqTraceListenerData"/> class. /// </summary> /// <param name="name">The name for the represented trace listener.</param> /// <param name="queuePath">The path name for the represented trace listener.</param> /// <param name="formatterName">The formatter name for the represented trace listener.</param> /// <param name="messagePriority">The priority for the represented trace listener.</param> /// <param name="recoverable">The recoverable flag for the represented trace listener.</param> /// <param name="timeToReachQueue">The timeToReachQueue for the represented trace listener.</param> /// <param name="timeToBeReceived">The timeToReachQueue for the represented trace listener.</param> /// <param name="useAuthentication">The use authentication flag for the represented trace listener.</param> /// <param name="useDeadLetterQueue">The use dead letter flag for the represented trace listener.</param> /// <param name="useEncryption">The use encryption flag for the represented trace listener.</param> /// <param name="transactionType">The transaction type for the represented trace listener.</param> /// <param name="traceOutputOptions">The trace output options for the represented trace listener.</param> /// <param name="filter">The filter for the represented trace listener.</param> public MsmqTraceListenerData(string name, string queuePath, string formatterName, MessagePriority messagePriority, bool recoverable, TimeSpan timeToReachQueue, TimeSpan timeToBeReceived, bool useAuthentication, bool useDeadLetterQueue, bool useEncryption, MessageQueueTransactionType transactionType, TraceOptions traceOutputOptions, SourceLevels filter) : base(name, typeof(MsmqTraceListener), traceOutputOptions, filter) { this.QueuePath = queuePath; this.Formatter = formatterName; this.MessagePriority = messagePriority; this.Recoverable = recoverable; this.TimeToReachQueue = timeToReachQueue; this.TimeToBeReceived = timeToBeReceived; this.UseAuthentication = useAuthentication; this.UseDeadLetterQueue = useDeadLetterQueue; this.UseEncryption = useEncryption; this.TransactionType = transactionType; }
/// <summary> /// Creates a new instance of the plain-text object serializer /// </summary> /// <param name="options">Trace options</param> public PlainTextTraceObjectSerializer(TraceOptions options) { this.Options = options ?? throw new ArgumentNullException(nameof(options)); }
/// <summary> /// Initializes a named instance of <see cref="FormattedDatabaseTraceListenerData"/> with /// name, stored procedure name, databse instance name, and formatter name. /// </summary> /// <param name="name">The name.</param> /// <param name="writeLogStoredProcName">The stored procedure name for writing the log.</param> /// <param name="addCategoryStoredProcName">The stored procedure name for adding a category for this log.</param> /// <param name="databaseInstanceName">The database instance name.</param> /// <param name="formatterName">The formatter name.</param> /// <param name="traceOutputOptions">The trace options.</param> public FormattedDatabaseTraceListenerData(string name, string writeLogStoredProcName, string addCategoryStoredProcName, string databaseInstanceName, string formatterName, TraceOptions traceOutputOptions) : base(name, typeof(FormattedDatabaseTraceListener), traceOutputOptions) { this.DatabaseInstanceName = databaseInstanceName; this.WriteLogStoredProcName = writeLogStoredProcName; this.AddCategoryStoredProcName = addCategoryStoredProcName; this.Formatter = formatterName; }
public void WriteFooterTest(TraceOptions opts, int flagCount) { var cache = new TraceEventCache(); var listener = new TestTextTraceListener(); listener.TraceOutputOptions = opts; listener.Filter = new TestTraceFilter(false); listener.TraceEvent(cache, "Source", TraceEventType.Critical, 1); Assert.Equal(0, listener.WriteCount); var baseExpected = 2; // header + message var expected = baseExpected; listener = new TestTextTraceListener(); listener.TraceOutputOptions = opts; listener.TraceEvent(null, "Source", TraceEventType.Critical, 1); Assert.Equal(expected, listener.WriteCount); // Two calls to write per flag, one call for writing the indent, one for the message. expected = baseExpected + flagCount * 2; listener = new TestTextTraceListener(); listener.TraceOutputOptions = opts; listener.TraceEvent(cache, "Source", TraceEventType.Critical, 1); Assert.Equal(expected, listener.WriteCount); }
public ILoggingConfigurationSendToEventLogTraceListener WithTraceOptions(TraceOptions traceOptions) { eventLogListener.TraceOutputOptions = traceOptions; return(this); }
private static void BuildFooter(StringBuilder writer, TraceEventType eventType, TraceEventCache eventCache, bool isUserData, TraceOptions opts) { if (!isUserData) { _InternalBuildRaw(writer, "</EventData>"); } else { _InternalBuildRaw(writer, "</UserData>"); } // Provide English resource string for EventType _InternalBuildRaw(writer, "<RenderingInfo Culture=\"en-EN\">"); //Avoid Enum.ToString which uses reflection switch (eventType) { case TraceEventType.Critical: _InternalBuildRaw(writer, "<Level>Critical</Level>"); break; case TraceEventType.Error: _InternalBuildRaw(writer, "<Level>Error</Level>"); break; case TraceEventType.Warning: _InternalBuildRaw(writer, "<Level>Warning</Level>"); break; case TraceEventType.Information: _InternalBuildRaw(writer, "<Level>Information</Level>"); break; case TraceEventType.Verbose: _InternalBuildRaw(writer, "<Level>Verbose</Level>"); break; case TraceEventType.Start: _InternalBuildRaw(writer, "<Level>Information</Level><Opcode>Start</Opcode>"); break; case TraceEventType.Stop: _InternalBuildRaw(writer, "<Level>Information</Level><Opcode>Stop</Opcode>"); break; case TraceEventType.Suspend: _InternalBuildRaw(writer, "<Level>Information</Level><Opcode>Suspend</Opcode>"); break; case TraceEventType.Resume: _InternalBuildRaw(writer, "<Level>Information</Level><Opcode>Resume</Opcode>"); break; case TraceEventType.Transfer: _InternalBuildRaw(writer, "<Level>Information</Level><Opcode>Transfer</Opcode>"); break; default: break; } _InternalBuildRaw(writer, "</RenderingInfo>"); // Custom System.Diagnostics information as its own schema if (eventCache != null && ((TraceOptions.LogicalOperationStack | TraceOptions.Callstack | TraceOptions.Timestamp) & opts) != 0) { _InternalBuildRaw(writer, "<System.Diagnostics.ExtendedData xmlns=\"http://schemas.microsoft.com/2006/09/System.Diagnostics/ExtendedData\">"); if ((TraceOptions.Timestamp & opts) != 0) { _InternalBuildRaw(writer, "<Timestamp>"); _InternalBuildRaw(writer, eventCache.Timestamp.ToString(CultureInfo.InvariantCulture)); _InternalBuildRaw(writer, "</Timestamp>"); } if ((TraceOptions.LogicalOperationStack & opts) != 0) { Stack stk = eventCache.LogicalOperationStack as Stack; _InternalBuildRaw(writer, "<LogicalOperationStack>"); if ((stk != null) && (stk.Count > 0)) { foreach (object obj in stk) { _InternalBuildRaw(writer, "<LogicalOperation>"); BuildEscaped(writer, obj.ToString()); _InternalBuildRaw(writer, "</LogicalOperation>"); } } _InternalBuildRaw(writer, "</LogicalOperationStack>"); } if ((TraceOptions.Callstack & opts) != 0) { _InternalBuildRaw(writer, "<Callstack>"); BuildEscaped(writer, eventCache.Callstack); _InternalBuildRaw(writer, "</Callstack>"); } _InternalBuildRaw(writer, "</System.Diagnostics.ExtendedData>"); } _InternalBuildRaw(writer, "</Event>"); }
public ILoggingConfigurationSendToRollingFileTraceListener WithTraceOptions(TraceOptions traceOptions) { rollingTraceListenerData.TraceOutputOptions = traceOptions; return(this); }
/// <summary> /// Init the specified eventCache, source, eventType, id, format and data. /// </summary> /// <param name="listener">The listener the message is for</param> /// <param name="eventCache">Event cache</param> /// <param name="source">Source</param> /// <param name="eventType">Event type</param> /// <param name="id">Identifier</param> /// <param name="format">Message</param> private void Init(TraceEventCache eventCache, TraceSource source, System.Diagnostics.TraceEventType eventType, int id, string format, object data) { EventCache = eventCache; Source = source; EventType = eventType; Id = id; Format = format; Data = data; Frame = new StackFrame(3, true); OutputOptions = TraceOptions.None; }
/// <summary> /// Creates a new <see cref="ISpanContext"/> with the given identifiers and options. /// </summary> /// <param name="traceId">The <see cref="ITraceId"/> to associate with the <see cref="ISpanContext"/>.</param> /// <param name="spanId">The <see cref="ISpanId"/> to associate with the <see cref="ISpanContext"/>.</param> /// <param name="traceOptions">The <see cref="TraceOptions"/> to associate with the <see cref="ISpanContext"/>.</param> /// <param name="tracestate">The <see cref="Tracestate"/> to associate with the <see cref="ISpanContext"/>.</param> /// <returns>A new <see cref="ISpanContext"/> with the given identifiers and options.</returns> public static ISpanContext Create(ITraceId traceId, ISpanId spanId, TraceOptions traceOptions, Tracestate tracestate) { return(new SpanContext(traceId, spanId, traceOptions, tracestate)); }
internal bool IsEnabled(TraceOptions opts) { return (opts & TraceOutputOptions) != 0; }
public InProcessSampledSpanStoreTest() { timestamp = Timestamp.FromDateTimeOffset(startTime); timestampConverter = Timer.StartNew(startTime, () => interval); sampledSpanContext = SpanContext.Create(TraceId.GenerateRandomId(random), SpanId.GenerateRandomId(random), TraceOptions.Builder().SetIsSampled(true).Build(), Tracestate.Empty); notSampledSpanContext = SpanContext.Create(TraceId.GenerateRandomId(random), SpanId.GenerateRandomId(random), TraceOptions.Default, Tracestate.Empty); parentSpanId = SpanId.GenerateRandomId(random); startEndHandler = new TestStartEndHandler(sampleStore); sampleStore.RegisterSpanNamesForCollection(new List <string>() { REGISTERED_SPAN_NAME }); }
/// <summary> /// Initializes a new instance of the <see cref="CommonLoggingEntlibTraceListenerData"/> class. /// </summary> /// <param name="name">The name.</param> /// <param name="traceListenerType">Type of the trace listener.</param> /// <param name="loggerNameFormat">The logger name format.</param> /// <param name="formatterName">Name of the formatter.</param> /// <param name="traceOutputOptions">The trace output options.</param> public CommonLoggingEntlibTraceListenerData(string name, Type traceListenerType, string loggerNameFormat, string formatterName, TraceOptions traceOutputOptions) : base(name, traceListenerType, traceOutputOptions) { LoggerNameFormat = loggerNameFormat; Formatter = formatterName; }
/// <summary> /// Initializes a <see cref="FormattedAppInsightsTraceListenerData"/>. /// </summary> /// <param name="name">Name of the listener.</param> /// <param name="instrumentationKey">Component id used to send the logs which identifies component uniquely.</param> /// <param name="formatter">Formatter name to be used to format the message.</param> /// <param name="traceOutputOptions">Specifies trace data options to be written to the trace output.</param> public FormattedAppInsightsTraceListenerData(string name, string instrumentationKey, string formatter, TraceOptions traceOutputOptions) : this(name, typeof(FormattedAppInsightsTraceListener), instrumentationKey, traceOutputOptions, formatter) { }
/// <summary> /// Initializes a <see cref="FormattedAppInsightsTraceListenerData"/>. /// </summary> /// <param name="name">Name of the listener.</param> /// <param name="listenerType">Type of the listener.</param> /// <param name="instrumentationKey">Component id used to send the logs which identifies component uniquely.</param> /// <param name="traceOutputOptions">Specifies trace data options to be written to the trace output.</param> /// <param name="formatterName">Formatter name to be used to format the message.</param> private FormattedAppInsightsTraceListenerData(string name, Type listenerType, string instrumentationKey, TraceOptions traceOutputOptions, string formatterName) : base(name, listenerType, traceOutputOptions) { this.InstrumentationKey = instrumentationKey; this.Formatter = formatterName; }
/// <summary> /// Initializes a <see cref="EmailTraceListenerData"/> with a toaddress, /// fromaddress, subjectLineStarter, subjectLineEnder, smtpServer, a formatter name, trace options /// and authentication information. /// </summary> /// <param name="name">The name of this listener</param> /// <param name="toAddress">A semicolon delimited string the represents to whom the email should be sent.</param> /// <param name="fromAddress">Represents from whom the email is sent.</param> /// <param name="subjectLineStarter">Starting text for the subject line.</param> /// <param name="subjectLineEnder">Ending text for the subject line.</param> /// <param name="smtpServer">The name of the SMTP server.</param> /// <param name="smtpPort">The port on the SMTP server to use for sending the email.</param> /// <param name="formatterName">The name of the Formatter <see cref="ILogFormatter"/> which determines how the ///email message should be formatted</param> /// <param name="traceOutputOptions">The trace options.</param> /// <param name="filter">The filter to apply.</param> /// <param name="authenticationMode">Authenticate mode to use.</param> /// <param name="userName">User name to pass to the server if using <see cref="EmailAuthenticationMode.UserNameAndPassword"/>.</param> /// <param name="password">Password to pass to the server if using <see cref="EmailAuthenticationMode.UserNameAndPassword"/>.</param> /// <param name="useSSL">Connect to the server using SSL?</param> public EmailTraceListenerData(string name, string toAddress, string fromAddress, string subjectLineStarter, string subjectLineEnder, string smtpServer, int smtpPort, string formatterName, TraceOptions traceOutputOptions, SourceLevels filter, EmailAuthenticationMode authenticationMode, string userName, string password, bool useSSL) : base(name, typeof(EmailTraceListener), traceOutputOptions, filter) { this.ToAddress = toAddress; this.FromAddress = fromAddress; this.SubjectLineStarter = subjectLineStarter; this.SubjectLineEnder = subjectLineEnder; this.SmtpServer = smtpServer; this.SmtpPort = smtpPort; this.Formatter = formatterName; this.AuthenticationMode = authenticationMode; this.UserName = userName; this.Password = password; this.UseSSL = useSSL; }
private bool IsEnabled(TraceOptions opts) { return((opts & TraceOutputOptions) != 0); }
private static void BuildHeader(StringBuilder writer, String source, TraceEventType eventType, int id, TraceEventCache eventCache, string relatedActivityId, bool isUserData, TraceOptions opts) { _InternalBuildRaw(writer, s_eventHeader); // Ideally, we want to enable provider guid at the TraceSource level // We can't blindly use the source param here as we need to a valid guid! //_InternalBuildRaw(writer, source); // For now, trace empty guid for provider id _InternalBuildRaw(writer, "{00000000-0000-0000-0000-000000000000}"); _InternalBuildRaw(writer, "\"/><EventID>"); _InternalBuildRaw(writer, ((uint)((id <0)?0:id)).ToString(CultureInfo.InvariantCulture)); _InternalBuildRaw(writer, "</EventID>"); _InternalBuildRaw(writer, "<Level>"); int sev = (int)eventType; int op = sev; // Treat overflow conditions as Information // Logical operation events (>255) such as Start/Stop will fall into this bucket if ((sev > 255) || (sev < 0)) sev = 0x08; _InternalBuildRaw(writer, sev.ToString(CultureInfo.InvariantCulture)); _InternalBuildRaw(writer, "</Level>"); // Logical operation events (>255) such as Start/Stop will be morphed into a byte value if (op > 255) { op /= 256; _InternalBuildRaw(writer, "<Opcode>"); _InternalBuildRaw(writer, op.ToString(CultureInfo.InvariantCulture)); _InternalBuildRaw(writer, "</Opcode>"); } if ((TraceOptions.DateTime & opts) != 0) { _InternalBuildRaw(writer, "<TimeCreated SystemTime=\""); if (eventCache != null) _InternalBuildRaw(writer, eventCache.DateTime.ToString("o", CultureInfo.InvariantCulture)); else _InternalBuildRaw(writer, DateTime.UtcNow.ToString("o", CultureInfo.InvariantCulture)); _InternalBuildRaw(writer, "\"/>"); } // Currently correlation is always traced, we could optimize this further _InternalBuildRaw(writer, "<Correlation ActivityID=\""); // ActivityId is typed as GUID by Correlation manager but most tracing usage typically calls ToString which is costly! _InternalBuildRaw(writer, Trace.CorrelationManager.ActivityId.ToString("B")); if (relatedActivityId != null) { _InternalBuildRaw(writer, "\" RelatedActivityID=\""); _InternalBuildRaw(writer, relatedActivityId); } _InternalBuildRaw(writer, "\"/>"); // Currently not tracing ProcessName as there is no place for it in the SystemProperties // Should we bother adding this to our own section? if (eventCache != null && ((TraceOptions.ProcessId | TraceOptions.ThreadId) & opts) != 0) { _InternalBuildRaw(writer, "<Execution "); _InternalBuildRaw(writer, "ProcessID=\""); // Review ProcessId as string can be cached! _InternalBuildRaw(writer, ((uint)eventCache.ProcessId).ToString(CultureInfo.InvariantCulture)); _InternalBuildRaw(writer, "\" "); _InternalBuildRaw(writer, "ThreadID=\""); _InternalBuildRaw(writer, eventCache.ThreadId); _InternalBuildRaw(writer, "\""); _InternalBuildRaw(writer, "/>"); } //_InternalBuildRaw(writer, "<Channel/>"); _InternalBuildRaw(writer, "<Computer>"); _InternalBuildRaw(writer, machineName); _InternalBuildRaw(writer, "</Computer>"); _InternalBuildRaw(writer, "</System>"); if (!isUserData) { _InternalBuildRaw(writer, "<EventData>"); } else { _InternalBuildRaw(writer, "<UserData>"); } }
/// <summary> /// Initializes a <see cref="HtmlEmailTraceListenerData"/> with a toaddress, /// fromaddress, subjectLineStarter, subjectLineEnder, smtpServer, a formatter name and trace options. /// </summary> /// <param name="name">The name of this listener</param> /// <param name="toAddress">A semicolon delimited string the represents to whom the email should be sent.</param> /// <param name="fromAddress">Represents from whom the email is sent.</param> /// <param name="subjectLineStarter">Starting text for the subject line.</param> /// <param name="subjectLineEnder">Ending text for the subject line.</param> /// <param name="smtpServer">The name of the SMTP server.</param> /// <param name="smtpPort">The port on the SMTP server to use for sending the email.</param> /// <param name="formatterName">The name of the Formatter <see cref="ILogFormatter"/> which determines how the ///email message should be formatted</param> /// <param name="traceOutputOptions">The trace options.</param> /// <param name="filter">The filter to apply.</param> public HtmlEmailTraceListenerData(string name, string toAddress, string fromAddress, string subjectLineStarter, string subjectLineEnder, string smtpServer, int smtpPort, string formatterName, TraceOptions traceOutputOptions, SourceLevels filter) : base(name, typeof(EmailTraceListener), traceOutputOptions, filter) { this.ToAddress = toAddress; this.FromAddress = fromAddress; this.SubjectLineStarter = subjectLineStarter; this.SubjectLineEnder = subjectLineEnder; this.SmtpServer = smtpServer; this.SmtpPort = smtpPort; this.Formatter = formatterName; }
internal bool IsEnabled(TraceOptions opts) { return ((opts & this.TraceOutputOptions) != TraceOptions.None); }
public void StartRemoteChildSpan_WithProbabilitySamplerDefaultSampler() { var configMock = Mock.Get <ITraceConfig>(traceConfig); configMock.Setup((c) => c.ActiveTraceParams).Returns(TraceParams.DEFAULT); // This traceId will not be sampled by the ProbabilitySampler because the first 8 bytes as long // is not less than probability * Long.MAX_VALUE; ITraceId traceId = TraceId.FromBytes( new byte[] { (byte)0x8F, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, 0, 0, 0, 0, 0, 0, 0, 0 }); // If parent is sampled then the remote child must be sampled. ISpan childSpan = SpanBuilder.CreateWithRemoteParent( SPAN_NAME, SpanContext.Create( traceId, SpanId.GenerateRandomId(randomHandler), TraceOptions.Builder().SetIsSampled(true).Build()), spanBuilderOptions) .StartSpan(); Assert.True(childSpan.Context.IsValid); Assert.Equal(traceId, childSpan.Context.TraceId); Assert.True(childSpan.Context.TraceOptions.IsSampled); childSpan.End(); Assert.Equal(TraceParams.DEFAULT, traceConfig.ActiveTraceParams); // If parent is not sampled then the remote child must be not sampled. childSpan = SpanBuilder.CreateWithRemoteParent( SPAN_NAME, SpanContext.Create( traceId, SpanId.GenerateRandomId(randomHandler), TraceOptions.DEFAULT), spanBuilderOptions) .StartSpan(); Assert.True(childSpan.Context.IsValid); Assert.Equal(traceId, childSpan.Context.TraceId); Assert.False(childSpan.Context.TraceOptions.IsSampled); childSpan.End(); }
/// <summary> /// Initializes a named instance of <see cref="FormattedEventLogTraceListenerData"/> with name, source name /// log name, machine name, formatter name, and <see cref="TraceOptions"/>. /// </summary> /// <param name="name">The name.</param> /// <param name="source">The event log source name.</param> /// <param name="logName">The log name.</param> /// <param name="machineName">The machine name.</param> /// <param name="formatterName">The formatter name.</param> /// <param name="traceOutputOptions">The output options.</param> public FormattedEventLogTraceListenerData(string name, string source, string logName, string machineName, string formatterName, TraceOptions traceOutputOptions) : base(name, typeof(FormattedEventLogTraceListener), traceOutputOptions) { this.Source = source; this.Log = logName; this.MachineName = machineName; this.Formatter = formatterName; }
public ILoggingConfigurationSendToFlatFileTraceListener WithTraceOptions(TraceOptions traceOptions) { flatFileTracelistenerData.TraceOutputOptions = traceOptions; return(this); }
protected override void Act() { trOption = TraceOptions.Callstack | TraceOptions.DateTime; base.FlatFileListenerBuilder.WithTraceOptions(trOption); }
public void Propagate_SpanContextTracingEnabled() { TestSpanContextConversion( SpanContext.Create(TRACE_ID, SPAN_ID, TraceOptions.Builder().SetIsSampled(true).Build(), Tracestate.Empty)); }
internal bool IsEnabled(TraceOptions opts) { return((opts & TraceOutputOptions) != 0); }
public ILoggingConfigurationSendToFlatFileTraceListener WithTraceOptions(TraceOptions traceOptions) { flatFileTracelistenerData.TraceOutputOptions = traceOptions; return this; }
public ILoggingConfigurationSendToMsmqTraceListener WithTraceOptions(TraceOptions traceOptions) { msmqTraceListener.TraceOutputOptions = traceOptions; return(this); }
/// <summary> /// Initializes trace handler to write text data /// </summary> /// <param name="traceSource">Trace source that holds a set of handlers</param> /// <param name="filterLevels">The level of trace message filtered by trace listener</param> /// <param name="traceOptions">Trace data options that has to be written in the trace output</param> /// <param name="traceFileFormat">File format component for the handler</param> public FileTraceHandler(TraceSource traceSource, SourceLevels filterLevels, TraceOptions traceOptions, ITraceFileFormat traceFileFormat) : base(traceSource, filterLevels, traceOptions, traceFileFormat) { }
private bool IsEnabled(TraceOptions opts) { return((opts & base.TraceOutputOptions) != TraceOptions.None); }
protected override void Act() { trOption = TraceOptions.Callstack | TraceOptions.DateTime; base.EmailTraceListenerBuilder.WithTraceOptions(trOption); }
/// <summary> /// Initializes a <see cref="EmailTraceListenerData"/> with a toaddress, /// fromaddress, subjectLineStarter, subjectLineEnder, smtpServer, a formatter name and trace options. /// </summary> /// <param name="name">The name of this listener</param> /// <param name="toAddress">A semicolon delimited string the represents to whom the email should be sent.</param> /// <param name="fromAddress">Represents from whom the email is sent.</param> /// <param name="subjectLineStarter">Starting text for the subject line.</param> /// <param name="subjectLineEnder">Ending text for the subject line.</param> /// <param name="smtpServer">The name of the SMTP server.</param> /// <param name="smtpPort">The port on the SMTP server to use for sending the email.</param> /// <param name="formatterName">The name of the Formatter <see cref="ILogFormatter"/> which determines how the ///email message should be formatted</param> ///<param name="traceOutputOptions">The trace options.</param> public EmailTraceListenerData(string name, string toAddress, string fromAddress, string subjectLineStarter, string subjectLineEnder, string smtpServer, int smtpPort, string formatterName, TraceOptions traceOutputOptions) : base(name, typeof(EmailTraceListener), traceOutputOptions) { this.ToAddress = toAddress; this.FromAddress = fromAddress; this.SubjectLineStarter = subjectLineStarter; this.SubjectLineEnder = subjectLineEnder; this.SmtpServer = smtpServer; this.SmtpPort = smtpPort; this.Formatter = formatterName; }
public void Add(TraceOptions option) { this.trace.Add(option); }
public InProcessSampledSpanStoreTest() { sampledSpanContext = SpanContext.Create(TraceId.GenerateRandomId(random), SpanId.GenerateRandomId(random), TraceOptions.Builder().SetIsSampled(true).Build()); notSampledSpanContext = SpanContext.Create(TraceId.GenerateRandomId(random), SpanId.GenerateRandomId(random), TraceOptions.DEFAULT); parentSpanId = SpanId.GenerateRandomId(random); startEndHandler = new TestStartEndHandler(sampleStore); sampleStore.RegisterSpanNamesForCollection(new List <string>() { REGISTERED_SPAN_NAME }); }