public static HerculesSinkSettings SetupMetrics([NotNull] this HerculesSinkSettings settings, [NotNull] IMetricContext metricContext)
        {
            var oldSetup = settings.AdditionalSetup;

            settings.AdditionalSetup = setup =>
            {
                oldSetup?.Invoke(setup);

                var newModule = new MetricsModule(metricContext);

                var oldModules = setup.Modules.Values.SelectMany(v => v.Before);
                var oldModule  = oldModules.OfType <MetricsModule>().FirstOrDefault();

                if (oldModule != null)
                {
                    oldModule.AddNestedModule(newModule);
                }
                else
                {
                    setup.AddRequestModule(newModule);
                }
            };

            return(settings);
        }
Example #2
0
 public void AddNestedModule(MetricsModule module)
 {
     if (nestedModule == null)
     {
         nestedModule = module;
     }
     else
     {
         nestedModule.AddNestedModule(module);
     }
 }