forked from grafana/tempo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlimits.go
More file actions
90 lines (78 loc) · 3.7 KB
/
limits.go
File metadata and controls
90 lines (78 loc) · 3.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package api
import (
"time"
"github.com/grafana/tempo/modules/overrides"
"github.com/grafana/tempo/modules/overrides/histograms"
"github.com/grafana/tempo/modules/overrides/userconfigurable/client"
"github.com/grafana/tempo/pkg/spanfilter/config"
)
// limitsFromOverrides will reconstruct a client.Limits from the overrides module
func limitsFromOverrides(overrides overrides.Interface, userID string) *client.Limits {
return &client.Limits{
Forwarders: strArrPtr(overrides.Forwarders(userID)),
MetricsGenerator: client.LimitsMetricsGenerator{
Processors: overrides.MetricsGeneratorProcessors(userID),
DisableCollection: boolPtr(overrides.MetricsGeneratorDisableCollection(userID)),
CollectionInterval: timePtr(overrides.MetricsGeneratorCollectionInterval(userID)),
TraceIDLabelName: strPtr(overrides.MetricsGeneratorTraceIDLabelName(userID)),
IngestionSlack: timePtr(overrides.MetricsGeneratorIngestionSlack(userID)),
GenerateNativeHistograms: histogramModePtr(overrides.MetricsGeneratorGenerateNativeHistograms(userID)),
NativeHistogramMaxBucketNumber: uint32Ptr(overrides.MetricsGeneratorNativeHistogramMaxBucketNumber(userID)),
NativeHistogramBucketFactor: floatPtr(overrides.MetricsGeneratorNativeHistogramBucketFactor(userID)),
NativeHistogramMinResetDuration: timePtr(overrides.MetricsGeneratorNativeHistogramMinResetDuration(userID)),
Processor: client.LimitsMetricsGeneratorProcessor{
ServiceGraphs: client.LimitsMetricsGeneratorProcessorServiceGraphs{
Dimensions: strArrPtr(overrides.MetricsGeneratorProcessorServiceGraphsDimensions(userID)),
EnableClientServerPrefix: boolPtr(overrides.MetricsGeneratorProcessorServiceGraphsEnableClientServerPrefix(userID)),
PeerAttributes: strArrPtr(overrides.MetricsGeneratorProcessorServiceGraphsPeerAttributes(userID)),
HistogramBuckets: floatArrPtr(overrides.MetricsGeneratorProcessorServiceGraphsHistogramBuckets(userID)),
},
SpanMetrics: client.LimitsMetricsGeneratorProcessorSpanMetrics{
Dimensions: strArrPtr(overrides.MetricsGeneratorProcessorSpanMetricsDimensions(userID)),
EnableTargetInfo: func() *bool {
val, _ := overrides.MetricsGeneratorProcessorSpanMetricsEnableTargetInfo(userID)
return boolPtr(val)
}(),
FilterPolicies: filterPoliciesPtr(overrides.MetricsGeneratorProcessorSpanMetricsFilterPolicies(userID)),
HistogramBuckets: floatArrPtr(overrides.MetricsGeneratorProcessorSpanMetricsHistogramBuckets(userID)),
TargetInfoExcludedDimensions: strArrPtr(overrides.MetricsGeneratorProcessorSpanMetricsTargetInfoExcludedDimensions(userID)),
EnableInstanceLabel: func() *bool {
val, _ := overrides.MetricsGeneratorProcessorSpanMetricsEnableInstanceLabel(userID)
return boolPtr(val)
}(),
},
HostInfo: client.LimitsMetricGeneratorProcessorHostInfo{
HostIdentifiers: strArrPtr(overrides.MetricsGeneratorProcessorHostInfoHostIdentifiers(userID)),
MetricName: strPtr(overrides.MetricsGeneratorProcessorHostInfoMetricName(userID)),
},
},
},
}
}
func boolPtr(b bool) *bool {
return &b
}
func timePtr(t time.Duration) *client.Duration {
return &client.Duration{Duration: t}
}
func strPtr(s string) *string {
return &s
}
func strArrPtr(s []string) *[]string {
return &s
}
func floatArrPtr(f []float64) *[]float64 {
return &f
}
func floatPtr(f float64) *float64 {
return &f
}
func filterPoliciesPtr(p []config.FilterPolicy) *[]config.FilterPolicy {
return &p
}
func histogramModePtr(h histograms.HistogramMethod) *histograms.HistogramMethod {
return &h
}
func uint32Ptr(u uint32) *uint32 {
return &u
}