示例#1
0
 protected AbstractProducerWithMetricsFactory(ILogger <AbstractProducerWithMetricsFactory <TKey, TValue> > logger,
                                              AbstractKafkaProducerSettings settings, ISerializer <TKey> keySerializer, ISerializer <TValue> valueSerializer,
                                              IMetricsPublisher stats)
     : base(logger, settings, keySerializer, valueSerializer)
 {
     Stats = stats;
 }
 public MetricsScrapeAndUpload(IMetricsScraper scraper, IMetricsPublisher publisher, Guid metricsCollectorRuntimeId)
 {
     this.scraper   = Preconditions.CheckNotNull(scraper);
     this.publisher = Preconditions.CheckNotNull(publisher);
     Preconditions.CheckArgument(metricsCollectorRuntimeId != Guid.Empty);
     this.metricsCollectorRuntimeId = metricsCollectorRuntimeId;
 }
示例#3
0
 public MetricsWorker(IMetricsScraper scraper, IMetricsStorage storage, IMetricsPublisher uploader, ISystemTime systemTime = null)
 {
     this.scraper    = Preconditions.CheckNotNull(scraper, nameof(scraper));
     this.storage    = Preconditions.CheckNotNull(storage, nameof(storage));
     this.uploader   = Preconditions.CheckNotNull(uploader, nameof(uploader));
     this.systemTime = systemTime ?? SystemTime.Instance;
 }
示例#4
0
 public PerfMetricPublisherService(
     IMetricsPublisher metricsPublisher,
     IReadOnlyCollection <NamedPerformanceMetric> availablePerfMetrics)
 {
     this.metricsPublisher     = metricsPublisher;
     this.availablePerfMetrics = availablePerfMetrics;
 }
示例#5
0
        public void Configure(MobileCore core, ServiceConfiguration config)
        {
            this.identifier = config.Id;
            string metricsUrl = config.Url;

            this.publisher = new NetworkMetricsPublisher(metricsUrl);
        }
示例#6
0
 protected AbstractKafkaPipelineWithMetrics(ILogger <AbstractKafkaPipelineWithMetrics <TConsumerKey, TConsumerValue, TPipe> > logger,
                                            IConsumerFactory <TConsumerKey, TConsumerValue> consumerFactory,
                                            IMetricsPublisher stats,
                                            IServiceProvider serviceProvider)
     : base(logger, consumerFactory, serviceProvider)
 {
     _stats = stats;
 }
 protected AbstractConsumerWithMetricsFactory(ILogger <AbstractConsumerWithMetricsFactory <TKey, TValue> > logger,
                                              AbstractKafkaConsumerSettings settings,
                                              IDeserializer <TValue> valueDeserializer,
                                              IMetricsPublisher stats)
     : base(logger, settings, valueDeserializer)
 {
     Stats = stats;
 }
示例#8
0
 public SymbolServiceEventProcessor(
     IWebHostEnvironment environment,
     IMetricsPublisher metrics,
     IOptions <SymbolServiceOptions> options)
 {
     _environment = environment;
     _metrics     = metrics;
     _options     = options.Value;
 }
示例#9
0
        public MetricsWorker(IMetricsScraper scraper, IMetricsStorage storage, IMetricsPublisher uploader)
        {
            this.scraper  = Preconditions.CheckNotNull(scraper, nameof(scraper));
            this.storage  = Preconditions.CheckNotNull(storage, nameof(storage));
            this.uploader = Preconditions.CheckNotNull(uploader, nameof(uploader));

            this.metricFilter = new MetricFilter()
                                .AddAllowedTags(new KeyValuePair <string, string>(MetricsConstants.MsTelemetry, true.ToString()))
                                .AddTagsToRemove(MetricsConstants.MsTelemetry, MetricsConstants.IotHubLabel, MetricsConstants.DeviceIdLabel);
        }
示例#10
0
        public MetricsWorker(IMetricsScraper scraper, IMetricsStorage storage, IMetricsPublisher uploader)
        {
            this.scraper  = Preconditions.CheckNotNull(scraper, nameof(scraper));
            this.storage  = Preconditions.CheckNotNull(storage, nameof(storage));
            this.uploader = Preconditions.CheckNotNull(uploader, nameof(uploader));

            this.metricFilter = new MetricTransformer()
                                .AddAllowedTags(new KeyValuePair <string, string>(MetricsConstants.MsTelemetry, true.ToString()))
                                .AddTagsToRemove(MetricsConstants.MsTelemetry, MetricsConstants.IotHubLabel, MetricsConstants.DeviceIdLabel)
                                .AddTagsToModify(("id", this.ReplaceDeviceId), ("module_name", name => name.CreateSha256()));
        }
示例#11
0
        public MetricsEventManager(IOptionsMonitor <AppServiceOptions> appServiceOptions, IEventGenerator generator, int functionActivityFlushIntervalSeconds, IMetricsPublisher metricsPublisher, int metricsFlushIntervalMS = DefaultFlushIntervalMS)
        {
            // we read these in the ctor (not static ctor) since it can change on the fly
            _appServiceOptions = appServiceOptions;
            _eventGenerator    = generator;
            _functionActivityFlushIntervalSeconds = functionActivityFlushIntervalSeconds;
            QueuedEvents = new ConcurrentDictionary <string, SystemMetricEvent>(StringComparer.OrdinalIgnoreCase);

            // Initialize the periodic log flush timer
            _metricsFlushTimer = new Timer(TimerFlush, null, metricsFlushIntervalMS, metricsFlushIntervalMS);

            _metricsPublisher = metricsPublisher;
        }
示例#12
0
        public MetricsEventManager(IEnvironment environment, IEventGenerator generator, int functionActivityFlushIntervalSeconds, IMetricsPublisher metricsPublisher, int metricsFlushIntervalMS = DefaultFlushIntervalMS)
        {
            // we read these in the ctor (not static ctor) since it can change on the fly
            appName        = GetNormalizedString(environment.GetAzureWebsiteUniqueSlotName());
            subscriptionId = environment.GetSubscriptionId() ?? string.Empty;

            _eventGenerator = generator;
            _functionActivityFlushIntervalSeconds = functionActivityFlushIntervalSeconds;
            QueuedEvents = new ConcurrentDictionary <string, SystemMetricEvent>(StringComparer.OrdinalIgnoreCase);

            // Initialize the periodic log flush timer
            _metricsFlushTimer = new Timer(TimerFlush, null, metricsFlushIntervalMS, metricsFlushIntervalMS);

            _metricsPublisher = metricsPublisher;
        }
            internal FunctionActivityTracker(IOptionsMonitor <AppServiceOptions> appServiceOptions, IEventGenerator generator, IMetricsPublisher metricsPublisher, ILinuxContainerActivityPublisher linuxContainerActivityPublisher, int functionActivityFlushInterval)
            {
                MetricsEventGenerator          = generator;
                _appServiceOptions             = appServiceOptions;
                _functionActivityFlushInterval = functionActivityFlushInterval;

                if (linuxContainerActivityPublisher != null && linuxContainerActivityPublisher != NullLinuxContainerActivityPublisher.Instance)
                {
                    _linuxContainerActivityPublisher = linuxContainerActivityPublisher;
                }

                if (metricsPublisher != null && metricsPublisher != NullMetricsPublisher.Instance)
                {
                    _metricsPublisher = metricsPublisher;
                }

                Task.Run(
                    async() =>
                {
                    try
                    {
                        int currentSecond = _functionActivityFlushInterval;
                        while (!_etwTaskCancellationSource.Token.IsCancellationRequested)
                        {
                            RaiseMetricsPerFunctionEvent();

                            if (currentSecond >= _functionActivityFlushInterval)
                            {
                                RaiseFunctionMetricEvents();
                                currentSecond = 0;
                            }
                            else
                            {
                                currentSecond = currentSecond + 1;
                            }

                            await Task.Delay(TimeSpan.FromSeconds(1), _etwTaskCancellationSource.Token);
                        }
                    }
                    catch (TaskCanceledException)
                    {
                        // This exception gets throws when cancellation request is raised via cancellation token.
                        // Let's eat this exception and continue
                    }
                },
                    _etwTaskCancellationSource.Token);
            }
示例#14
0
            internal FunctionActivityTracker(IOptionsMonitor <AppServiceOptions> appServiceOptions, IEventGenerator generator, IMetricsPublisher metricsPublisher, ILinuxContainerActivityPublisher linuxContainerActivityPublisher, int functionActivityFlushInterval)
            {
                MetricsEventGenerator          = generator;
                _appServiceOptions             = appServiceOptions;
                _functionActivityFlushInterval = functionActivityFlushInterval;

                if (linuxContainerActivityPublisher != null && linuxContainerActivityPublisher != NullLinuxContainerActivityPublisher.Instance)
                {
                    _linuxContainerActivityPublisher = linuxContainerActivityPublisher;
                }

                if (metricsPublisher != null && metricsPublisher != NullMetricsPublisher.Instance)
                {
                    _metricsPublisher = metricsPublisher;
                }

                StartActivityTimer();
            }
示例#15
0
            internal FunctionActivityTracker(IOptionsMonitor <AppServiceOptions> appServiceOptions, IEventGenerator generator, IMetricsPublisher metricsPublisher, ILinuxContainerActivityPublisher linuxContainerActivityPublisher, int functionActivityFlushInterval, ILogger <MetricsEventManager> logger)
            {
                MetricsEventGenerator          = generator;
                _appServiceOptions             = appServiceOptions;
                _functionActivityFlushInterval = functionActivityFlushInterval;

                if (linuxContainerActivityPublisher != null && linuxContainerActivityPublisher != NullLinuxContainerActivityPublisher.Instance)
                {
                    _linuxContainerActivityPublisher = linuxContainerActivityPublisher;
                }

                if (metricsPublisher != null && metricsPublisher != NullMetricsPublisher.Instance)
                {
                    _metricsPublisher = metricsPublisher;
                }

                _activityFlushCounter = _functionActivityFlushInterval;
                _activityTimer        = new Timer(TimerFlush, null, _activityTimerIntervalMS, _activityTimerIntervalMS);

                _logger = logger;
            }
        public SymsorterBatchFinalizer(
            IMetricsPublisher metrics,
            IOptions <SymbolServiceOptions> options,
            ISymbolGcsWriter gcsWriter,
            BundleIdGenerator bundleIdGenerator,
            IHub hub,
            ILogger <SymsorterBatchFinalizer> logger)
        {
            _options           = options?.Value ?? throw new ArgumentNullException(nameof(options));
            _metrics           = metrics;
            _logger            = logger ?? throw new ArgumentNullException(nameof(logger));
            _gcsWriter         = gcsWriter ?? throw new ArgumentNullException(nameof(gcsWriter));
            _bundleIdGenerator = bundleIdGenerator;
            _hub = hub;
            if (!File.Exists(_options.SymsorterPath))
            {
                throw new ArgumentException($"Symsorter not found at: {_options.SymsorterPath}");
            }

            _symsorterOutputPath = Path.Combine(_options.BaseWorkingPath, "symsorter_output");
            Directory.CreateDirectory(_symsorterOutputPath);
        }
示例#17
0
        protected override void Load(ContainerBuilder builder)
        {
            // IMetricsScraper
            builder.Register(c => new MetricsScraper(new string[] { "http://edgeHub:9600/metrics", "http://edgeAgent:9600/metrics" }))
            .As <IMetricsScraper>()
            .SingleInstance();

            // Task<IMetricsStorage>
            builder.Register(async c =>
            {
                IStoreProvider storeProvider = await c.Resolve <Task <IStoreProvider> >();
                ISequentialStore <IEnumerable <Metric> > dataStore = await storeProvider.GetSequentialStore <IEnumerable <Metric> >("Metrics");

                return(new MetricsStorage(dataStore) as IMetricsStorage);
            })
            .As <Task <IMetricsStorage> >()
            .SingleInstance();

            // IMetricsPublisher
            builder.RegisterType <EdgeRuntimeDiagnosticsUpload>()
            .As <IMetricsPublisher>()
            .SingleInstance();

            // Task<MetricsWorker>
            builder.Register(async c =>
            {
                IMetricsScraper scraper        = c.Resolve <IMetricsScraper>();
                IMetricsPublisher publisher    = c.Resolve <IMetricsPublisher>();
                Task <IMetricsStorage> storage = c.Resolve <Task <IMetricsStorage> >();

                return(new MetricsWorker(scraper, await storage, publisher));
            })
            .As <Task <MetricsWorker> >()
            .SingleInstance();

            base.Load(builder);
        }
示例#18
0
            internal FunctionActivityTracker(IEventGenerator generator, IMetricsPublisher metricsPublisher, int functionActivityFlushInterval)
            {
                MetricsEventGenerator          = generator;
                _functionActivityFlushInterval = functionActivityFlushInterval;
                _metricsPublisher = metricsPublisher;
                Task.Run(
                    async() =>
                {
                    try
                    {
                        int currentSecond = _functionActivityFlushInterval;
                        while (!_etwTaskCancellationSource.Token.IsCancellationRequested)
                        {
                            RaiseMetricsPerFunctionEvent();

                            if (currentSecond >= _functionActivityFlushInterval)
                            {
                                RaiseFunctionMetricEvents();
                                currentSecond = 0;
                            }
                            else
                            {
                                currentSecond = currentSecond + 1;
                            }

                            await Task.Delay(TimeSpan.FromSeconds(1), _etwTaskCancellationSource.Token);
                        }
                    }
                    catch (TaskCanceledException)
                    {
                        // This exception gets throws when cancellation request is raised via cancellation token.
                        // Let's eat this exception and continue
                    }
                },
                    _etwTaskCancellationSource.Token);
            }
示例#19
0
        public MetricsWorker(IMetricsScraper scraper, IMetricsStorage storage, IMetricsPublisher uploader)
        {
            this.scraper  = Preconditions.CheckNotNull(scraper, nameof(scraper));
            this.storage  = Preconditions.CheckNotNull(storage, nameof(storage));
            this.uploader = Preconditions.CheckNotNull(uploader, nameof(uploader));

            this.metricFilter = new MetricTransformer()
                                .AddAllowedTags((MetricsConstants.MsTelemetry, true.ToString()))
                                .AddDisallowedTags(
                ("quantile", "0.1"),
                ("quantile", "0.5"),
                ("quantile", "0.99"))
                                .AddTagsToRemove(MetricsConstants.MsTelemetry, MetricsConstants.IotHubLabel, MetricsConstants.DeviceIdLabel)
                                .AddTagsToModify(
                ("id", this.ReplaceDeviceId),
                ("module_name", this.ReplaceModuleId),
                ("to", name => name.CreateSha256()),
                ("from", name => name.CreateSha256()),
                ("to_route_input", name => name.CreateSha256()),
                ("from_route_output", name => name.CreateSha256()));

#pragma warning disable SA1111 // Closing parenthesis should be on line of last parameter
            this.metricAggregator = new MetricAggregator(
                new AggregationTemplate("edgehub_gettwin_total", "id", new Summer()),
                new AggregationTemplate(
                    "edgehub_messages_received_total",
                    ("route_output", new Summer()),
                    ("id", new Summer())
                    ),
                new AggregationTemplate(
                    "edgehub_messages_sent_total",
                    ("from", new Summer()),
                    ("to", new Summer()),
                    ("from_route_output", new Summer()),
                    ("to_route_input", new Summer())
                    ),
                new AggregationTemplate(
                    new string[]
            {
                "edgehub_message_size_bytes",
                "edgehub_message_size_bytes_sum",
                "edgehub_message_size_bytes_count"
            },
                    "id",
                    new Averager()),
                new AggregationTemplate(
                    new string[]
            {
                "edgehub_message_process_duration_seconds",
                "edgehub_message_process_duration_seconds_sum",
                "edgehub_message_process_duration_seconds_count",
            },
                    ("from", new Averager()),
                    ("to", new Averager())
                    ),
                new AggregationTemplate(
                    "edgehub_direct_methods_total",
                    ("from", new Summer()),
                    ("to", new Summer())
                    ),
                new AggregationTemplate("edgehub_queue_length", "endpoint", new Summer()),
                new AggregationTemplate(
                    new string[]
            {
                "edgehub_messages_dropped_total",
                "edgehub_messages_unack_total",
            },
                    ("from", new Summer()),
                    ("from_route_output", new Summer())
                    ),
                new AggregationTemplate("edgehub_client_connect_failed_total", "id", new Summer())
                );
#pragma warning restore SA1111 // Closing parenthesis should be on line of last parameter
        }
示例#20
0
        public MetricsEventManager(IOptionsMonitor <AppServiceOptions> appServiceOptions, IEventGenerator generator, int functionActivityFlushIntervalSeconds, IMetricsPublisher metricsPublisher, ILinuxContainerActivityPublisher linuxContainerActivityPublisher, ILogger <MetricsEventManager> logger, int metricsFlushIntervalMS = DefaultFlushIntervalMS)
        {
            _logger = logger ?? throw new ArgumentNullException(nameof(logger));

            // we read these in the ctor (not static ctor) since it can change on the fly
            _appServiceOptions = appServiceOptions;
            _eventGenerator    = generator;
            _functionActivityFlushIntervalSeconds = functionActivityFlushIntervalSeconds;
            QueuedEvents = new ConcurrentDictionary <string, SystemMetricEvent>(StringComparer.OrdinalIgnoreCase);

            // Initialize the periodic log flush timer
            _metricsFlushTimer = new Timer(TimerFlush, null, metricsFlushIntervalMS, metricsFlushIntervalMS);

            _functionActivityTracker = new FunctionActivityTracker(_appServiceOptions, _eventGenerator, metricsPublisher, linuxContainerActivityPublisher, _functionActivityFlushIntervalSeconds, _logger);
        }
示例#21
0
 public MetricsWorker(IMetricsScraper scraper, IMetricsStorage storage, IMetricsPublisher uploader)
 {
     this.scraper  = Preconditions.CheckNotNull(scraper, nameof(scraper));
     this.storage  = Preconditions.CheckNotNull(storage, nameof(storage));
     this.uploader = Preconditions.CheckNotNull(uploader, nameof(uploader));
 }
示例#22
0
 protected AbstractProducerWithMetricsFactory(ILogger <AbstractProducerWithMetricsFactory <TKey, TValue> > logger,
                                              AbstractKafkaProducerSettings settings, ISerializer <TValue> valueSerializer, IMetricsPublisher stats)
     : this(logger, settings, null, valueSerializer, stats)
 {
 }
示例#23
0
 public MetricsScrapeAndUpload(IMetricsScraper scraper, IMetricsPublisher publisher, Dictionary <string, string> additionalTags)
 {
     this.scraper        = Preconditions.CheckNotNull(scraper);
     this.publisher      = Preconditions.CheckNotNull(publisher);
     this.additionalTags = Preconditions.CheckNotNull(additionalTags);
 }
示例#24
0
 public Metrics(IMetricsPublisher stats)
 {
     _stats = stats;
 }
示例#25
0
 public WebHostMetricsLogger(IOptionsMonitor <AppServiceOptions> appServiceOptions, IEventGenerator eventGenerator, IMetricsPublisher metricsPublisher)
     : this(appServiceOptions, eventGenerator, metricsPublisher, 5)
 {
 }
示例#26
0
 public static Metrics Metric(this IMetricsPublisher stats)
 {
     return(new Metrics(stats));
 }
示例#27
0
 protected WebHostMetricsLogger(IOptionsMonitor <AppServiceOptions> appServiceOptions, IEventGenerator eventGenerator, IMetricsPublisher metricsPublisher, int metricEventIntervalInSeconds)
 {
     _metricsEventManager = new MetricsEventManager(appServiceOptions, eventGenerator, metricEventIntervalInSeconds, metricsPublisher);
 }
示例#28
0
 public WebHostMetricsLogger(IEnvironment environment, IEventGenerator eventGenerator, IMetricsPublisher metricsPublisher)
     : this(environment, eventGenerator, metricsPublisher, 5)
 {
 }
示例#29
0
 protected WebHostMetricsLogger(IEnvironment environment, IEventGenerator eventGenerator, IMetricsPublisher metricsPublisher, int metricEventIntervalInSeconds)
 {
     _metricsEventManager = new MetricsEventManager(environment, eventGenerator, metricEventIntervalInSeconds, metricsPublisher);
 }
示例#30
0
 protected internal KafkaProducerWithMetrics(ILogger logger, string topic, IProducer <TKey, TValue> producer,
                                             IMetricsPublisher stats)
     : base(logger, topic, producer)
 {
     _stats = stats;
 }