Esempio n. 1
0
        /// <summary>
        /// Agrega un nuevo contador a la categoría
        /// </summary>
        /// <param name="counterName">Nombre del contador</param>
        /// <param name="counterDescription">Descripción del contador</param>
        /// <param name="counterType">Tipo del contador</param>
        /// <param name="hasBaseCounter">Indica si el contador tiene contador base asociado</param>
        private void AddCounter(string counterName, string counterDescription,
                                AlemanaPerformanceCounterType counterType, bool hasBaseCounter)
        {
            if (this.isDisposed)
            {
                throw new InstrumentationException(new ObjectDisposedException(Messages.ResourceDisposed),
                                                   Messages.ResourceDisposed);
            }

            if (counterDataList.ContainsKey(counterName))
            {
                throw new InstrumentationException(string.Format(
                                                       Messages.CategoryAlreadyHasCounterName, this.Name,
                                                       counterName));
            }

            CounterData counterData = new CounterData()
            {
                Name           = counterName,
                Description    = counterDescription,
                Type           = Utils.ToPerformanceCounterType(counterType),
                HasBaseCounter = hasBaseCounter
            };

            if (hasBaseCounter)
            {
                counterData.BaseName        = counterName + "Base";
                counterData.BaseDescription = "Contador base de " + counterName;
                counterData.BaseType        = Utils.ToPerformanceCounterBaseType(counterType);
            }

            counterDataList.Add(counterName, counterData);
        }
Esempio n. 2
0
        /// <summary>
        /// Agrega una nueva instancia de contador
        /// </summary>
        /// <param name="counterName">Nombre del contador que contendrá a la instancia</param>
        /// <param name="instanceName">Nombre de la instancia</param>
        /// <param name="isActive">Indica si la instancia está activa</param>
        internal void AddCounterInstance(string counterName, string instanceName, bool isActive)
        {
            if (this.isDisposed)
            {
                throw new InstrumentationException(new ObjectDisposedException(Messages.ResourceDisposed),
                                                   Messages.ResourceDisposed);
            }

            if (counterDataList.ContainsKey(counterName))
            {
                CounterData counterData = counterDataList[counterName];
                counterData.AddInstance(instanceName, isActive);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Obtiene un contador por su nombre
        /// </summary>
        /// <param name="counterName">Nombre del contador</param>
        /// <returns>Contador obtenido, o null en caso de no existir</returns>
        internal CounterData GetCounter(string counterName)
        {
            if (this.isDisposed)
            {
                throw new InstrumentationException(new ObjectDisposedException(Messages.ResourceDisposed),
                                                   Messages.ResourceDisposed);
            }

            CounterData counterData = null;

            if (counterDataList.ContainsKey(counterName))
            {
                counterData = counterDataList[counterName];
            }

            return(counterData);
        }