Ejemplo n.º 1
0
        public JavascriptMetric(string name, string jsAggregator)
            : base(name)
        {
            _javascript = jsAggregator;
            _aggregators = new Dictionary<string, PeriodMetric>();

            var javascriptErrorMessageContext = string.Format("{0} ({1})", name, "Metric Filter");
            _context = new JavascriptContext(jsAggregator, javascriptErrorMessageContext);

            try {
                var dimensions = _context.ExecuteFunction("dimensions", new string[] { });
                if (dimensions.IsArray()) {
                    var ad = dimensions.AsArray();
                    var length = (int)ad.Properties["length"].Value.Value.AsNumber();

                    _dimensions = new string[length];

                    foreach (var prop in ad.Properties) {
                        int index = 0;
                        if (int.TryParse(prop.Key, out index)) {
                            _dimensions[index] = prop.Value.Value.Value.AsString();
                        }
                    }

                }
            } catch (Exception ex) {
                Debug.WriteLine("Unable to load dimensions for metric: '{0}'.  {1}", Name, ex.Message);
            }

            _updateCallbacks = new ConcurrentDictionary<string, Action<List<JavascriptMetricUpdate>>>();
        }
Ejemplo n.º 2
0
        public JavascriptMetric(string name, string jsAggregator)
            : base(name)
        {
            _javascript  = jsAggregator;
            _aggregators = new Dictionary <string, PeriodMetric>();

            var javascriptErrorMessageContext = string.Format("{0} ({1})", name, "Metric Filter");

            _context = new JavascriptContext(jsAggregator, javascriptErrorMessageContext);

            try {
                var dimensions = _context.ExecuteFunction("dimensions", new string[] { });
                if (dimensions.IsArray())
                {
                    var ad     = dimensions.AsArray();
                    var length = (int)ad.Properties["length"].Value.Value.AsNumber();

                    _dimensions = new string[length];

                    foreach (var prop in ad.Properties)
                    {
                        int index = 0;
                        if (int.TryParse(prop.Key, out index))
                        {
                            _dimensions[index] = prop.Value.Value.Value.AsString();
                        }
                    }
                }
            } catch (Exception ex) {
                Debug.WriteLine("Unable to load dimensions for metric: '{0}'.  {1}", Name, ex.Message);
            }

            _updateCallbacks = new ConcurrentDictionary <string, Action <List <JavascriptMetricUpdate> > >();
        }
Ejemplo n.º 3
0
        public PeriodMetric(string name, string jsAggregator, string filter, TimePeriod period)
        {
            _name   = name;
            _filter = filter;
            _period = period;

            var javascriptErrorMessageContext = string.Format("{0} ({1})", _name, "Metric Aggregator");

            _context = new JavascriptContext(jsAggregator, javascriptErrorMessageContext);

            Initialize();
        }
Ejemplo n.º 4
0
        public PeriodMetric(string name, string jsAggregator, string filter, TimePeriod period)
        {
            _name = name;
            _filter = filter;
            _period = period;

            var javascriptErrorMessageContext = string.Format("{0} ({1})", _name, "Metric Aggregator");

            _context = new JavascriptContext(jsAggregator, javascriptErrorMessageContext);

            Initialize();
        }