internal MetricsSinkAdapter(string name, string description, MetricsSink sink, string
                             context, MetricsFilter sourceFilter, MetricsFilter recordFilter, MetricsFilter
                             metricFilter, int period, int queueCapacity, int retryDelay, float retryBackoff,
                             int retryCount)
 {
     this.name         = Preconditions.CheckNotNull(name, "name");
     this.description  = description;
     this.sink         = Preconditions.CheckNotNull(sink, "sink object");
     this.context      = context;
     this.sourceFilter = sourceFilter;
     this.recordFilter = recordFilter;
     this.metricFilter = metricFilter;
     this.period       = Contracts.CheckArg(period, period > 0, "period");
     firstRetryDelay   = Contracts.CheckArg(retryDelay, retryDelay > 0, "retry delay");
     this.retryBackoff = Contracts.CheckArg(retryBackoff, retryBackoff > 1, "retry backoff"
                                            );
     oobPutTimeout = (long)(firstRetryDelay * Math.Pow(retryBackoff, retryCount) * 1000
                            );
     this.retryCount = retryCount;
     this.queue      = new SinkQueue <MetricsBuffer>(Contracts.CheckArg(queueCapacity, queueCapacity
                                                                        > 0, "queue capacity"));
     latency = registry.NewRate("Sink_" + name, "Sink end to end latency", false);
     dropped = registry.NewCounter("Sink_" + name + "Dropped", "Dropped updates per sink"
                                   , 0);
     qsize      = registry.NewGauge("Sink_" + name + "Qsize", "Queue size", 0);
     sinkThread = new _Thread_86(this);
     sinkThread.SetName(name);
     sinkThread.SetDaemon(true);
 }
Exemple #2
0
        private MutableMetric NewImpl(Metric.Type metricType)
        {
            Type resType = method.ReturnType;

            switch (metricType)
            {
            case Metric.Type.Counter:
            {
                return(NewCounter(resType));
            }

            case Metric.Type.Gauge:
            {
                return(NewGauge(resType));
            }

            case Metric.Type.Default:
            {
                return(resType == typeof(string) ? NewTag(resType) : NewGauge(resType));
            }

            case Metric.Type.Tag:
            {
                return(NewTag(resType));
            }

            default:
            {
                Contracts.CheckArg(metricType, false, "unsupported metric type");
                return(null);
            }
            }
        }
 /// <summary>Construct a metrics record</summary>
 /// <param name="info">
 ///
 /// <see cref="MetricInfo"/>
 /// of the record
 /// </param>
 /// <param name="timestamp">of the record</param>
 /// <param name="tags">of the record</param>
 /// <param name="metrics">of the record</param>
 public MetricsRecordImpl(MetricsInfo info, long timestamp, IList <MetricsTag> tags
                          , IEnumerable <AbstractMetric> metrics)
 {
     this.timestamp = Contracts.CheckArg(timestamp, timestamp > 0, "timestamp");
     this.info      = Preconditions.CheckNotNull(info, "info");
     this.tags      = Preconditions.CheckNotNull(tags, "tags");
     this.metrics   = Preconditions.CheckNotNull(metrics, "metrics");
 }
Exemple #4
0
 internal MethodMetric(object obj, MethodInfo method, MetricsInfo info, Metric.Type
                       type)
 {
     this.obj    = Preconditions.CheckNotNull(obj, "object");
     this.method = Contracts.CheckArg(method, Runtime.GetParameterTypes(method
                                                                        ).Length == 0, "Metric method should have no arguments");
     this.info = Preconditions.CheckNotNull(info, "info");
     impl      = NewImpl(Preconditions.CheckNotNull(type, "metric type"));
 }
Exemple #5
0
 internal MetricsSourceAdapter(string prefix, string name, string description, MetricsSource
                               source, IEnumerable <MetricsTag> injectedTags, MetricsFilter recordFilter, MetricsFilter
                               metricFilter, int jmxCacheTTL, bool startMBeans)
 {
     this.prefix       = Preconditions.CheckNotNull(prefix, "prefix");
     this.name         = Preconditions.CheckNotNull(name, "name");
     this.source       = Preconditions.CheckNotNull(source, "source");
     attrCache         = Maps.NewHashMap();
     infoBuilder       = new MBeanInfoBuilder(name, description);
     this.injectedTags = injectedTags;
     this.recordFilter = recordFilter;
     this.metricFilter = metricFilter;
     this.jmxCacheTTL  = Contracts.CheckArg(jmxCacheTTL, jmxCacheTTL > 0, "jmxCacheTTL"
                                            );
     this.startMBeans = startMBeans;
 }