Example #1
0
 public ThreadPoolStatsCollector(
     IMetricFactory metricFactory,
     ICollectorExceptionHandler errorHandler) : base(errorHandler)
 {
     WorkerActiveThreadCount = metricFactory.CreateGauge(
         "dotnet_thread_pool_active_worker_thread_total",
         "Total number of active worker threads in the thread pool");
     WorkerRetiredThreadCount = metricFactory.CreateGauge(
         "dotnet_thread_pool_retired_worker_thread_total",
         "Total number of retired worker threads in the thread pool");
     ThreadPoolWorkerThreadAdjustmentThroughput = metricFactory.CreateGauge(
         "dotnet_thread_pool_worker_thread_adjustment_throughput",
         "Refers to the collection of information for one sample; that is, a measurement of throughput with a certain concurrency level, in an instant of time.");
     WorkerThreadPoolAdjustmentReasonCount = metricFactory.CreateCounter(
         "dotnet_thread_pool_worker_thread_adjustment_reason",
         "Records a change in control, when the thread injection (hill-climbing) algorithm determines that a change in concurrency level is in place.",
         false,
         "reason");
     IoThreadCount = metricFactory.CreateGauge(
         "dotnet_thread_pool_io_thread_total",
         "Number of I/O threads in the thread pool, including this one");
     IoRetiredCount = metricFactory.CreateGauge(
         "dotnet_thread_pool_retired_io_thread_total",
         "Number of retired I/O threads.");
 }
Example #2
0
    public MetricsCollector(IMetricFactory metricFactory)
    {
        _totalSubscriptionRequests = metricFactory.CreateCounter(
            "dolittle_shared_runtime_event_horizon_consumer_subscription_requests_total",
            "SubscriptionsService total number of subscription requests received from Head");

        _totalRegisteredSubscriptions = metricFactory.CreateCounter(
            "dolittle_shared_runtime_event_horizon_consumer_registered_subscriptions_total",
            "Subscriptions total number of registered subscriptions");

        _currentConnectedSubscriptions = metricFactory.CreateGauge(
            "dolittle_shared_runtime_event_horizon_consumer_connected_subscriptions_current",
            "Subscription total number of connected subscriptions");

        _totalSubscriptionRequestsWhereAlreadyStarted = metricFactory.CreateCounter(
            "dolittle_shared_runtime_event_horizon_consumer_subscription_already_started_total",
            "Subscriptions total number of subscription requests made where subscription was already started");

        _totalSubscriptionsWithMissingProducerMicroserviceAddress = metricFactory.CreateCounter(
            "dolittle_shared_runtime_event_horizon_consumer_subscription_with_missing_producer_microservice_address_total",
            "Subscriptions total number of subscriptions where producer microservice address configuration was missing");

        _totalSubscriptionsFailedDueToException = metricFactory.CreateCounter(
            "dolittle_shared_runtime_event_horizon_consumer_subscription_failed_due_to_exception_total",
            "Subscriptions total number of subscriptions failed due to an exception");

        _totalSubscriptionsFailedDueToReceivingOrWritingEventsCompleted = metricFactory.CreateCounter(
            "dolittle_shared_runtime_event_horizon_consumer_subscription_failed_due_to_receiving_or_writing_events_completed_total",
            "Subscriptions total number of subscriptions failed due to receiving or writing events completed");

        _totalSubscriptionLoops = metricFactory.CreateCounter(
            "dolittle_shared_runtime_event_horizon_consumer_subscription_loops_total",
            "Subscriptions total number of subscriptions loops");
    }
Example #3
0
        /// <summary>
        /// Sets a new value for a measurement on a gauge
        /// </summary>
        /// <param name="name">Name of the metric</param>
        /// <param name="description">Description of the metric</param>
        /// <param name="value">New measured value</param>
        /// <param name="labels">Labels that are applicable for this measurement</param>
        public void SetGaugeMeasurement(string name, string description, double value, Dictionary <string, string> labels)
        {
            var enableMetricTimestamps = _prometheusConfiguration.CurrentValue.EnableMetricTimestamps;

            var gauge = _metricFactory.CreateGauge(name, help: description, includeTimestamp: enableMetricTimestamps, labelNames: labels.Keys.ToArray());

            gauge.WithLabels(labels.Values.ToArray()).Set(value);
        }
        /// <summary>
        ///     Sets a new value for a measurement on a gauge
        /// </summary>
        /// <param name="name">Name of the metric</param>
        /// <param name="description">Description of the metric</param>
        /// <param name="value">New measured value</param>
        /// <param name="labels">Labels that are applicable for this measurement</param>
        /// <param name="includeTimestamp">Indication whether or not a timestamp should be reported</param>
        public void WriteGaugeMeasurement(string name, string description, double value, Dictionary <string, string> labels, bool includeTimestamp)
        {
            // Order labels alphabetically
            var orderedLabels = labels.OrderByDescending(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);

            var gauge = _metricFactory.CreateGauge(name, help: description, includeTimestamp: includeTimestamp, labelNames: orderedLabels.Keys.ToArray());

            gauge.WithLabels(orderedLabels.Values.ToArray()).Set(value);
        }
        public IActionResult Get()
        {
            var metricFlags = MetricFlags.None;

            metricFlags |= MetricFlags.IncludeTimestamp;

            var gauge = _metricFactory.CreateGauge("example", "Sample metric", metricFlags, labelNames: new [] { "instance", "region" });

            gauge.WithLabels(new [] { "local", "europe" }).Set(100);

            return(Ok());
        }
Example #6
0
    public MetricsCollector(IMetricFactory metricFactory)
    {
        _currentPendingStreamWrites = metricFactory.CreateGauge(
            "dolittle_system_runtime_services_reversecalls_pending_writes",
            "ReverseCall current pending stream writes waiting");

        _totalStreamWrites = metricFactory.CreateCounter(
            "dolittle_system_runtime_services_reversecalls_stream_writes_total",
            "ReverseCall total number of writes to streams");

        _totalStreamWriteBytes = metricFactory.CreateCounter(
            "dolittle_system_runtime_services_reversecalls_stream_write_bytes_total",
            "ReverseCall total number of bytes written to streams");

        _totalStreamWriteWaitTime = metricFactory.CreateCounter(
            "dolittle_system_runtime_services_reversecalls_stream_write_wait_seconds_total",
            "ReverseCall total time spent waiting to write to streams");

        _totalStreamWriteTime = metricFactory.CreateCounter(
            "dolittle_system_runtime_services_reversecalls_stream_write_seconds_total",
            "ReverseCall total time spent writing to streams");

        _totalStreamReads = metricFactory.CreateCounter(
            "dolittle_system_runtime_services_reversecalls_stream_reads_total",
            "ReverseCall total number of reads from streams");

        _totalStreamReadBytes = metricFactory.CreateCounter(
            "dolittle_system_runtime_services_reversecalls_stream_read_bytes_total",
            "ReverseCall total number of bytes read from streams");

        _totalPingsSent = metricFactory.CreateCounter(
            "dolittle_system_runtime_services_reversecalls_pings_sent_total",
            "ReverseCall total number of pings sent");

        _totalPongsReceived = metricFactory.CreateCounter(
            "dolittle_system_runtime_services_reversecalls_pongs_received_total",
            "ReverseCall total number of pongs received");

        _totalKeepaliveResets = metricFactory.CreateCounter(
            "dolittle_system_runtime_services_reversecalls_keepalive_resets_total",
            "ReverseCall total number of times ping keepalive tokens have been reset");

        _totalKeepaliveTimeouts = metricFactory.CreateCounter(
            "dolittle_system_runtime_services_reversecalls_keepalive_timeouts_total",
            "ReverseCall total number of times ping keepalive tokens have timed out");

        _totalFirstMessageWaitTime = metricFactory.CreateCounter(
            "dolittle_system_runtime_services_reversecalls_first_message_wait_seconds_total",
            "ReverseCall total time spent waiting for first message");
    }
        public ContentionStatsCollector(
            IMetricFactory metricFactory,
            ICollectorExceptionHandler errorHandler) : base(errorHandler)
        {
            ContentionSecondsTotal = metricFactory
                                     .CreateGauge(
                "dotnet_contention_seconds_total",
                "The total amount of time spent contending locks");

            ContentionTotal = metricFactory
                              .CreateCounter(
                "dotnet_contention_total",
                "The number of locks contended");
        }
Example #8
0
        /// <summary>
        /// Initializes a new instance of the type
        /// </summary>
        /// <param name="dependencyService">A service that can be used to retrieve dependencies that were injected</param>
        /// <param name="loggerFactory">A factory that can be used to create loggers</param>
        /// <param name="metricFactory">A factory that can be used to create metrics</param>
        /// <param name="webSocketConfiguration">The configuration of the web socket</param>
        /// <param name="bufferPool">The buffer pool used to retreive arrays</param>
        public WebSocketHandler(IDependencyService dependencyService, IWebSocketConfiguration webSocketConfiguration, IMetricFactory metricFactory, ILoggerFactory loggerFactory, IBufferPool bufferPool)
        {
            Guard.NotNull(nameof(metricFactory), metricFactory);
            Guard.NotNull(nameof(loggerFactory), loggerFactory);
            Guard.NotNull(nameof(bufferPool), bufferPool);
            Guard.NotNull(nameof(webSocketConfiguration), webSocketConfiguration);

            WebSocketConfiguration = webSocketConfiguration;
            BufferPool             = bufferPool;
            SessionId     = Guid.NewGuid();
            MetricFactory = metricFactory;
            Logger        = loggerFactory.CreateLogger($"Session Handler: {SessionId:N}");

            DependencyService = dependencyService;

            _errorCounter        = metricFactory.CreateCounter("WebSocket error counter", "Tracks the number of errors that have occurred since the start of the service", false, new string[0]);
            _serviceSessionGauge = metricFactory.CreateGauge("WebSocket sessions in progress", "Tracks the number of sessions underway", false, new string[0]);
            _sessionTimes        = metricFactory.CreateSummary("WebSocket session iteration times", "Tracks the time taken to execute an iteration in the session", 10, false, new string[0]);
            _receiveTimes        = metricFactory.CreateSummary("WebSocket message receive time", "Tracks the time taken to receive a message", 10, false, new string[0]);
        }
Example #9
0
 public GcStatsCollector(
     IMetricFactory metricFactory,
     IMemoryCache memoryCache,
     ICollectorExceptionHandler errorHandler,
     RuntimeStatCollectorsConfiguration configuration) : base(errorHandler)
 {
     _memoryCache = memoryCache;
     _eventTimer  = new EventTimer(
         memoryCache,
         GCStart_V1,
         GCEnd_V1,
         x => Convert.ToInt64(x.Payload[0]), "gc");
     GcReasons = metricFactory.CreateCounter(
         "dotnet_gc_reason_total",
         "A tally of all the reasons that lead to garbage collections being run",
         false,
         "gc_gen",
         "gc_reason",
         "gc_type");
     GcDuration = metricFactory.CreateHistogram(
         "dotnet_gc_duration",
         "The amount of time spent running garbage collections",
         false,
         configuration.HistogramBuckets,
         "gc_gen",
         "gc_reason",
         "gc_type");
     GcHeapSizeInBytes = metricFactory.CreateGauge(
         "dotnet_gc_heap_size_bytes",
         "The current size of all heaps (only updated after a garbage collection)",
         false,
         "gc_gen");
     LargeObjectAllocationTypeTrigger = metricFactory.CreateCounter(
         "dotnet_gc_loh_type_trigger_total",
         "Objects that triggered Large Object Heap allocation",
         false,
         "type_name");
 }
 public static IMetricFamily <IGauge, ValueTuple <string> > CreateGauge(this IMetricFactory factory, string name, string help, string labelName, bool includeTimestamp = false)
 {
     return(factory.CreateGauge(name, help, ValueTuple.Create(labelName), includeTimestamp));
 }
 public IGauge Creation()
 {
     return(_factory.CreateGauge("gauge", string.Empty));
 }
Example #12
0
        private IMetricFamily <IGauge> CreateGauge(string metricName, string metricDescription, Dictionary <string, string> labels, bool enableMetricTimestamps)
        {
            var gauge = _metricFactory.CreateGauge(metricName, metricDescription, includeTimestamp: enableMetricTimestamps, labelNames: labels.Keys.ToArray());

            return(gauge);
        }
 /// <summary>
 ///     Create Gauge.
 /// </summary>
 /// <param name="factory">Metric factory</param>
 /// <param name="name">Name.</param>
 /// <param name="help">Help text.</param>
 /// <param name="labelNames">Array of label names.</param>
 public static IMetricFamily <IGauge> CreateGauge(this IMetricFactory factory, string name, string help, params string[] labelNames)
 {
     return(factory.CreateGauge(name, help, false, labelNames));
 }
 public ICollector <IGauge> CreateGauge(string name, string help, GaugeConfiguration?configuration = null)
 => _factory.CreateGauge(name, help, configuration);
Example #15
0
    public MetricsCollector(IMetricFactory metricFactory)
    {
        _totalStartedConnections = metricFactory.CreateCounter(
            "dolittle_system_runtime_services_clients_reversecalls_connections_started_total",
            "ReverseCall total number of connections that have been started");

        _pendingWrites = metricFactory.CreateGauge(
            "dolittle_system_runtime_services_clients_reversecalls_pending_writes",
            "ReverseCall current pending stream writes waiting");

        _totalWriteWaitTime = metricFactory.CreateCounter(
            "dolittle_system_runtime_services_clients_reversecalls_stream_write_wait_seconds_total",
            "ReverseCall total time spent waiting to write to streams");

        _totalWriteTime = metricFactory.CreateCounter(
            "dolittle_system_runtime_services_clients_reversecalls_stream_write_seconds_total",
            "ReverseCall total time spent writing to streams");

        _totalWrites = metricFactory.CreateCounter(
            "dolittle_system_runtime_services_clients_reversecalls_stream_writes_total",
            "ReverseCall total number of writes to streams");

        _totalWriteBytes = metricFactory.CreateCounter(
            "dolittle_system_runtime_services_clients_reversecalls_stream_write_bytes_total",
            "ReverseCall total number of bytes written to streams");

        _totalWaitForConnectResponseTime = metricFactory.CreateCounter(
            "dolittle_system_runtime_services_clients_reversecalls_connect_response_wait_seconds_total",
            "ReverseCall total time spent waiting for connect response");

        _totalCancelledConnections = metricFactory.CreateCounter(
            "dolittle_system_runtime_services_clients_reversecalls_connections_cancelled_total",
            "ReverseCall total number of connections that have been cancelled");

        _totalReceivedMessages = metricFactory.CreateCounter(
            "dolittle_system_runtime_services_clients_reversecalls_messages_received_total",
            "ReverseCall total number of messages that have been received");

        _totalReceivedBytes = metricFactory.CreateCounter(
            "dolittle_system_runtime_services_clients_reversecalls_stream_read_bytes_total",
            "ReverseCall total number of bytes read from streams");

        _totalPingsReceived = metricFactory.CreateCounter(
            "dolittle_system_runtime_services_clients_reversecalls_pings_received_total",
            "ReverseCall total number of pings received");

        _totalPongsSent = metricFactory.CreateCounter(
            "dolittle_system_runtime_services_clients_reversecalls_pongs_sent_total",
            "ReverseCall total number of pongs sent");

        _totalReceivedRequests = metricFactory.CreateCounter(
            "dolittle_system_runtime_services_clients_reversecalls_requests_received_total",
            "ReverseCall total number of requests that have been received");

        _totalEmptyMessagesReceived = metricFactory.CreateCounter(
            "dolittle_system_runtime_services_clients_reversecalls_empty_messages_received_total",
            "ReverseCall total number of empty messages that have been received");

        _totalPingTimeouts = metricFactory.CreateCounter(
            "dolittle_system_runtime_services_clients_reversecalls_keepalive_timeouts_total",
            "ReverseCall total number of times ping keepalive has timed out");

        _totalFailedRequestHandlers = metricFactory.CreateCounter(
            "dolittle_system_runtime_services_clients_reversecalls_requests_failed_handlers_total",
            "ReverseCall total number of failed request handlers");

        _totalFailedRequestCallbacks = metricFactory.CreateCounter(
            "dolittle_system_runtime_services_clients_reversecalls_requests_failed_callbacks_total",
            "ReverseCall total number of failed request callbacks");

        _totalFailedResponseWrites = metricFactory.CreateCounter(
            "dolittle_system_runtime_services_clients_reversecalls_failed_response_writes_total",
            "ReverseCall total number of failed response writes");

        _totalRequestHandlingTime = metricFactory.CreateCounter(
            "dolittle_system_runtime_services_clients_reversecalls_request_handling_seconds_total",
            "ReverseCall total time spent handling requests");
    }