public QueueWriter(ILogWriter logWriter, IMetricFactory metricFactory, IStorageQueue storageQueue) { this.logWriter = logWriter; this.metricFactory = metricFactory; this.storageQueue = storageQueue; }
public void InitializeTest() { _measureCounterMetricsMock = new Mock <IMeasureCounterMetrics>(); _measureMetricsMock = new Mock <IMeasureMetrics>(); _metricFactory = new MetricFactory(_measureMetricsMock.Object); }
/// <summary> /// Adds a console provider to the factory /// </summary> /// <param name="factory">The factory to add the console provider to</param> /// <param name="name">The user friendly and unique name of the provider</param> /// <param name="reportingInterval">The number of seconds before each call to counters to report values</param> /// <param name="includeLabels">True if the labels should be prefixed</param> /// <returns>The metric factory</returns> public static IMetricFactory AddConsole(this IMetricFactory factory, string name, long reportingInterval, bool includeLabels) { factory.AddProvider(name, new ConsoleMetricsProvider(reportingInterval, includeLabels)); return(factory); }
public static IMetricFamily <IGauge <long>, ValueTuple <string> > CreateGaugeInt64(this IMetricFactory factory, string name, string help, string labelName, bool includeTimestamp = false) { return(factory.CreateGaugeInt64(name, help, ValueTuple.Create(labelName), includeTimestamp)); }
/// <summary> /// Initializes a new instance of the type /// </summary> /// <param name="logger">The logger to write debugging and diagnostics information to</param> /// <param name="metricFactory">A factory to create metric containers from</param> /// <param name="containerName">The name of the container to write the checkpoints to</param> /// <param name="connectionString">The connection string of the Azure Storage account</param> /// <param name="retryOptions">Rety options for the Azure Storage client, or null for default</param> public BlobStorageMetadataCheckpointManager(ILogger logger, IMetricFactory metricFactory, string containerName, string connectionString, RetryOptions retryOptions = null) : base(logger, metricFactory, containerName, connectionString, retryOptions) { }
/// <summary> /// Adds a Prometheus provider to the factory /// </summary> /// <param name="factory">The factory to add the application insights provider to</param> /// <param name="name">The user friendly and unique name of the provider</param> /// <param name="hostName">The host name that will server the data</param> /// <param name="port">The port that the metrics server willb exposed on</param> /// <param name="url">The URL suffix the metrics server will be exposed on (default: metrics/)</param> /// <param name="bufferSize">The number of metrics in a bucket, use multiples of 500 for optimal performance</param> /// <param name="ageBuckets">The number of buckets to keep before aging out</param> /// <param name="pulseDuration">The duration in seconds of a pulse summary</param> public static IMetricFactory AddPrometheus(this IMetricFactory factory, string name, int port, string hostName = null, string url = "metrics/", int bufferSize = 1500, int ageBuckets = 5, int pulseDuration = 10) { factory.AddProvider(name, new PrometheusMetricsProvider(hostName, port, url, bufferSize, ageBuckets, pulseDuration)); return(factory); }
/// <summary> /// Adds a callback provider to the factory /// </summary> /// <param name="factory">The factory to add the callback provider to</param> /// <param name="name">The user friendly and unique name of the provider</param> /// <param name="reportingInterval">The number of seconds before each call to counters to report values</param> /// <param name="singleValueWriter">The callback method that is invoked for single value writes</param> /// <param name="summaryWriter">The callback method that is invoked for summary data writes</param> /// <param name="userState">A user state object that consumers can provide that is meaningful to their callbacks</param> /// <returns>The metric factory</returns> public static IMetricFactory AddCallback(this IMetricFactory factory, string name, long reportingInterval, CallbackMetricsProvider.MetricWriterSingleValue singleValueWriter, CallbackMetricsProvider.MetricWriterSummary summaryWriter, object userState) { factory.AddProvider(name, new CallbackMetricsProvider(reportingInterval, singleValueWriter, summaryWriter, userState)); return(factory); }
/// <summary> /// Initializes a new instance of the type /// </summary> /// <param name="logger">The logger to write debugging and diagnostics information to</param> /// <param name="metricFactory">A factory to create metric containers from</param> /// <param name="containerName">The name of the container to write the poison message data to</param> /// <param name="allowedReceiveCount">The number of times that a message can be received before it is considered poison (e.g. 1 allows for a single receive)</param> /// <param name="connectionString">The connection string of the Azure Storage account</param> /// <param name="retryOptions">Rety options for the Azure Storage client, or null for default</param> public BlobStorageCountPoisonedMessageMonitor(ILogger logger, IMetricFactory metricFactory, string containerName, string connectionString, int allowedReceiveCount, RetryOptions retryOptions = null) : base(logger, metricFactory, containerName, connectionString, retryOptions) { Guard.NotLessThan(nameof(allowedReceiveCount), allowedReceiveCount, 1); _allowedReceiveCount = allowedReceiveCount; }
/// <summary> /// Initializes a new instance of the type /// </summary> /// <param name="credential">The Azure managed identity credential to use for authorization. Access controls may be specified by the Event Hubs namespace or the requested Event Hub, depending on Azure configuration.</param> /// <param name="checkpointManager">The manager responsible for checkpointing</param> /// <param name="leaseManager">The manager responsible for leasing</param> /// <param name="logger">The logger used to write debugging and diagnostics information</param> /// <param name="metricFactory">A factory used to create metrics</param> /// <param name="fullyQualifiedNamespace">The fully qualified Event Hubs namespace to connect to. This is likely to be similar to {yournamespace}.servicebus.windows.net.</param> /// <param name="eventHubName">The name of the specific Event Hub to associate the processor with.</param> /// <param name="consumerGroupName">The name of the consumer group the processor is associated with. Events are read in the context of this group.</param> /// <param name="options">The set of options to use for the processor.</param> /// <param name="processorFactory">A factory used to create processors, null for default</param> public FixedBatchProcessorClient(ILogger logger, IMetricFactory metricFactory, TokenCredential credential, string fullyQualifiedNamespace, string eventHubName, string consumerGroupName, FixedProcessorClientOptions options, ILeaseManager leaseManager, ICheckpointManager checkpointManager, ProcessorFactory processorFactory = null) : base(logger, metricFactory, credential, fullyQualifiedNamespace, eventHubName, consumerGroupName, options, leaseManager, checkpointManager) { _logger = logger; _processorFactory = processorFactory ?? new ProcessorFactory((ILogger logger, IMetricFactory metricFactory, ProcessorPartitionContext partitionContext) => (IProcessor)Activator.CreateInstance(typeof(T))); }
public MetricsCollector(IMetricFactory metricFactory) { _totalGet = metricFactory.CreateCounter( "dolittle_shared_runtime_projections_store_get_total", "ProjectionStore total number of Get requests"); _totalFailedGet = metricFactory.CreateCounter( "dolittle_shared_runtime_projections_store_get_failed_total", "ProjectionStore total number of Get requests that have failed"); _totalGetAll = metricFactory.CreateCounter( "dolittle_shared_runtime_projections_store_get_all_total", "ProjectionStore total number of GetAll requests"); _totalFailedGetAll = metricFactory.CreateCounter( "dolittle_shared_runtime_projections_store_get_all_failed_total", "ProjectionStore total number of GetAll requests that have failed"); _totalReplaceAttempts = metricFactory.CreateCounter( "dolittle_shared_runtime_projections_persister_replace_total", "ProjectionPersister total number of Replace requests"); _totalCopyStoreReplacements = metricFactory.CreateCounter( "dolittle_shared_runtime_projections_persister_replace_copy_total", "ProjectionPersister total number of Replace in copy stores that succeeded"); _totalFailedCopyStoreReplacements = metricFactory.CreateCounter( "dolittle_shared_runtime_projections_persister_replace_copy_failed_total", "ProjectionPersister total number of Replace in copy stores that failed"); _totalProjectionStoreReplacements = metricFactory.CreateCounter( "dolittle_shared_runtime_projections_store_replace_total", "ProjectionStore total number of Replace requests"); _totalFailedProjectionStoreReplacements = metricFactory.CreateCounter( "dolittle_shared_runtime_projections_store_replace_failed_total", "ProjectionStore total number of Replace requests that have failed"); _totalRemoveAttempts = metricFactory.CreateCounter( "dolittle_shared_runtime_projections_persister_remove_total", "ProjectionPersister total number of Remove requests"); _totalCopyStoreRemovals = metricFactory.CreateCounter( "dolittle_shared_runtime_projections_persister_remove_copy_total", "ProjectionPersister total number of Remove in copy stores that succeeded"); _totalFailedCopyStoreRemovals = metricFactory.CreateCounter( "dolittle_shared_runtime_projections_persister_remove_copy_failed_total", "ProjectionPersister total number of Remove in copy stores that failed"); _totalProjectionStoreRemovals = metricFactory.CreateCounter( "dolittle_shared_runtime_projections_store_remove_total", "ProjectionStore total number of Remove requests"); _totalFailedProjectionStoreRemovals = metricFactory.CreateCounter( "dolittle_shared_runtime_projections_store_remove_failed_total", "ProjectionStore total number of Remove requests that have failed"); _totalDropAttempts = metricFactory.CreateCounter( "dolittle_shared_runtime_projections_persister_drop_total", "ProjectionPersister total number of Drop requests"); _totalCopyStoreDrops = metricFactory.CreateCounter( "dolittle_shared_runtime_projections_persister_drop_copy_total", "ProjectionPersister total number of Drop in copy stores that succeeded"); _totalFailedCopyStoreDrops = metricFactory.CreateCounter( "dolittle_shared_runtime_projections_persister_drop_copy_failed_total", "ProjectionPersister total number of Drop in copy stores that failed"); _totalProjectionStoreDrops = metricFactory.CreateCounter( "dolittle_shared_runtime_projections_store_drop_total", "ProjectionStore total number of Drop requests"); _totalFailedProjectionStoreDrops = metricFactory.CreateCounter( "dolittle_shared_runtime_projections_store_drop_failed_total", "ProjectionStore total number of Drop requests that have failed"); }
protected abstract IProcessor CreateProcessor(ILogger logger, IMetricFactory metricFactory, ProcessorPartitionContext partitionContext);
/// <summary> /// Initializes a new instance of the type /// </summary> /// <param name="checkpointManager">The manager responsible for checkpointing</param> /// <param name="leaseManager">The manager responsible for leasing</param> /// <param name="logger">The logger used to write debugging and diagnostics information</param> /// <param name="metricFactory">A factory used to create metrics</param> /// <param name="connectionString">The connection string to use for connecting to the Event Hubs namespace; it is expected that the Event Hub name and the shared key properties are contained in this connection string.</param> /// <param name="consumerGroupName">The name of the consumer group the processor is associated with. Events are read in the context of this group.</param> /// <param name="options">The set of options to use for the processor.</param> /// <param name="processorFactory">A factory used to create processors, null for default</param> public FixedBatchProcessorClient(ILogger logger, IMetricFactory metricFactory, string connectionString, string consumerGroupName, FixedProcessorClientOptions options, ILeaseManager leaseManager, ICheckpointManager checkpointManager, ProcessorFactory processorFactory = null) : base(logger, metricFactory, connectionString, consumerGroupName, options, leaseManager, checkpointManager) { _logger = logger; _processorFactory = processorFactory ?? new ProcessorFactory((ILogger logger, IMetricFactory metricFactory, ProcessorPartitionContext partitionContext) => (IProcessor)Activator.CreateInstance(typeof(T))); }
/// <summary> /// Initializes a new instance of the type /// </summary> /// <param name="credential">The Azure managed identity credential to use for authorization. Access controls may be specified by the Event Hubs namespace or the requested Event Hub, depending on Azure configuration.</param> /// <param name="checkpointManager">The manager responsible for checkpointing</param> /// <param name="leaseManager">The manager responsible for leasing</param> /// <param name="logger">The logger used to write debugging and diagnostics information</param> /// <param name="metricFactory">A factory used to create metrics</param> /// <param name="fullyQualifiedNamespace">The fully qualified Event Hubs namespace to connect to. This is likely to be similar to {yournamespace}.servicebus.windows.net.</param> /// <param name="eventHubName">The name of the specific Event Hub to associate the processor with.</param> /// <param name="consumerGroupName">The name of the consumer group the processor is associated with. Events are read in the context of this group.</param> /// <param name="options">The set of options to use for the processor.</param> protected FixedProcessorClient(ILogger logger, IMetricFactory metricFactory, TokenCredential credential, string fullyQualifiedNamespace, string eventHubName, string consumerGroupName, FixedProcessorClientOptions options, ILeaseManager leaseManager, ICheckpointManager checkpointManager) : base(options?.BatchSize ?? 1, consumerGroupName, fullyQualifiedNamespace, eventHubName, credential, options) { ConfigureInstance(logger, metricFactory, options, leaseManager, checkpointManager); }
/// <summary> /// Initializes a new instance of the type /// </summary> /// <param name="connectionString">The connection string to use for connecting to the Event Hubs namespace; it is expected that the shared key property is contained in this connection string, but not the Event Hub name.</param> /// <param name="checkpointManager">The manager responsible for checkpointing</param> /// <param name="leaseManager">The manager responsible for leasing</param> /// <param name="logger">The logger used to write debugging and diagnostics information</param> /// <param name="metricFactory">A factory used to create metrics</param> /// <param name="eventHubName">The name of the specific Event Hub to associate the processor with.</param> /// <param name="consumerGroupName">The name of the consumer group the processor is associated with. Events are read in the context of this group.</param> /// <param name="options">The set of options to use for the processor.</param> protected FixedProcessorClient(ILogger logger, IMetricFactory metricFactory, string connectionString, string eventHubName, string consumerGroupName, FixedProcessorClientOptions options, ILeaseManager leaseManager, ICheckpointManager checkpointManager) : base(options?.BatchSize ?? 1, consumerGroupName, connectionString, eventHubName, options) { ConfigureInstance(logger, metricFactory, options, leaseManager, checkpointManager); }
/// <summary> /// Initializes a new instance of the type /// </summary> /// <param name="logger">The logger to write debugging and diagnostics information to</param> /// <param name="metricFactory">The factory to create metric recorders from</param> /// <param name="connectionString">The connection string used to access the Azure BLOB store</param> /// <param name="containerName">The name of the container that the BLOBs are contained in</param> /// <param name="subContainerPrefix">The prefix for the BLOB container</param> public AzureStorageCheckpointManager(ILogger logger, IMetricFactory metricFactory, string connectionString, string containerName, string subContainerPrefix) : this(logger, metricFactory, CloudStorageAccount.Parse(connectionString), containerName, subContainerPrefix) { }
public CounterController(IMetricFactory metricFactory) { _counter = metricFactory.CreateCounter("myCounter", "some help about this"); }
/// <inheritdoc /> public async Task <bool> InitializeAsync(FixedProcessorClient client, FixedProcessorClientOptions options, ILogger logger, IMetricFactory metricFactory, CancellationToken cancellationToken) { var success = false; using (Logger.BeginScope("Initialize poison message store")) { Logger.LogDebug("Initializing poison message store"); // Use the same prefix as the checkpoint store if it exists to reduce user configuration requirements _messageStorePrefix = string.IsNullOrWhiteSpace(options.CheckpointPrefix) ? string.Format(CultureInfo.InvariantCulture, "{0}/{1}/{2}", client.FullyQualifiedNamespace.ToLowerInvariant(), client.EventHubName.ToLowerInvariant(), client.ConsumerGroup.Replace("$", "").ToLowerInvariant()) : string.Format(CultureInfo.InvariantCulture, "{0}/{1}/{2}/{3}", options.CheckpointPrefix, client.FullyQualifiedNamespace.ToLowerInvariant(), client.EventHubName.ToLowerInvariant(), client.ConsumerGroup.Replace("$", "").ToLowerInvariant()); Logger.LogInformation("Store prefix {location}", _messageStorePrefix); _blobNameFormatString = string.Concat(_messageStorePrefix, "/{0}"); success = await CreateStoreIfNotExistsAsync(client, options, cancellationToken).ConfigureAwait(false); } return(success); }
/// <summary> /// Initializes a new instance of the type /// </summary> /// <param name="logger">The logger to write debugging and diagnostics information to</param> /// <param name="metricFactory">A factory to create metric containers from</param> /// <param name="storageAccountUri">The Azure Storage account URI</param> /// <param name="containerName">The name of the container to write the poison message data to</param> /// <param name="allowedReceiveCount">The number of times that a message can be received before it is considered poison (e.g. 1 allows for a single receive)</param> /// <param name="credential">The credential provider such as managed identity provider</param> /// <param name="retryOptions">Rety options for the Azure Storage client, or null for default</param> public BlobStorageCountPoisonedMessageMonitor(ILogger logger, IMetricFactory metricFactory, Uri storageAccountUri, string containerName, TokenCredential credential, int allowedReceiveCount, RetryOptions retryOptions = null) : base(logger, metricFactory, storageAccountUri, containerName, credential, retryOptions) { Guard.NotLessThan(nameof(allowedReceiveCount), allowedReceiveCount, 1); _allowedReceiveCount = allowedReceiveCount; }
public CounterController(IMetricFactory metricFactory) { _counter = metricFactory.CreateCounter("my_counter", "some help about this"); _conterLabel = metricFactory.CreateCounter("my_counter_label", "some help about this", ("label1", "label2")); _counterTs = metricFactory.CreateCounter("my_counter_ts", "some help about this", true); }
/// <summary> /// Initializes a new instance of the type /// </summary> /// <param name="logger">The logger to write debugging and diagnostics information to</param> /// <param name="metricFactory">A factory to create metric containers from</param> /// <param name="storageAccountUri">The Azure Storage account URI</param> /// <param name="containerName">The name of the container to write the checkpoints to</param> /// <param name="credential">The credential provider such as managed identity provider</param> /// <param name="retryOptions">Rety options for the Azure Storage client, or null for default</param> public BlobStorageMetadataCheckpointManager(ILogger logger, IMetricFactory metricFactory, Uri storageAccountUri, string containerName, TokenCredential credential, RetryOptions retryOptions = null) : base(logger, metricFactory, storageAccountUri, containerName, credential, retryOptions) { }
public Worker(ILogger <Worker> logger, IMetricFactory metricFactory) { _logger = logger; _counter = metricFactory.CreateCounter("my_count", "help text"); }
/// <summary> /// Initializes a new instance of the type /// </summary> /// <param name="logger">The logger to write debugging and diagnostics information to</param> /// <param name="metricFactory">The factory to create metric recorders from</param> /// <param name="consumerGroupName">The name of the consumer group that the processor is associated with</param> /// <param name="connectionString">The connection string used to access the Azure BLOB store</param> /// <param name="containerName">The name of the container that the BLOBs are contained in</param> /// <param name="subContainerPrefix">The prefix for the BLOB container</param> public AzureStorageEpochRecorder(ILogger logger, IMetricFactory metricFactory, string consumerGroupName, string connectionString, string containerName, string subContainerPrefix) : this(logger, metricFactory, consumerGroupName, CloudStorageAccount.Parse(connectionString), containerName, subContainerPrefix) { }
/// <summary> /// Adds an Application Insights provider to the factory /// </summary> /// <param name="factory">The factory to add the application insights provider to</param> /// <param name="name">The user friendly and unique name of the provider</param> /// <param name="instrumentationKey">The application insights instrumentation key to write to</param> /// <param name="enrichmentProperties">The dictionary of properties that are to be used when enriching telemetry objects processed by this initializer</param> /// <returns>The metric factory</returns> public static IMetricFactory AddApplicationInsights(this IMetricFactory factory, string name, string instrumentationKey, Dictionary <string, string> enrichmentProperties = null) { factory.AddProvider(name, new ApplicationInsightsMetricsProvider(instrumentationKey, enrichmentProperties)); return(factory); }
public TextAnalyzer(IMetricFactory factory) { _factory = factory; }
public PrometheusMetricsCollector(IMetricFactory metricFactory) { Guard.NotNull(metricFactory, nameof(metricFactory)); _metricFactory = metricFactory; }
public HistogramController(IMetricFactory metricFactory) { _histogram = metricFactory.CreateHistogram("test_hist", "help_text", "params1"); }
/// <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]); }
public DemoProcessor(PartitionContext partitionContext, ILoggerFactory loggerFactory, IMetricFactory metricFactory) { _logger = loggerFactory.CreateLogger("DemoProcessor"); _processedCounter = metricFactory.CreateCounter("dp_message_count", "The number of messages processed since the processor started", false, new string[0]); }
public static IMetricFamily <ICounter, ValueTuple <string> > CreateCounter(this IMetricFactory factory, string name, string help, string labelName, bool includeTimestamp = false) { return(factory.CreateCounter(name, help, ValueTuple.Create(labelName), includeTimestamp)); }
public void Setup() { _factory = new MetricFactory(new CollectorRegistry()); }
public static void AssignFactory(IMetricFactory factory) { Factory = factory; }