private void InitMetricsHistogramsReporting(
            WavefrontSpanReporter wfSpanReporter, ApplicationTags applicationTags,
            TimeSpan reportFrequency, ILoggerFactory loggerFactory, out IMetricsRoot metricsRoot,
            out AppMetricsTaskScheduler metricsScheduler, out HeartbeaterService heartbeaterService,
            out WavefrontSdkMetricsRegistry sdkMetricsRegistry)
        {
            var tempMetricsRoot = new MetricsBuilder()
                                  .Configuration.Configure(
                options =>
            {
                options.DefaultContextLabel = DerivedMetricPrefix;
            })
                                  .Report.ToWavefront(
                options =>
            {
                options.WavefrontSender = wfSpanReporter.WavefrontSender;
                options.Source          = wfSpanReporter.Source;
                options.ApplicationTags = applicationTags;
                options.WavefrontHistogram.ReportMinuteDistribution = true;
                options.LoggerFactory = loggerFactory;
            })
                                  .Build();

            metricsRoot = tempMetricsRoot;

            metricsScheduler = new AppMetricsTaskScheduler(
                reportFrequency,
                async() =>
            {
                await Task.WhenAll(tempMetricsRoot.ReportRunner.RunAllAsync());
            });
            metricsScheduler.Start();

            heartbeaterService = new HeartbeaterService(
                wfSpanReporter.WavefrontSender, applicationTags, HeartbeaterComponents,
                wfSpanReporter.Source, loggerFactory);
            heartbeaterService.Start();

            sdkMetricsRegistry = new WavefrontSdkMetricsRegistry
                                 .Builder(wfSpanReporter.WavefrontSender)
                                 .Prefix(Constants.SdkMetricPrefix + ".opentracing")
                                 .Source(wfSpanReporter.Source)
                                 .Tags(applicationTags.ToPointTags())
                                 .LoggerFactory(loggerFactory)
                                 .Build();
            wfSpanReporter.SetSdkMetricsRegistry(sdkMetricsRegistry);
        }
 public Task StartAsync(CancellationToken cancellationToken)
 {
     _heartbeaterService.Start();
     return(Task.CompletedTask);
 }