Пример #1
0
 public TraceManager(LogWriter logWriter, TracerInstrumentationListener instrumentationListener)
 {
     if (logWriter == null)
     {
         throw new ArgumentNullException("logWriter");
     }
     this.logWriter = logWriter;
     this.instrumentationListener = instrumentationListener;
 }
Пример #2
0
        private void Initialize(string operation, TracerInstrumentationListener instrumentationListener)
        {
            this.instrumentationListener = instrumentationListener;

            StartLogicalOperation(operation);
            if (IsTracingEnabled())
            {
                instrumentationListener.TracerOperationStarted(PeekLogicalOperationStack() as string);

                stopwatch         = Stopwatch.StartNew();
                tracingStartTicks = Stopwatch.GetTimestamp();

                WriteTraceStartMessage(startTitle);
            }
        }
Пример #3
0
        private static TracerInstrumentationListener GetInstrumentationListener(IConfigurationSource configurationSource)
        {
            TracerInstrumentationListener instrumentationListener;

            if (configurationSource != null)
            {
                instrumentationListener = EnterpriseLibraryFactory.BuildUp <TracerInstrumentationListener>(configurationSource);
            }
            else
            {
                instrumentationListener = new TracerInstrumentationListener(false);
            }

            return(instrumentationListener);
        }
Пример #4
0
        public void SetUp()
        {
            nameFormatter                    = new AppDomainNameFormatter(applicationInstanceName);
            listener                         = new LoggingInstrumentationListener(instanceName, true, true, true, applicationInstanceName);
            tracerListener                   = new TracerInstrumentationListener(true);
            formattedInstanceName            = nameFormatter.CreateName(instanceName);
            totalLoggingEventsRaised         = new EnterpriseLibraryPerformanceCounter(counterCategoryName, TotalLoggingEventsRaised, formattedInstanceName);
            totalTraceListenerEntriesWritten = new EnterpriseLibraryPerformanceCounter(counterCategoryName, TotalTraceListenerEntriesWritten, formattedInstanceName);

            // Use AppDomainFriendlyName for the instance name
            nameFormatter         = new AppDomainNameFormatter();
            formattedInstanceName = nameFormatter.CreateName(instanceName);

            totalTraceOperationsStartedCounter = new EnterpriseLibraryPerformanceCounter(TracerInstrumentationListener.counterCategoryName, TracerInstrumentationListener.TotalTraceOperationsStartedCounterName, formattedInstanceName);
        }
        public void GetTracerFromTraceManagerWithInstrumentationEnabled()
        {
            MockTraceListener.Reset();
            LogSource source = new LogSource("tracesource", SourceLevels.All);

            source.Listeners.Add(new MockTraceListener());
            List <LogSource> traceSources = new List <LogSource>(new LogSource[] { source });
            LogWriter        lg           = new LogWriter(new List <ILogFilter>(), new List <LogSource>(), source, null, new LogSource("errors"), "default", true, false);
            TracerInstrumentationListener instrumentationListener = new TracerInstrumentationListener(true);
            TraceManager tm = new TraceManager(lg, instrumentationListener);

            Assert.IsNotNull(tm);
            using (tm.StartTrace("testoperation"))
            {
                Assert.AreEqual(1, MockTraceListener.Entries.Count);
            }
            Assert.AreEqual(2, MockTraceListener.Entries.Count);
        }
Пример #6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Tracer"/> class with the given logical operation name and activity id.
        /// </summary>
        /// <remarks>
        /// This is meant to be used internally
        /// </remarks>
        /// <param name="operation">The operation for the <see cref="Tracer"/></param>
        /// <param name="activityId">The activity id</param>
        /// <param name="writer">The <see cref="LogWriter"/> that is used to write trace messages</param>
        /// <param name="instrumentationListener">The <see cref="TracerInstrumentationListener"/> used to determine if instrumentation should be enabled</param>
        internal Tracer(string operation, Guid activityId, LogWriter writer, TracerInstrumentationListener instrumentationListener)
        {
            if (instrumentationListener == null)
            {
                instrumentationListener = new TracerInstrumentationListener(false);
            }

            if (CheckTracingAvailable())
            {
                if (writer == null)
                {
                    throw new ArgumentNullException("writer", Resources.ExceptionWriterShouldNotBeNull);
                }

                SetActivityId(activityId);

                this.writer = writer;

                Initialize(operation, instrumentationListener);
            }
        }
Пример #7
0
        private void Initialize(string operation, IConfigurationSource configurationSource)
        {
            if (configurationSource != null)
            {
                instrumentationListener = EnterpriseLibraryFactory.BuildUp <TracerInstrumentationListener>(configurationSource);
            }
            else
            {
                instrumentationListener = new TracerInstrumentationListener(false);
            }

            StartLogicalOperation(operation);
            if (IsTracingEnabled())
            {
                instrumentationListener.TracerOperationStarted(PeekLogicalOperationStack() as string);

                stopwatch         = Stopwatch.StartNew();
                tracingStartTicks = Stopwatch.GetTimestamp();

                WriteTraceStartMessage(startTitle);
            }
        }