Esempio n. 1
0
                                // getDescription returns the description of data.
                                private static @string getDescription(metric.Data data)
                                {
                                    switch (data.type())
                                    {
                                    case ptr <metric.Int64Data> d:
                                        return(d.Info.Description);

                                        break;

                                    case ptr <metric.Float64Data> d:
                                        return(d.Info.Description);

                                        break;

                                    case ptr <metric.HistogramInt64Data> d:
                                        return(d.Info.Description);

                                        break;

                                    case ptr <metric.HistogramFloat64Data> d:
                                        return(d.Info.Description);

                                        break;
                                    }

                                    return("");
                                }
Esempio n. 2
0
                                // dataToMetricDescriptorType returns a wire.MetricDescriptor_Type based on the
                                // underlying type of data.
                                private static wire.MetricDescriptor_Type dataToMetricDescriptorType(metric.Data data)
                                {
                                    switch (data.type())
                                    {
                                    case ptr <metric.Int64Data> d:
                                        if (d.IsGauge)
                                        {
                                            return(wire.MetricDescriptor_GAUGE_INT64);
                                        }

                                        return(wire.MetricDescriptor_CUMULATIVE_INT64);

                                        break;

                                    case ptr <metric.Float64Data> d:
                                        if (d.IsGauge)
                                        {
                                            return(wire.MetricDescriptor_GAUGE_DOUBLE);
                                        }

                                        return(wire.MetricDescriptor_CUMULATIVE_DOUBLE);

                                        break;

                                    case ptr <metric.HistogramInt64Data> d:
                                        return(wire.MetricDescriptor_CUMULATIVE_DISTRIBUTION);

                                        break;

                                    case ptr <metric.HistogramFloat64Data> d:
                                        return(wire.MetricDescriptor_CUMULATIVE_DISTRIBUTION);

                                        break;
                                    }

                                    return(wire.MetricDescriptor_UNSPECIFIED);
                                }
Esempio n. 3
0
                                // getLabelKeys returns a slice of *wire.LabelKeys based on the keys
                                // in data.
                                private static slice <ptr <wire.LabelKey> > getLabelKeys(metric.Data data)
                                {
                                    switch (data.type())
                                    {
                                    case ptr <metric.Int64Data> d:
                                        return(infoKeysToLabelKeys(d.Info.Keys));

                                        break;

                                    case ptr <metric.Float64Data> d:
                                        return(infoKeysToLabelKeys(d.Info.Keys));

                                        break;

                                    case ptr <metric.HistogramInt64Data> d:
                                        return(infoKeysToLabelKeys(d.Info.Keys));

                                        break;

                                    case ptr <metric.HistogramFloat64Data> d:
                                        return(infoKeysToLabelKeys(d.Info.Keys));

                                        break;
                                    }

                                    return(null);
                                }
Esempio n. 4
0
                                // dataToMetricDescriptor return a *wire.MetricDescriptor based on data.
                                private static ptr <wire.MetricDescriptor> dataToMetricDescriptor(metric.Data data)
                                {
                                    if (data == null)
                                    {
                                        return(_addr_null !);
                                    }
                                    ptr <wire.MetricDescriptor> descriptor = addr(new wire.MetricDescriptor(Name: data.Handle(), Description: getDescription(data), Type: dataToMetricDescriptorType(data), LabelKeys: getLabelKeys(data), ));

                                    return(_addr_descriptor !);
                                }
Esempio n. 5
0
                                // dataToTimeseries returns a slice of *wire.TimeSeries based on the
                                // points in data.
                                private static slice <ptr <wire.TimeSeries> > dataToTimeseries(metric.Data data, time.Time start)
                                {
                                    if (data == null)
                                    {
                                        return(null);
                                    }

                                    var     numRows        = numRows(data);
                                    ref var startTimestamp = ref heap(convertTimestamp(start), out ptr <var> _addr_startTimestamp);