Пример #1
0
        public object CreateObject(IBuilderContext context, string name, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
        {
            InstrumentationConfigurationSection objectConfiguration
                = GetConfiguration(configurationSource);
            TracerInstrumentationListener createdObject
                = new TracerInstrumentationListener(objectConfiguration.PerformanceCountersEnabled);

            return(createdObject);
        }
		/// <summary>
		/// This method supports the Enterprise Library infrastructure and is not intended to be used directly from your code.
		/// Builds a <see cref="TracerInstrumentationListener"/>.
		/// </summary>
		/// <param name="context">The <see cref="IBuilderContext"/> that represents the current building process.</param>
		/// <param name="name">The name of the instance to build. It is part of the <see cref="ICustomFactory.CreateObject(IBuilderContext, string, IConfigurationSource, ConfigurationReflectionCache)"/> method, but it is not used in this implementation.</param>
		/// <param name="configurationSource">The source for configuration objects.</param>
		/// <param name="reflectionCache">The cache to use retrieving reflection information.</param>
		/// <returns>A fully initialized instance of <see cref="TracerInstrumentationListener"/>.</returns>
		public object CreateObject(IBuilderContext context, string name, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
        {
            InstrumentationConfigurationSection objectConfiguration
                = GetConfiguration(configurationSource);

            TracerInstrumentationListener createdObject
                = new TracerInstrumentationListener(objectConfiguration.PerformanceCountersEnabled);

            return createdObject;
        }
Пример #3
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);
			}
		}
        private void Initialize(string operation, TracerInstrumentationListener tracerInstrumentationListener)
        {
            instrumentationListener = tracerInstrumentationListener;

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

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

                WriteTraceStartMessage(startTitle);
            }
        }
        private static TracerInstrumentationListener GetInstrumentationListener(IConfigurationSource configurationSource)
        {
            TracerInstrumentationListener instrumentationListener;
            if (configurationSource != null)
            {
                instrumentationListener = EnterpriseLibraryFactory.BuildUp<TracerInstrumentationListener>(configurationSource);
            }
            else
            {
                instrumentationListener = new TracerInstrumentationListener(false);
            }

            return instrumentationListener;
        }
        /// <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="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 CustomTracer(string operation, LogWriter writer, TracerInstrumentationListener instrumentationListener)
        {
            if (instrumentationListener == null)
            {
                instrumentationListener = new TracerInstrumentationListener(false);
            }

            if (CheckTracingAvailable())
            {
                if (writer == null) throw new ArgumentNullException("writer", exceptionWriterShouldNotBeNull);

                if (GetActivityId().Equals(Guid.Empty))
                {
                    SetActivityId(Guid.NewGuid());
                }

                this.writer = writer;

                Initialize(operation, instrumentationListener);
            }
        }