private WavefrontTracer( IReporter reporter, IList <KeyValuePair <string, string> > tags, IList <ISampler> samplers, ApplicationTags applicationTags, ISet <string> redMetricsCustomTagKeys, TimeSpan reportFrequency, PropagatorRegistry registry, ILoggerFactory loggerFactory) { ScopeManager = new AsyncLocalScopeManager(); this.reporter = reporter; Tags = tags; this.samplers = samplers; this.redMetricsCustomTagKeys = redMetricsCustomTagKeys; this.applicationTags = applicationTags; this.registry = registry; logger = loggerFactory.CreateLogger <WavefrontTracer>(); WavefrontSpanReporter spanReporter = GetWavefrontSpanReporter(reporter); if (spanReporter != null) { /* * Tracing spans will be converted to metrics and histograms and will be reported * to Wavefront only if you use the WavefrontSpanReporter. */ InitMetricsHistogramsReporting(spanReporter, applicationTags, reportFrequency, loggerFactory, out metricsRoot, out metricsScheduler, out heartbeaterService, out sdkMetricsRegistry); } }
private void WithApplicationTags(ApplicationTags applicationTags) { WithGlobalTag(ApplicationTagKey, applicationTags.Application); WithGlobalTag(ServiceTagKey, applicationTags.Service); WithGlobalTag(ClusterTagKey, applicationTags.Cluster ?? NullTagValue); WithGlobalTag(ShardTagKey, applicationTags.Shard ?? NullTagValue); WithGlobalTags(applicationTags.CustomTags); }
private WavefrontAspNetCoreReporter(IMetricsRoot metrics, IWavefrontSender wavefrontSender, ApplicationTags applicationTags, string source) { Metrics = metrics; WavefrontSender = wavefrontSender; ApplicationTags = applicationTags; Source = source; }
/// <summary> /// Initializes a new instance of the <see cref="Builder"/> class. /// </summary> /// <param name="reporter">The reporter to report tracing spans with.</param> /// <param name="applicationTags"> /// Tags containing metadata about the application. /// </param> public Builder(IReporter reporter, ApplicationTags applicationTags) { this.reporter = reporter; this.applicationTags = applicationTags; tags = new List <KeyValuePair <string, string> >(); samplers = new List <ISampler>(); redMetricsCustomTagKeys = new HashSet <string> { SpanKind.Key }; registry = new PropagatorRegistry(); }
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); }
private void ConfigureWavefront(IServiceCollection services) { var appTagsConfig = new ConfigurationBuilder() .AddYamlFile(Path.Combine(env.ContentRootPath, Configuration["applicationTagsYamlFile"])) .Build(); ApplicationTags applicationTags = ConstructApplicationTags(appTagsConfig); var wfReportingConfig = new ConfigurationBuilder() .AddYamlFile(Path.Combine(env.ContentRootPath, Configuration["wfReportingConfigYamlFile"])) .Build(); string source = wfReportingConfig["source"]; if (string.IsNullOrWhiteSpace(source)) { source = Dns.GetHostName(); } IWavefrontSender wavefrontSender = ConstructWavefrontSender(wfReportingConfig); WavefrontAspNetCoreReporter wfAspNetCoreReporter = new WavefrontAspNetCoreReporter .Builder(applicationTags) .WithSource(source) .Build(wavefrontSender); ITracer tracer; if (wfReportingConfig.GetValue <bool>("reportTraces")) { WavefrontSpanReporter wavefrontSpanReporter = new WavefrontSpanReporter .Builder() .WithSource(source) .Build(wavefrontSender); var consoleReporter = new ConsoleReporter(source); var compositeReporter = new CompositeReporter(wavefrontSpanReporter, consoleReporter); tracer = new WavefrontTracer .Builder(compositeReporter, applicationTags) .Build(); } else { tracer = null; } services.AddWavefrontForMvc(wfAspNetCoreReporter, tracer); }
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 AspNetCoreDiagnostics(ILoggerFactory loggerFactory, ITracer tracer, WavefrontAspNetCoreReporter wfAspNetCoreReporter) : base(loggerFactory, tracer) { _metrics = wfAspNetCoreReporter.Metrics; _applicationTags = wfAspNetCoreReporter.ApplicationTags; _overallAggregatedPerSourceTags = GetTags(true, true, true, null, null, null); _overallAggregatedPerShardTags = GetTags(true, true, true, null, null, WavefrontProvidedSource); _overallAggregatedPerServiceTags = GetTags(true, true, false, null, null, WavefrontProvidedSource); _overallAggregatedPerClusterTags = GetTags(true, false, false, null, null, WavefrontProvidedSource); _overallAggregatedPerApplicationTags = GetTags(false, false, false, null, null, WavefrontProvidedSource); _totalInflightRequestGauge = new WavefrontGaugeOptions { Context = AspNetCoreContext, Name = "total_requests.inflight", Tags = _overallAggregatedPerSourceTags, MeasurementUnit = Unit.Requests }; }
/// <summary> /// Initializes a new instance of the <see cref="Builder"/> class. /// </summary> /// <param name="reporter">The reporter to report tracing spans with.</param> /// <param name="applicationTags"> /// Tags containing metadata about the application. /// </param> public Builder(IReporter reporter, ApplicationTags applicationTags) { this.reporter = reporter; this.applicationTags = applicationTags; tags = new List <KeyValuePair <string, string> >(); }
/// <summary> /// Initializes a Builder for <see cref="WavefrontAspNetCoreReporter"/>. /// </summary> /// <param name="applicationTags"> /// Metadata about your application that is propagated as tags when /// metrics/histograms are sent to Wavefront. /// </param> public Builder(ApplicationTags applicationTags) { this.applicationTags = applicationTags; }