コード例 #1
0
ファイル: WorkQueue.cs プロジェクト: gideonkorir/jaeger4net
 public WorkQueue(ISender sender, WorkQueueOptions options, ClientMetrics metrics)
 {
     this.sender  = sender ?? throw new ArgumentNullException(nameof(sender));
     this.metrics = metrics ?? throw new ArgumentNullException(nameof(metrics));
     this.options = options ?? throw new ArgumentNullException(nameof(options));
     queue        = new BlockingCollection <Span>(options.MaxQueueSize);
 }
コード例 #2
0
        private async Task UploadAsync(
            Task uploadTask,
            Task updateUiTask,
            ClientMetrics metrics,
            View cancelButton,
            View uploadButton,
            ISpan span,
            CancellationTokenSource source)
        {
            var container = base.FindViewById(Resource.Id.metrics_container) !;

            container.Visibility = ViewStates.Visible;

            var doneText        = (TextView)base.FindViewById(Resource.Id.done_text) !;
            var ranForLabel     = (TextView)base.FindViewById(Resource.Id.ran_for_label) !;
            var ranForContainer = base.FindViewById(Resource.Id.ran_for_container) !;
            var ranForView      = base.FindViewById(Resource.Id.ran_for_view) !;

            try
            {
                cancelButton.Enabled = true;
                await Task.WhenAny(uploadTask, updateUiTask);

                if (uploadTask.IsCompletedSuccessfully)
                {
                    cancelButton.Enabled = false;
                    uploadButton.Enabled = false;

                    doneText.Visibility        = ViewStates.Visible;
                    ranForView.Visibility      = ViewStates.Visible;
                    ranForContainer.Visibility = ViewStates.Visible;

                    ranForLabel.Text = metrics.RanFor.ToString();
                    span.Finish(SpanStatus.Ok);
                }
                else if (uploadTask.IsFaulted)
                {
                    ShowError(uploadTask.Exception);
                    span.Finish(SpanStatus.InternalError);
                }
                else
                {
                    cancelButton.Enabled = false;
                    uploadButton.Enabled = true;
                    span.Finish(SpanStatus.Cancelled);
                }
            }
            catch (Exception e)
            {
                ShowError(e);
                span.Finish(e);
            }
            finally
            {
                source.Cancel();
            }
        }
コード例 #3
0
 public RemoteBaggageRestrictor(IRestrictionSource restrictionSource, RemoteRestrictorOptions options,ClientMetrics metrics)
 {
     this.restrictionSource = restrictionSource ?? throw new ArgumentNullException(nameof(restrictionSource));
     this.options = options ?? throw new ArgumentNullException(nameof(options));
     this.metrics = metrics ?? throw new ArgumentNullException(nameof(metrics));
     serviceRestrictions = new ConcurrentDictionary<string, ConcurrentDictionary<string, Restriction>>();
     timer = new AsyncTimer(UpdateAsync, options.RefreshInterval, options.CancellationToken);
     timer.Start();
 }
コード例 #4
0
 public ConsoleUploader(
     Client client,
     ClientMetrics metrics,
     ILogger <ConsoleUploader> logger)
 {
     _client  = client;
     _metrics = metrics;
     _logger  = logger;
 }
コード例 #5
0
        public async Task <IActionResult> Get()
        {
            try {
                string natsServer      = "http://127.0.0.1:8222";
                string exportedMetrics = "";
                string clientname      = "";

                if (Environment.GetEnvironmentVariable("NATSMETRICSURL") != null)
                {
                    natsServer = Environment.GetEnvironmentVariable("NATSMETRICSURL");
                }

                // grab the URL above /conns and pull the client connection data
                ClientMetrics          metrics    = new ClientMetrics();
                List <ClientVariables> clientVars = await metrics.CollectMetrics(natsServer);

                foreach (ClientVariables c in clientVars)
                {
                    clientname       = c.clientName.Replace("-", "_");
                    exportedMetrics += "# HELP Total Messages Incoming for this client.\n";
                    exportedMetrics += "# TYPE gnatds_clients_in_msgs_total gauge\n";
                    exportedMetrics += "gnatds_clients_in_msgs_total{server_id=\"" + natsServer + "\",";
                    exportedMetrics += "clientname=\"" + clientname + "\"} " + c.inMessages + "\n";

                    exportedMetrics += "# HELP Total Messages Outgoing for this client.\n";
                    exportedMetrics += "# TYPE gnatds_clients_out_msgs_total gauge\n";
                    exportedMetrics += "gnatds_clients_out_msgs_total{server_id=\"" + natsServer + "\",";
                    exportedMetrics += "clientname=\"" + clientname + "\"} " + c.outMessages + "\n";

                    exportedMetrics += "# HELP Total Pending Bytes for this client.\n";
                    exportedMetrics += "# TYPE gnatds_clients_pending_bytes_total gauge\n";
                    exportedMetrics += "gnatds_clients_pending_bytes_total{server_id=\"" + natsServer + "\",";
                    exportedMetrics += "clientname=\"" + clientname + "\"} " + c.pendingBytes + "\n";

                    exportedMetrics += "# HELP Total Bytes Incoming for this client.\n";
                    exportedMetrics += "# TYPE gnatds_clients_in_bytes_total gauge\n";
                    exportedMetrics += "gnatds_clients_in_bytes_total{server_id=\"" + natsServer + "\",";
                    exportedMetrics += "clientname=\"" + clientname + "\"} " + c.inBytes + "\n";

                    exportedMetrics += "# HELP Total Bytes Outgoing for this client.\n";
                    exportedMetrics += "# TYPE gnatds_clients_out_bytes_total gauge\n";
                    exportedMetrics += "gnatds_clients_out_bytes_total{server_id=\"" + natsServer + "\",";
                    exportedMetrics += "clientname=\"" + clientname + "\"} " + c.outBytes + "\n";

                    exportedMetrics += "# HELP Total Subscriptions for this client.\n";
                    exportedMetrics += "# TYPE gnatds_clients_subscriptions_total gauge\n";
                    exportedMetrics += "gnatds_clients_subscriptions_total{server_id=\"" + natsServer + "\",";
                    exportedMetrics += "clientname=\"" + clientname + "\"} " + c.subscriptions + "\n";
                }
                return(Ok(exportedMetrics));
            }
            catch (Exception ex) {
                _logger.LogError(ex, "Get Metrics error");
                return(BadRequest());
            }
        }
コード例 #6
0
        public TestClient(string grpcHostName, int grpcPort, int metricsPort, ClientMetrics metrics = null)
        {
            MetricsPort    = metricsPort;
            _metricsServer = new MetricServer(MetricsHostname, MetricsPort);
            _metricsServer.Start();
            _interceptor = new ClientInterceptor(true, metrics);

            var channel = new Channel(grpcHostName, grpcPort, ChannelCredentials.Insecure);

            _client = new TestService.TestServiceClient(
                channel.Intercept(_interceptor));
        }
コード例 #7
0
        public async Task should_send_client_metrics()
        {
            _server.Given(
                Request
                .Create()
                .WithPath("/client/metrics")
                .WithHeader("UNLEASH-APPNAME", "test-app")
                .UsingGet())
            .RespondWith(
                Response
                .Create()
                .WithStatusCode(200)
                );

            var uri    = new Uri("http://localhost:" + _server.Ports.First());
            var config = UnleashConfig.TheBuilder().AppName("test-app").UnleashAPI(uri).Build();

            var sender  = new UnleashMetricsSender(config);
            var bucket  = new MetricsBucket();
            var metrics = new ClientMetrics(config, bucket);
            await sender.SendMetrics(metrics);
        }
コード例 #8
0
 private Task StartUiUpdater(CancellationToken token, ClientMetrics metrics) =>
 Task.Run(async() =>
コード例 #9
0
 public BaggageSetter(IRestrictBaggage baggageRestrictor, ClientMetrics metrics)
 {
     this.baggageRestrictor = baggageRestrictor ?? throw new ArgumentNullException(nameof(baggageRestrictor));
     this.metrics           = metrics;
 }
コード例 #10
0
 public RemoteReporter(ISender sender, WorkQueueOptions options, ClientMetrics metrics)
 {
     this.metrics = metrics ?? throw new ArgumentNullException(nameof(metrics));
     workQueue    = new WorkQueue(sender, options, metrics);
 }