private WavefrontAspNetCoreReporter(IMetricsRoot metrics, IWavefrontSender wavefrontSender, ApplicationTags applicationTags, string source) { Metrics = metrics; WavefrontSender = wavefrontSender; ApplicationTags = applicationTags; Source = source; sdkMetricsRegistry = new WavefrontSdkMetricsRegistry .Builder(wavefrontSender) .Prefix(SdkMetricPrefix + ".aspnetcore") .Source(source) .Tags(applicationTags.ToPointTags()) .Build(); double sdkVersion = Utils.GetSemVer(Assembly.GetExecutingAssembly()); sdkMetricsRegistry.Gauge("version", () => sdkVersion); }
public WavefrontReporter(MetricsReportingWavefrontOptions options) { if (options == null) { throw new ArgumentNullException(nameof(options)); } if (options.WavefrontSender == null) { throw new ArgumentNullException( nameof(MetricsReportingWavefrontOptions.WavefrontSender)); } wavefrontSender = options.WavefrontSender; source = options.Source; if (options.ApplicationTags != null) { globalTags = new Dictionary <string, string>(options.ApplicationTags.ToPointTags()); } else { globalTags = new Dictionary <string, string>(); } histogramGranularities = new HashSet <HistogramGranularity>(); if (options.WavefrontHistogram.ReportMinuteDistribution) { histogramGranularities.Add(HistogramGranularity.Minute); } if (options.WavefrontHistogram.ReportHourDistribution) { histogramGranularities.Add(HistogramGranularity.Hour); } if (options.WavefrontHistogram.ReportDayDistribution) { histogramGranularities.Add(HistogramGranularity.Day); } if (options.FlushInterval < TimeSpan.Zero) { throw new InvalidOperationException( $"{nameof(MetricsReportingWavefrontOptions.FlushInterval)} " + "must not be less than zero"); } Filter = options.Filter; FlushInterval = options.FlushInterval > TimeSpan.Zero ? options.FlushInterval : AppMetricsConstants.Reporting.DefaultFlushInterval; // Formatting will be handled by the Wavefront sender. Formatter = null; metricFields = options.MetricFields ?? new MetricFields(); var registryBuilder = new WavefrontSdkMetricsRegistry.Builder(wavefrontSender) .Prefix(Constants.SdkMetricPrefix + ".app_metrics") .Source(source) .Tags(globalTags); if (options.LoggerFactory != null) { registryBuilder.LoggerFactory(options.LoggerFactory); } sdkMetricsRegistry = registryBuilder.Build(); reporterErrors = sdkMetricsRegistry.Counter("reporter.errors"); double sdkVersion = Utils.GetSemVer(Assembly.GetExecutingAssembly()); sdkMetricsRegistry.Gauge("version", () => sdkVersion); Logger.Info($"Using Wavefront Reporter {this}. FlushInterval: {FlushInterval}"); }