コード例 #1
0
 private void ConfigureSinks()
 {
     lock (this)
     {
         sinkConfigs = config.GetInstanceConfigs(SinkKey);
         int confPeriod = 0;
         foreach (KeyValuePair <string, MetricsConfig> entry in sinkConfigs)
         {
             MetricsConfig conf       = entry.Value;
             int           sinkPeriod = conf.GetInt(PeriodKey, PeriodDefault);
             confPeriod = confPeriod == 0 ? sinkPeriod : ArithmeticUtils.Gcd(confPeriod, sinkPeriod
                                                                             );
             string clsName = conf.GetClassName(string.Empty);
             if (clsName == null)
             {
                 continue;
             }
             // sink can be registered later on
             string sinkName = entry.Key;
             try
             {
                 MetricsSinkAdapter sa = NewSink(sinkName, conf.GetString(DescKey, sinkName), conf
                                                 );
                 sa.Start();
                 sinks[sinkName] = sa;
             }
             catch (Exception e)
             {
                 Log.Warn("Error creating sink '" + sinkName + "'", e);
             }
         }
         period = confPeriod > 0 ? confPeriod : config.GetInt(PeriodKey, PeriodDefault);
     }
 }
コード例 #2
0
        internal virtual void RegisterSink(string name, string desc, MetricsSink sink)
        {
            lock (this)
            {
                Preconditions.CheckNotNull(config, "config");
                MetricsConfig      conf = sinkConfigs[name];
                MetricsSinkAdapter sa   = conf != null?NewSink(name, desc, sink, conf) : NewSink(
                                                  name, desc, sink, ((MetricsConfig)config.Subset(SinkKey)));

                sinks[name] = sa;
                sa.Start();
                Log.Info("Registered sink " + name);
            }
        }