public DeploymentMetrics(IMetricsProvider metricsProvider, string storageFolder, ISystemTime time = null) { this.systemTime = time ?? SystemTime.Instance; this.availabilities = new List <Availability>(); this.edgeAgent = new Lazy <Availability>(() => new Availability(Constants.EdgeAgentModuleName, this.CalculateEdgeAgentDowntime(), this.systemTime)); Preconditions.CheckNotNull(metricsProvider, nameof(metricsProvider)); this.running = metricsProvider.CreateGauge( "total_time_running_correctly_seconds", "The amount of time the module was specified in the deployment and was in the running state", new List <string> { "module_name", MetricsConstants.MsTelemetry }); this.expectedRunning = metricsProvider.CreateGauge( "total_time_expected_running_seconds", "The amount of time the module was specified in the deployment", new List <string> { "module_name", MetricsConstants.MsTelemetry }); this.unsuccessfulSyncs = metricsProvider.CreateCounter( "unsuccessful_iothub_syncs", "The amount of times edgeAgent failed to sync with iotHub", new List <string> { MetricsConstants.MsTelemetry }); this.totalSyncs = metricsProvider.CreateCounter( "iothub_syncs", "The amount of times edgeAgent attempted to sync with iotHub, both successful and unsuccessful", new List <string> { MetricsConstants.MsTelemetry }); this.deploymentTime = metricsProvider.CreateHistogram( "deployment_time_seconds", "The amount of time it took to complete a new deployment", new List <string> { MetricsConstants.MsTelemetry }); string storageDirectory = Path.Combine(Preconditions.CheckNonWhiteSpace(storageFolder, nameof(storageFolder)), "availability"); try { Directory.CreateDirectory(storageDirectory); this.checkpointFile = Path.Combine(storageDirectory, "avaliability.checkpoint"); this.updateCheckpointFile = new PeriodicTask(this.UpdateCheckpointFile, this.checkpointFrequency, this.checkpointFrequency, this.log, "Checkpoint Availability", false); } catch (Exception ex) { this.log.LogError(ex, "Could not create checkpoint directory"); } }
public CleanupProcessor(MessageStore messageStore, bool checkEntireQueueOnCleanup) { this.messageStore = messageStore; this.ensureCleanupTaskTimer = new Timer(this.EnsureCleanupTask, null, TimeSpan.Zero, CleanupTaskFrequency); this.cancellationTokenSource = new CancellationTokenSource(); this.checkEntireQueueOnCleanup = checkEntireQueueOnCleanup; this.expiredCounter = Metrics.Instance.CreateCounter( "messages_dropped", "Messages cleaned up because of TTL expired", new List <string> { "reason", "from", "from_route_output", MetricsConstants.MsTelemetry }); }
public ExceptionCounter(Dictionary <Type, string> recognizedExceptions, HashSet <Type> ignoredExceptions, IMetricsProvider metricsProvider) { this.recognizedExceptions = Preconditions.CheckNotNull(recognizedExceptions, nameof(recognizedExceptions)); this.ignoredExceptions = Preconditions.CheckNotNull(ignoredExceptions, nameof(ignoredExceptions)); Preconditions.CheckNotNull(metricsProvider, nameof(metricsProvider)); this.exceptions = Preconditions.CheckNotNull(metricsProvider.CreateCounter( "exceptions_total", "The number of exceptions thrown of the given type", new List <string> { "exception_name" })); AppDomain.CurrentDomain.FirstChanceException += this.OnException; }
Metrics() { this.offlineCounter = Util.Metrics.Metrics.Instance.CreateCounter( "offline_count", "EdgeHub offline count", new List <string> { "id", MetricsConstants.MsTelemetry }); this.offlineDuration = Util.Metrics.Metrics.Instance.CreateDuration( "offline_duration", "EdgeHub offline time", new List <string> { "id", MetricsConstants.MsTelemetry }); }