Skip to content

Commit

Permalink
Making metricObjective public so it can be mapped without YAML marsha…
Browse files Browse the repository at this point in the history
…lling
  • Loading branch information
gaantunes committed Mar 13, 2023
1 parent b7afa88 commit 9d8fda4
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 21 deletions.
6 changes: 3 additions & 3 deletions pkg/mapper/mapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ type MetricMapper struct {
}

type SummaryOptions struct {
Quantiles []metricObjective `yaml:"quantiles"`
Quantiles []MetricObjective `yaml:"quantiles"`
MaxAge time.Duration `yaml:"max_age"`
AgeBuckets uint32 `yaml:"age_buckets"`
BufCap uint32 `yaml:"buf_cap"`
Expand All @@ -69,12 +69,12 @@ type HistogramOptions struct {
NativeHistogramMaxBuckets uint32 `yaml:"native_histogram_max_buckets"`
}

type metricObjective struct {
type MetricObjective struct {
Quantile float64 `yaml:"quantile"`
Error float64 `yaml:"error"`
}

var defaultQuantiles = []metricObjective{
var defaultQuantiles = []MetricObjective{
{Quantile: 0.5, Error: 0.05},
{Quantile: 0.9, Error: 0.01},
{Quantile: 0.99, Error: 0.001},
Expand Down
2 changes: 1 addition & 1 deletion pkg/mapper/mapper_defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type mapperConfigDefaultsAlias struct {
ObserverType ObserverType `yaml:"observer_type"`
TimerType ObserverType `yaml:"timer_type,omitempty"` // DEPRECATED - field only present to preserve backwards compatibility in configs
Buckets []float64 `yaml:"buckets"` // DEPRECATED - field only present to preserve backwards compatibility in configs
Quantiles []metricObjective `yaml:"quantiles"` // DEPRECATED - field only present to preserve backwards compatibility in configs
Quantiles []MetricObjective `yaml:"quantiles"` // DEPRECATED - field only present to preserve backwards compatibility in configs
MatchType MatchType `yaml:"match_type"`
GlobDisableOrdering bool `yaml:"glob_disable_ordering"`
Ttl time.Duration `yaml:"ttl"`
Expand Down
32 changes: 16 additions & 16 deletions pkg/mapper/mapper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type mappings []struct {
statsdMetric string
name string
labels map[string]string
quantiles []metricObjective
quantiles []MetricObjective
notPresent bool
ttl time.Duration
metricType MetricType
Expand Down Expand Up @@ -570,7 +570,7 @@ mappings:
statsdMetric: "test.*.*",
name: "foo",
labels: map[string]string{},
quantiles: []metricObjective{
quantiles: []MetricObjective{
{Quantile: 0.42, Error: 0.04},
{Quantile: 0.7, Error: 0.002},
},
Expand All @@ -597,7 +597,7 @@ mappings:
statsdMetric: "test.*.*",
name: "foo",
labels: map[string]string{},
quantiles: []metricObjective{
quantiles: []MetricObjective{
{Quantile: 0.42, Error: 0.04},
{Quantile: 0.7, Error: 0.002},
},
Expand All @@ -618,7 +618,7 @@ mappings:
statsdMetric: "test1.*.*",
name: "foo",
labels: map[string]string{},
quantiles: []metricObjective{
quantiles: []MetricObjective{
{Quantile: 0.5, Error: 0.05},
{Quantile: 0.9, Error: 0.01},
{Quantile: 0.99, Error: 0.001},
Expand All @@ -640,7 +640,7 @@ mappings:
statsdMetric: "test1.*.*",
name: "foo",
labels: map[string]string{},
quantiles: []metricObjective{
quantiles: []MetricObjective{
{Quantile: 0.5, Error: 0.05},
{Quantile: 0.9, Error: 0.01},
{Quantile: 0.99, Error: 0.001},
Expand Down Expand Up @@ -690,7 +690,7 @@ mappings:
statsdMetric: "test.*.*",
name: "foo",
labels: map[string]string{},
quantiles: []metricObjective{
quantiles: []MetricObjective{
{Quantile: 0.42, Error: 0.04},
{Quantile: 0.7, Error: 0.002},
},
Expand Down Expand Up @@ -720,7 +720,7 @@ mappings:
statsdMetric: "test.*.*",
name: "foo",
labels: map[string]string{},
quantiles: []metricObjective{
quantiles: []MetricObjective{
{Quantile: 0.42, Error: 0.04},
{Quantile: 0.7, Error: 0.002},
},
Expand Down Expand Up @@ -754,7 +754,7 @@ mappings:
statsdMetric: "test.*.*",
name: "foo",
labels: map[string]string{},
quantiles: []metricObjective{
quantiles: []MetricObjective{
{Quantile: 0.42, Error: 0.04},
{Quantile: 0.7, Error: 0.002},
},
Expand Down Expand Up @@ -819,7 +819,7 @@ mappings:
statsdMetric: "test.*.*",
name: "foo",
labels: map[string]string{},
quantiles: []metricObjective{
quantiles: []MetricObjective{
{Quantile: 0.42, Error: 0.04},
{Quantile: 0.7, Error: 0.002},
},
Expand Down Expand Up @@ -862,7 +862,7 @@ mappings:
statsdMetric: "test.*.*",
name: "foo",
labels: map[string]string{},
quantiles: []metricObjective{
quantiles: []MetricObjective{
{Quantile: 0.42, Error: 0.04},
{Quantile: 0.7, Error: 0.002},
},
Expand Down Expand Up @@ -909,7 +909,7 @@ mappings:
statsdMetric: "test.*.*",
name: "foo",
labels: map[string]string{},
quantiles: []metricObjective{
quantiles: []MetricObjective{
{Quantile: 0.42, Error: 0.04},
{Quantile: 0.7, Error: 0.002},
},
Expand All @@ -921,7 +921,7 @@ mappings:
statsdMetric: "test_default.*.*",
name: "foo_default",
labels: map[string]string{},
quantiles: []metricObjective{
quantiles: []MetricObjective{
{Quantile: 0.9, Error: 0.1},
{Quantile: 0.99, Error: 0.01},
},
Expand Down Expand Up @@ -965,7 +965,7 @@ mappings:
statsdMetric: "test.*.*",
name: "foo",
labels: map[string]string{},
quantiles: []metricObjective{
quantiles: []MetricObjective{
{Quantile: 0.42, Error: 0.04},
{Quantile: 0.7, Error: 0.002},
},
Expand All @@ -977,7 +977,7 @@ mappings:
statsdMetric: "test_default.*.*",
name: "foo_default",
labels: map[string]string{},
quantiles: []metricObjective{
quantiles: []MetricObjective{
{Quantile: 0.9, Error: 0.1},
{Quantile: 0.99, Error: 0.01},
},
Expand Down Expand Up @@ -1017,7 +1017,7 @@ mappings:
statsdMetric: "test.*.*",
name: "foo",
labels: map[string]string{},
quantiles: []metricObjective{
quantiles: []MetricObjective{
{Quantile: 0.9, Error: 0.1},
{Quantile: 0.99, Error: 0.01},
},
Expand All @@ -1029,7 +1029,7 @@ mappings:
statsdMetric: "test_default.*.*",
name: "foo_default",
labels: map[string]string{},
quantiles: []metricObjective{
quantiles: []MetricObjective{
{Quantile: 0.9, Error: 0.1},
{Quantile: 0.99, Error: 0.01},
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/mapper/mapping.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type MetricMapping struct {
ObserverType ObserverType `yaml:"observer_type"`
TimerType ObserverType `yaml:"timer_type,omitempty"` // DEPRECATED - field only present to preserve backwards compatibility in configs. Always empty
LegacyBuckets []float64 `yaml:"buckets"`
LegacyQuantiles []metricObjective `yaml:"quantiles"`
LegacyQuantiles []MetricObjective `yaml:"quantiles"`
MatchType MatchType `yaml:"match_type"`
HelpText string `yaml:"help"`
Action ActionType `yaml:"action"`
Expand Down

0 comments on commit 9d8fda4

Please sign in to comment.