Beispiel #1
0
        public async Task <MetricsDataValueSource> GetDataAsync(IMetricsFilter filter)
        {
            _logger.RetrievedMetricsData();

            if (_contexts.Count == 0)
            {
                return(MetricsDataValueSource.Empty);
            }

            var environment = await _environmentInfoProvider.BuildAsync();

            var contexts = _contexts.Values.Select(g => new MetricsContextValueSource(
                                                       g.Context,
                                                       g.DataProvider.Gauges.ToArray(),
                                                       g.DataProvider.Counters.ToArray(),
                                                       g.DataProvider.Meters.ToArray(),
                                                       g.DataProvider.Histograms.ToArray(),
                                                       g.DataProvider.Timers.ToArray(),
                                                       g.DataProvider.ApdexScores.ToArray()
                                                       ));

            var data = new MetricsDataValueSource(_clock.UtcDateTime, environment, contexts);

            _logger.GettingMetricsData();

            return(data.Filter(filter));
        }
Beispiel #2
0
        public static AppMetricsOptions WithGlobalTags(this AppMetricsOptions options, Action <Dictionary <string, string>, EnvironmentInfo> setupAction)
        {
            var environmentBuilder = new EnvironmentInfoProvider();
            var environmentInfo    = environmentBuilder.BuildAsync().GetAwaiter().GetResult();

            setupAction(options.GlobalTags, environmentInfo);

            return(options);
        }