예제 #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);
        }
예제 #2
0
        public static IServiceCollection AddWavefrontDirectIngestion(this IServiceCollection services, IConfiguration configuration)
        {
            var waveFrontDirectIngestionConfiguration =
                configuration.GetSection(WavefrontDirectIngestionOptions.WavefrontDirectIngestion)
                .Get <WavefrontDirectIngestionOptions>();

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

            var wfDirectIngestionClientBuilder = new WavefrontDirectIngestionClient.Builder(waveFrontDirectIngestionConfiguration.Hostname, waveFrontDirectIngestionConfiguration.Token);

            wfDirectIngestionClientBuilder.MaxQueueSize(waveFrontDirectIngestionConfiguration.MaxQueueSize);
            wfDirectIngestionClientBuilder.BatchSize(waveFrontDirectIngestionConfiguration.BatchSize);
            wfDirectIngestionClientBuilder.FlushIntervalSeconds(waveFrontDirectIngestionConfiguration.FlushIntervalSeconds);
            var wavefrontSender = wfDirectIngestionClientBuilder.Build();

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

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

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

            services.AddWavefrontForMvc(wfAspNetCoreReporter, tracer);

            return(services);
        }
예제 #3
0
        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);
        }