Ejemplo n.º 1
0
 public static IStatsDClient WithScopes([NotNull] this IStatsDClient client, [CanBeNull, ItemNotNull] params string[] nextPrefixes)
 {
     if (nextPrefixes == null || nextPrefixes.Length == 0)
     {
         return(client);
     }
     return(new PooledStatsDClient(client, nextPrefixes));
 }
Ejemplo n.º 2
0
 public static T Timing <T>([NotNull] this IStatsDClient client, [NotNull, ItemNotNull] string[] keys, [NotNull] Func <T> action, [NotNull] out Stopwatch timer)
 {
     timer = Stopwatch.StartNew();
     try
     {
         return(action());
     }
     finally
     {
         timer.Stop();
         client.Timing(timer.ElapsedMilliseconds, sampleRate: 1.0, keys);
     }
 }
Ejemplo n.º 3
0
        public static async Task <T> TimingAsync <T>([NotNull] this IStatsDClient client, [NotNull, ItemNotNull] string[] keys, [NotNull] Func <Task <T> > action)
        {
            var timer = Stopwatch.StartNew();

            try
            {
                return(await action().ConfigureAwait(false));
            }
            finally
            {
                timer.Stop();
                client.Timing(timer.ElapsedMilliseconds, sampleRate: 1.0, keys);
            }
        }
Ejemplo n.º 4
0
        public RtqMonitoringEventBulkIndexer(ILog logger,
                                             RtqElasticsearchIndexerSettings indexerSettings,
                                             IRtqElasticsearchClient elasticsearchClient,
                                             RemoteTaskQueue remoteTaskQueue,
                                             IStatsDClient statsDClient)
        {
            this.indexerSettings = indexerSettings;
            eventSource          = new RtqEventSource(remoteTaskQueue.EventLogRepository);
            offsetInterpreter    = new RtqEventLogOffsetInterpreter();
            var perfGraphiteReporter = new RtqMonitoringPerfGraphiteReporter(statsDClient,
                                                                             graphitePathPrefix: $"{indexerSettings.RtqGraphitePathPrefix}.ElasticsearchBulkIndexer.Perf");

            this.logger       = logger.ForContext("CassandraDistributedTaskQueue").ForContext(nameof(RtqMonitoringEventBulkIndexer));
            taskMetaProcessor = new TaskMetaProcessor(this.logger, indexerSettings, elasticsearchClient, remoteTaskQueue, perfGraphiteReporter);
        }
Ejemplo n.º 5
0
 public GraphiteRtqProfiler([NotNull] IStatsDClient statsDClient,
                            [NotNull] IGraphiteClient graphiteClient,
                            [NotNull] string statsDKeyNamePrefix,
                            [NotNull] string consumerGraphitePathPrefix)
 {
     if (string.IsNullOrEmpty(statsDKeyNamePrefix))
     {
         throw new InvalidOperationException("statsDKeyNamePrefix is empty");
     }
     if (string.IsNullOrEmpty(consumerGraphitePathPrefix))
     {
         throw new InvalidOperationException("consumerGraphitePathPrefix is empty");
     }
     this.statsDClient               = statsDClient.WithScopes($"{statsDKeyNamePrefix}.{Dns.GetHostName()}", $"{statsDKeyNamePrefix}.Total");
     this.graphiteClient             = graphiteClient;
     this.consumerGraphitePathPrefix = FormatGraphitePathPrefix(consumerGraphitePathPrefix);
 }
        public RtqMonitoringEventFeeder(ILog logger,
                                        RtqElasticsearchIndexerSettings indexerSettings,
                                        IRtqElasticsearchClient elasticsearchClient,
                                        IGraphiteClient graphiteClient,
                                        IStatsDClient statsDClient,
                                        IRtqPeriodicJobRunner rtqPeriodicJobRunner,
                                        RemoteTaskQueue remoteTaskQueue)
        {
            this.logger              = logger.ForContext("CassandraDistributedTaskQueue").ForContext(nameof(RtqMonitoringEventFeeder));
            this.indexerSettings     = indexerSettings;
            this.elasticsearchClient = elasticsearchClient;
            GlobalTime  = remoteTaskQueue.GlobalTime;
            eventSource = new RtqEventSource(remoteTaskQueue.EventLogRepository);
            var eventFeedPeriodicJobRunner = new RtqEventFeedPeriodicJobRunner(rtqPeriodicJobRunner, graphiteClient, indexerSettings.EventFeedGraphitePathPrefix);

            eventFeedFactory = new EventFeedFactory(new RtqEventFeedGlobalTimeProvider(GlobalTime), eventFeedPeriodicJobRunner);
            var perfGraphiteReporter = new RtqMonitoringPerfGraphiteReporter(statsDClient, indexerSettings.PerfGraphitePathPrefix);
            var taskMetaProcessor    = new TaskMetaProcessor(this.logger, indexerSettings, elasticsearchClient, remoteTaskQueue, perfGraphiteReporter);

            eventConsumer = new RtqMonitoringEventConsumer(indexerSettings, taskMetaProcessor);
        }
        public RtqTaskCounterEventFeeder(ILog logger,
                                         ISerializer serializer,
                                         RtqTaskCounterSettings settings,
                                         IRtqTaskDataRegistry taskDataRegistry,
                                         IRtqTaskCounterStateStorage stateStorage,
                                         IGraphiteClient graphiteClient,
                                         IStatsDClient statsDClient,
                                         IRtqPeriodicJobRunner rtqPeriodicJobRunner,
                                         RemoteTaskQueue remoteTaskQueue)
        {
            this.serializer       = serializer;
            this.settings         = settings;
            this.taskDataRegistry = taskDataRegistry;
            this.stateStorage     = stateStorage;
            GlobalTime            = remoteTaskQueue.GlobalTime;
            var eventFeedPeriodicJobRunner = new RtqEventFeedPeriodicJobRunner(rtqPeriodicJobRunner, graphiteClient, settings.EventFeedGraphitePathPrefix);

            eventFeedFactory       = new EventFeedFactory(new RtqEventFeedGlobalTimeProvider(GlobalTime), eventFeedPeriodicJobRunner);
            eventSource            = new RtqEventSource(remoteTaskQueue.EventLogRepository);
            handleTasksMetaStorage = remoteTaskQueue.HandleTasksMetaStorage;
            perfGraphiteReporter   = new RtqMonitoringPerfGraphiteReporter(statsDClient, settings.PerfGraphitePathPrefix);
            this.logger            = logger.ForContext("CassandraDistributedTaskQueue").ForContext(nameof(RtqTaskCounterEventFeeder));
            this.logger.Info("Using RtqTaskCounterSettings: {RtqTaskCounterSettings}", new { RtqTaskCounterSettings = settings.ToPrettyJson() });
        }
 public PooledStatsDClient([NotNull] IStatsDClient innerClient, [CanBeNull, ItemNotNull] string[] prefixes)
 {
     pool             = null;
     this.innerClient = innerClient;
     this.prefixes    = prefixes;
 }
Ejemplo n.º 9
0
 public static void Timing([NotNull] this IStatsDClient client, [NotNull] string key, [NotNull] Action action)
 {
     Timing(client, new[] { key }, action);
 }
Ejemplo n.º 10
0
 public static Task <T> TimingAsync <T>([NotNull] this IStatsDClient client, [NotNull] string key, [NotNull] Func <Task <T> > action)
 {
     return(TimingAsync(client, new[] { key }, action));
 }
Ejemplo n.º 11
0
 public static IStatsDClient WithScope([NotNull] this IStatsDClient client, [CanBeNull] string nextPrefix)
 {
     return(string.IsNullOrEmpty(nextPrefix) ? client : client.WithScopes(nextPrefix));
 }
Ejemplo n.º 12
0
 public static T Timing <T>([NotNull] this IStatsDClient client, [NotNull, ItemNotNull] string[] keys, [NotNull] Func <T> action)
 {
     return(Timing(client, keys, action, out _));
 }
Ejemplo n.º 13
0
 public static IStatsDClient WithTotalAndMachineScope([NotNull] this IStatsDClient client)
 {
     return(client.WithScopes("Total", $"PerMachine.{Environment.MachineName}"));
 }
Ejemplo n.º 14
0
 public static void Timing([NotNull] this IStatsDClient client, [NotNull, ItemNotNull] string[] keys, [NotNull] Action action)
 {
     Timing(client, keys, action, out _);
 }
Ejemplo n.º 15
0
 public static T Timing <T>([NotNull] this IStatsDClient client, [NotNull] string key, [NotNull] Func <T> action, [NotNull] out Stopwatch timer)
 {
     return(Timing(client, new[] { key }, action, out timer));
 }
Ejemplo n.º 16
0
 public GraphiteSenderMiddleware(IStatsDClient statsDClient)
 {
     this.statsDClient = statsDClient.WithScope("Api2");
 }
Ejemplo n.º 17
0
 public static IStatsDClient WithTotalAndMachineScope([NotNull] this IStatsDClient client, [NotNull] string keyPrefix)
 {
     return(client.WithScope(keyPrefix).WithTotalAndMachineScope());
 }
Ejemplo n.º 18
0
 public static void Timing([NotNull] this IStatsDClient client, [NotNull] string key, long timing, double sampleRate = 1.0)
 {
     client.Timing(timing, sampleRate, key);
 }
Ejemplo n.º 19
0
 public static void Decrement([NotNull] this IStatsDClient client, [NotNull, ItemNotNull] params string[] keys)
 {
     client.Increment(magnitude: -1, sampleRate: 1.0, keys);
 }
Ejemplo n.º 20
0
 public static void Decrement([NotNull] this IStatsDClient client, [NotNull] string key, int magnitude = -1, double sampleRate = 1.0)
 {
     client.Increment(magnitude, sampleRate, key);
 }
Ejemplo n.º 21
0
 public RtqMonitoringPerfGraphiteReporter([NotNull] IStatsDClient statsDClient, [NotNull] string graphitePathPrefix)
 {
     this.statsDClient       = statsDClient;
     this.graphitePathPrefix = graphitePathPrefix;
 }
Ejemplo n.º 22
0
 public static void Timing([NotNull] this IStatsDClient client, [NotNull] string key, [NotNull] Action action, [NotNull] out Stopwatch timer)
 {
     Timing(client, new[] { key }, action, out timer);
 }