MCPcopy
hub / github.com/grafana/tempo / newHistogram

Function newHistogram

modules/generator/registry/histogram.go:70–96  ·  view source on GitHub ↗
(name string, buckets []float64, lifecycler Limiter, traceIDLabelName string, externalLabels map[string]string, staleDuration time.Duration)

Source from the content-addressed store, hash-verified

68)
69
70func newHistogram(name string, buckets []float64, lifecycler Limiter, traceIDLabelName string, externalLabels map[string]string, staleDuration time.Duration) *histogram {
71 if traceIDLabelName == "" {
72 traceIDLabelName = "traceID"
73 }
74
75 // add +Inf bucket
76 buckets = append(buckets, math.Inf(1))
77
78 bucketLabels := make([]string, len(buckets))
79 for i, bucket := range buckets {
80 bucketLabels[i] = formatFloat(bucket)
81 }
82
83 return &histogram{
84 metricName: name,
85 nameCount: fmt.Sprintf("%s_count", name),
86 nameSum: fmt.Sprintf("%s_sum", name),
87 nameBucket: fmt.Sprintf("%s_bucket", name),
88 buckets: buckets,
89 bucketLabels: bucketLabels,
90 series: make(map[uint64]*histogramSeries),
91 seriesDemand: NewCardinality(staleDuration, removeStaleSeriesInterval),
92 lifecycler: lifecycler,
93 traceIDLabelName: traceIDLabelName,
94 externalLabels: externalLabels,
95 }
96}
97
98func (h *histogram) ObserveWithExemplar(lbls labels.Labels, value float64, traceID string, multiplier float64) {
99 hash := lbls.Hash()

Calls 2

formatFloatFunction · 0.85
NewCardinalityFunction · 0.85