Exemple #1
0
            internal void WriteTo(TextWriter tw, string metric, string instance)
            {
                if (instance == null)
                {
                    tw.Write(metric);
                    tw.Write("_sum ");
                    tw.Write(this.sum.Value);
                    tw.Write('\n');

                    tw.Write(metric);
                    tw.Write("_count ");
                    tw.Write(this.count.Value);
                    tw.Write('\n');

                    for (var i = 0; i < this.bucketIntervals.Length; i++)
                    {
                        tw.Write(metric);
                        tw.Write("_bucket{le=\"");
                        tw.Write(this.bucketIntervals[i]);
                        tw.Write("\"} ");
                        tw.Write(this.values[i].Value);
                        tw.Write('\n');
                    }

                    tw.Write(metric);
                    tw.Write("_bucket{le=\"+Inf\"} ");
                    tw.Write(this.values[this.bucketIntervals.Length].Value);
                    tw.Write('\n');
                }
                else
                {
                    tw.Write(metric);
                    tw.Write("_sum{i=\"");
                    tw.Write(Metrics.EscapeInstanceName(instance));
                    tw.Write("\"} ");
                    tw.Write(this.sum.Value);
                    tw.Write('\n');

                    tw.Write(metric);
                    tw.Write("_count{i=\"");
                    tw.Write(Metrics.EscapeInstanceName(instance));
                    tw.Write("\"} ");
                    tw.Write(this.count.Value);
                    tw.Write('\n');

                    for (var i = 0; i < this.bucketIntervals.Length; i++)
                    {
                        tw.Write(metric);
                        tw.Write("_bucket{i=\"");
                        tw.Write(Metrics.EscapeInstanceName(instance));
                        tw.Write("\",le=\"");
                        tw.Write(this.bucketIntervals[i]);
                        tw.Write("\"} ");
                        tw.Write(this.values[i].Value);
                        tw.Write('\n');
                    }

                    tw.Write(metric);
                    tw.Write("_bucket{i=\"");
                    tw.Write(Metrics.EscapeInstanceName(instance));
                    tw.Write("\",le=\"+Inf\"} ");
                    tw.Write(this.values[this.bucketIntervals.Length].Value);
                    tw.Write('\n');
                }
            }