/// <summary> /// Agrega un nuevo contador /// </summary> /// <param name="categoryName">Nombre de la categoría del contador</param> /// <param name="counterName">Nombre del contador</param> /// <param name="counterDescription">Descripción del contador</param> /// <param name="counterType">Tipo del contador</param> public static void AddCounter(string categoryName, string counterName, string counterDescription, AlemanaPerformanceCounterType counterType) { if (!isInitialized) { PerformanceCounterContainer.AddCounter(categoryName, counterName, counterDescription, counterType); } else { throw new InstrumentationException( "El InstrumentationProvider ya está inicializado. Debe llamar a este método antes de llamar a Initialize()"); } }
/// <summary> /// Carga la configuración a partir de <paramref name="section"/> /// </summary> /// <param name="section">Sección de configuración del archivo de configuración</param> private static void LoadConfigurationFromConfigurationSection( InstrumentationSection section) { foreach (PerformanceCounterCategoryElement categoryElement in section.CategoryCollection) { PerformanceCounterContainer.AddPerformanceCounterCategory(categoryElement.Name, categoryElement.Description, categoryElement.IsActive, categoryElement.Type); foreach (PerformanceCounterElement counterElement in categoryElement.PerformanceCounterCollection) { PerformanceCounterContainer.AddCounter(categoryElement.Name, counterElement.Name, counterElement.Description, counterElement.Type); foreach (PerformanceCounterInstanceElement instanceElement in counterElement.InstanceCollection) { PerformanceCounterContainer.AddCounterInstance(categoryElement.Name, counterElement.Name, instanceElement.Name, instanceElement.IsActive); } } } }