internal void SetSdkMetricsRegistry(WavefrontSdkMetricsRegistry sdkMetricsRegistry)
        {
            this.sdkMetricsRegistry = sdkMetricsRegistry;

            // init internal metrics
            this.sdkMetricsRegistry.Gauge("reporter.queue.size", () => spanBuffer.Count);
            this.sdkMetricsRegistry.Gauge("reporter.queue.remaining_capacity",
                                          () => spanBuffer.BoundedCapacity - spanBuffer.Count);
            spansReceived = this.sdkMetricsRegistry.Counter("reporter.spans.received");
            spansDropped  = this.sdkMetricsRegistry.Counter("reporter.spans.dropped");
            reportErrors  = this.sdkMetricsRegistry.Counter("reporter.errors");
        }
예제 #2
0
        protected internal ProxyConnectionHandler(string host, int port,
                                                  WavefrontSdkMetricsRegistry sdkMetricsRegistry, string entityPrefix,
                                                  ILoggerFactory loggerFactory)
        {
            this.host          = host;
            this.port          = port;
            this.loggerFactory = loggerFactory;
            reconnectingSocket = null;

            this.sdkMetricsRegistry = sdkMetricsRegistry;
            this.entityPrefix       = string.IsNullOrWhiteSpace(entityPrefix) ? "" : entityPrefix + ".";
            errors        = this.sdkMetricsRegistry.Counter(this.entityPrefix + "errors");
            connectErrors = this.sdkMetricsRegistry.Counter(this.entityPrefix + "connect.errors");
        }
        internal void SetSdkMetricsRegistry(WavefrontSdkMetricsRegistry sdkMetricsRegistry)
        {
            this.sdkMetricsRegistry = sdkMetricsRegistry;

            // init internal metrics
            double sdkVersion = Utils.GetSemVer(Assembly.GetExecutingAssembly());

            this.sdkMetricsRegistry.Gauge("version", () => sdkVersion);
            this.sdkMetricsRegistry.Gauge("reporter.queue.size", () => spanBuffer.Count);
            this.sdkMetricsRegistry.Gauge("reporter.queue.remaining_capacity",
                                          () => spanBuffer.BoundedCapacity - spanBuffer.Count);
            spansReceived = this.sdkMetricsRegistry.DeltaCounter("reporter.spans.received");
            spansDropped  = this.sdkMetricsRegistry.DeltaCounter("reporter.spans.dropped");
            reportErrors  = this.sdkMetricsRegistry.DeltaCounter("reporter.errors");
        }
        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 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);
        }
예제 #6
0
        public MetricSnapshotWavefrontWriter(
            IWavefrontSender wavefrontSender,
            string source,
            IDictionary <string, string> globalTags,
            ISet <HistogramGranularity> histogramGranularities,
            WavefrontSdkMetricsRegistry sdkMetricsRegistry,
            MetricFields fields)
        {
            this.wavefrontSender        = wavefrontSender;
            this.source                 = source;
            this.globalTags             = globalTags;
            this.histogramGranularities = histogramGranularities;
            this.fields                 = fields;

            gaugesReported        = sdkMetricsRegistry.Counter("gauges.reported");
            deltaCountersReported = sdkMetricsRegistry.Counter("delta_counters.reported");
            countersReported      = sdkMetricsRegistry.Counter("counters.reported");
            wfHistogramsReported  = sdkMetricsRegistry.Counter("wavefront_histograms.reported");
            histogramsReported    = sdkMetricsRegistry.Counter("histograms.reported");
            metersReported        = sdkMetricsRegistry.Counter("meters.reported");
            timersReported        = sdkMetricsRegistry.Counter("timers.reported");
            apdexesReported       = sdkMetricsRegistry.Counter("apdexes.reported");
            writerErrors          = sdkMetricsRegistry.Counter("writer.errors");
        }
        /// <summary>
        /// Initializes a new instance of the
        /// <see cref="T:Wavefront.SDK.CSharp.Common.ReconnectingSocket"/> class.
        /// </summary>
        /// <param name="host">The hostname of the Wavefront proxy.</param>
        /// <param name="port">The port number of the Wavefront proxy to connect to.</param>
        /// <param name="loggerFactory">The logger factory used to create a logger.</param>
        public ReconnectingSocket(string host, int port,
                                  WavefrontSdkMetricsRegistry sdkMetricsRegistry, string entityPrefix,
                                  ILoggerFactory loggerFactory)
        {
            this.host = host;
            this.port = port;
            logger    = loggerFactory.CreateLogger <ReconnectingSocket>() ??
                        throw new ArgumentNullException(nameof(loggerFactory));

            entityPrefix   = string.IsNullOrWhiteSpace(entityPrefix) ? "" : entityPrefix + ".";
            writeSuccesses = sdkMetricsRegistry.Counter(entityPrefix + "write.success");
            writeErrors    = sdkMetricsRegistry.Counter(entityPrefix + "write.errors");
            flushSuccesses = sdkMetricsRegistry.Counter(entityPrefix + "flush.success");
            flushErrors    = sdkMetricsRegistry.Counter(entityPrefix + "flush.errors");
            resetSuccesses = sdkMetricsRegistry.Counter(entityPrefix + "reset.success");
            resetErrors    = sdkMetricsRegistry.Counter(entityPrefix + "reset.errors");

            client = new TcpClient
            {
                ReceiveTimeout = serverReadTimeoutMillis
            };
            // Block while attempting to establish a connection
            ConnectAsync(false).GetAwaiter().GetResult();
        }
        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}");
        }
 /// <summary>
 /// Initializes a new instance of the
 /// <see cref="T:Wavefront.SDK.CSharp.Common.ReconnectingSocket"/> class.
 /// </summary>
 /// <param name="host">The hostname of the Wavefront proxy.</param>
 /// <param name="port">The port number of the Wavefront proxy to connect to.</param>
 public ReconnectingSocket(string host, int port,
                           WavefrontSdkMetricsRegistry sdkMetricsRegistry, string entityPrefix)
     : this(host, port, sdkMetricsRegistry, entityPrefix, Logging.LoggerFactory)
 {
 }
예제 #10
0
 protected internal ProxyConnectionHandler(string host, int port,
                                           WavefrontSdkMetricsRegistry sdkMetricsRegistry, string entityPrefix)
     : this(host, port, sdkMetricsRegistry, entityPrefix, Logging.LoggerFactory)
 {
 }