Exemplo n.º 1
0
        public static IServiceCollection AddWavefrontProxy(this IServiceCollection services, IConfiguration configuration)
        {
            var waveFrontProxyConfiguration =
                configuration.GetSection(WavefrontProxyOptions.WavefrontProxy).Get <WavefrontProxyOptions>();

            var wfProxyClientBuilder = new WavefrontProxyClient.Builder(waveFrontProxyConfiguration.Hostname);

            wfProxyClientBuilder.MetricsPort(waveFrontProxyConfiguration.Port);
            wfProxyClientBuilder.DistributionPort(waveFrontProxyConfiguration.DistributionPort);
            wfProxyClientBuilder.TracingPort(waveFrontProxyConfiguration.TracingPort);
            wfProxyClientBuilder.FlushIntervalSeconds(waveFrontProxyConfiguration.TracingPort);
            var wavefrontSender = wfProxyClientBuilder.Build();

            var applicationTags = new ApplicationTags.Builder(waveFrontProxyConfiguration.Application, waveFrontProxyConfiguration.Service)
                                  .Cluster(waveFrontProxyConfiguration.Cluster)
                                  .Shard(waveFrontProxyConfiguration.Shard)
                                  .Build();

            var wfAspNetCoreReporter = new WavefrontAspNetCoreReporter.Builder(applicationTags)
                                       .WithSource(waveFrontProxyConfiguration.Source)
                                       .ReportingIntervalSeconds(waveFrontProxyConfiguration.ReportingIntervalSeconds)
                                       .Build(wavefrontSender);

            System.Console.WriteLine(wfAspNetCoreReporter);

            var wavefrontSpanReporter = new WavefrontSpanReporter.Builder()
                                        .Build(wavefrontSender);

            ITracer tracer = new WavefrontTracer.Builder(wavefrontSpanReporter, applicationTags).Build();

            services.AddWavefrontForMvc(wfAspNetCoreReporter, tracer);

            return(services);
        }
Exemplo n.º 2
0
        private static void startWavefrontReportingViaProxy()
        {
            IWavefrontSender wavefrontProxyClient = new WavefrontProxyClient.Builder(proxyHost)
                                                    .MetricsPort(metricsPort)
                                                    .Build();

            IMetricsRoot metrics = new MetricsBuilder()
                                   .Configuration.Configure(options =>
            {
                options.DefaultContextLabel = "service";
                options.GlobalTags          = new GlobalMetricTags(new Dictionary <string, string>
                {
                    { "dc", "us-west-2" },
                    { "env", "staging" }
                });
            })
                                   .Report.ToWavefront(options =>
            {
                options.WavefrontSender = wavefrontProxyClient;
                options.Source          = "app-1.company.com";
            })
                                   .Build();

            CounterOptions evictions = new CounterOptions
            {
                Name = "cache-evictions"
            };

            metrics.Measure.Counter.Increment(evictions);

            var scheduler = new AppMetricsTaskScheduler(TimeSpan.FromSeconds(5), async() =>
            {
                await Task.WhenAll(metrics.ReportRunner.RunAllAsync());
            });

            scheduler.Start();
        }