Exemple #1
0
        /// <summary>
        /// Bind to an existing metric given by "name"
        /// </summary>
        /// <param name="pipeline"></param>
        /// <param name="name"></param>
        /// <param name="connection"></param>
        /// <param name="connectionId"></param>
        public MetricConnection(EventPipeline pipeline, IConnection connection, string connectionId, string jsonMetric, string clientId)
        {
            _connection   = connection;
            _connectionId = connectionId;
            _clientId     = clientId;
            _jsonMetric   = JsonConvert.DeserializeObject <JsonMetric>(jsonMetric);



            // Try to find the metric, and add a watcher
            var metric = pipeline.GetProcessor(_jsonMetric.Name) as MetricProcessor;

            if (metric == null)
            {
                // Its new so we need to create a new one...
                var filePath = Path.Combine(PathManager.BasePath, "user", "metric", _jsonMetric.Name + ".json");
                //if (!File.Exists(filePath)) {
                var formattedJson = JsonConvert.SerializeObject(_jsonMetric, Formatting.Indented);
                File.WriteAllText(filePath, formattedJson);

                //}

                metric = new MetricProcessor(_jsonMetric.Name, _jsonMetric);
                pipeline.AddProcessor(metric);
            }

            metric.Updated(_connectionId, WriteValueUpdate);
            metric.Error(_connectionId, WriteErrorUpdate);


            SendUpdates(metric);
        }
Exemple #2
0
 public void ProcessWith<U>(
     MetricProcessor<U> processor,
     MetricName name,
     U context)
 {
     processor.ProcessGauge(name, this, context);
 }
Exemple #3
0
 public void ProcessWith<T>(
     MetricProcessor<T> processor,
     MetricName name,
     T context)
 {
     processor.ProcessCounter(name, this, context);
 }
Exemple #4
0
 public void ProcessWith<T>(
     MetricProcessor<T> processor,
     MetricName name,
     T context)
 {
     processor.ProcessHistogram(name, this, context);
 }
Exemple #5
0
 public void SendUpdates(MetricProcessor metric)
 {
     _connection.Send(_connectionId, new {
         ClientId = _clientId,
         Metric   = metric.CurrentState.Values,
         Success  = true
     });
 }
Exemple #6
0
        private MeterFactory(MetricProcessor metricProcessor)
        {
            if (metricProcessor == null)
            {
                this.metricProcessor = new NoOpMetricProcessor();
            }
            else
            {
                this.metricProcessor = metricProcessor;
            }

            this.defaultMeter = new MeterSdk(string.Empty, this.metricProcessor);
        }
        private MeterFactory(MeterBuilder meterBuilder)
        {
            this.metricProcessor = meterBuilder.MetricProcessor ?? new NoOpMetricProcessor();
            this.metricExporter  = meterBuilder.MetricExporter ?? new NoOpMetricExporter();

            // We only have PushMetricController now with only configurable thing being the push interval
            this.pushMetricController = new PushMetricController(
                this.meterRegistry,
                this.metricProcessor,
                this.metricExporter,
                meterBuilder.MetricPushInterval == default(TimeSpan) ? this.defaultPushInterval : meterBuilder.MetricPushInterval,
                new CancellationTokenSource());

            this.defaultMeter = new MeterSdk(string.Empty, this.metricProcessor);
        }
        private IEnumerable <List <Text> > PopulateMetrics()
        {
            var metricConfigs = _simulationSummary.PlayersData.Count > 1
                ? _multiplayerMetrics
                : _singleplayerMetrics;

            var sumByPlayerByMetrics = MetricProcessor.GetSumByPlayerByMetric(_simulationSummary.Events);

            var playerNameBestFitGroup  = new List <Text>();
            var metricTitleBestFitGroup = new List <Text>();
            var metricValueBestFitGroup = new List <Text>();

            var column = CreateColumn();

            playerNameBestFitGroup.ForEach(playerText => playerText.gameObject.AddComponent <TextCutoff>());

            AddPlayers(column.GetComponentInChildren <LayoutGroup>().gameObject, _simulationSummary.PlayersData, playerNameBestFitGroup);
            // Set players box to be wider than the rest
            var layoutElement = column.GetComponent <LayoutElement>();

            layoutElement.preferredWidth = layoutElement.preferredWidth * 3;
            layoutElement.minWidth       = layoutElement.minWidth * 3;

            foreach (var metricConfig in metricConfigs)
            {
                sumByPlayerByMetrics.TryGetValue(metricConfig.KeyMetric, out var valueByPlayer);

                column = CreateColumn();
                SetLocalizedTitle(column, metricConfig.KeyMetric, metricTitleBestFitGroup);
                SetIcon(column, metricConfig.IconPath);
                AddItems(
                    column.GetComponentInChildren <LayoutGroup>().gameObject,
                    _simulationSummary.PlayersData,
                    valueByPlayer,
                    0,
                    metricConfig.HighlightHighest,
                    metricValueBestFitGroup);
            }
            var playerMetrics = PlayerMetrics.GetPlayerBestMetrics(sumByPlayerByMetrics, _simulationSummary);

            AddMetricItems(playerMetrics);

            return(new[] { playerNameBestFitGroup, metricTitleBestFitGroup, metricValueBestFitGroup });
        }
 void context_EndRequest(object sender, EventArgs e)
 {
     try
     {
         HttpApplication application = sender as HttpApplication;
         this._timer.Stop();
         this._data.ResponseEndedUtc = DateTime.UtcNow;
         this._data.HttpResponseStatusCode = application.Response.StatusCode;
         this._data.HttpResponseSubStatusCode = application.Response.SubStatusCode;
         this._data.ResponseSize = application.Response.OutputStream.Length;
         this._data.ProcessingTime = this._timer.ElapsedMilliseconds;
         MetricProcessor processor = new MetricProcessor();
         processor.WriteRequestResponse(this._data);
     }
     catch (Exception ex)
     {
         Trace.Write(ex.Message);
     }
 }
Exemple #10
0
 public static MeterFactory Create(MetricProcessor metricProcessor)
 {
     return(new MeterFactory(metricProcessor));
 }
Exemple #11
0
 internal TestMeter(string meterName, MetricProcessor metricProcessor, Action collectAction)
     : base(meterName, metricProcessor)
 {
     this.collectAction = collectAction;
 }
 /// <summary>
 /// Configures metric processor. (aka batcher).
 /// </summary>
 /// <param name="metricProcessor">MetricProcessor instance.</param>
 /// <returns>The meter builder instance for chaining.</returns>
 public MeterBuilder SetMetricProcessor(MetricProcessor metricProcessor)
 {
     this.MetricProcessor = metricProcessor;
     return(this);
 }
        public OpenTelemetryMetrics(MetricProcessor processor, TimeSpan timeSpan)
        {
            var factory = new AutoCollectingMeterFactory(processor, timeSpan);

            _meter = factory.GetMeter("Steeltoe");
        }
 public OpenTelemetryMetrics(MetricProcessor processor = null)
 {
     _meter = MeterFactory.Create(processor).GetMeter("Steeltoe");
 }
Exemple #15
0
 public void WriteValueUpdate(MetricProcessor metric)
 {
     SendUpdates(metric);
 }