Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[query] Adds histogram_quantile function #1373

Merged
merged 7 commits into from
Feb 14, 2019
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/cmd/services/m3query/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,10 @@ type TagOptionsConfiguration struct {
// If not provided, defaults to `__name__`.
MetricName string `yaml:"metricName"`

// BucketName specifies the tag name that corresponds to the metric's bucket.
// If not provided, defaults to `le`.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is le from Prom?

Copy link
Collaborator

@benraskin92 benraskin92 Feb 13, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nvm - saw below

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep 👍

BucketName string `yaml:"bucketName"`

// Scheme determines the default ID generation scheme. Defaults to TypeLegacy.
Scheme models.IDSchemeType `yaml:"idScheme"`
}
Expand All @@ -311,6 +315,11 @@ func TagOptionsFromConfig(cfg TagOptionsConfiguration) (models.TagOptions, error
opts = opts.SetMetricName([]byte(name))
}

bucket := cfg.BucketName
if bucket != "" {
opts = opts.SetBucketName([]byte(bucket))
}

if cfg.Scheme == models.TypeDefault {
cfg.Scheme = models.TypeLegacy
}
Expand Down
4 changes: 3 additions & 1 deletion src/cmd/services/m3query/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,17 @@ func TestDefaultTagOptionsConfig(t *testing.T) {
opts, err := TagOptionsFromConfig(cfg)
require.NoError(t, err)
assert.Equal(t, []byte("__name__"), opts.MetricName())
assert.Equal(t, []byte("le"), opts.BucketName())
assert.Equal(t, models.TypeLegacy, opts.IDSchemeType())
}

func TestTagOptionsConfig(t *testing.T) {
var cfg TagOptionsConfiguration
config := "metricName: abcdefg\nidScheme: prepend_meta"
config := "metricName: abcdefg\nidScheme: prepend_meta\nbucketName: foo"
require.NoError(t, yaml.Unmarshal([]byte(config), &cfg))
opts, err := TagOptionsFromConfig(cfg)
require.NoError(t, err)
assert.Equal(t, []byte("abcdefg"), opts.MetricName())
assert.Equal(t, []byte("foo"), opts.BucketName())
assert.Equal(t, models.TypePrependMeta, opts.IDSchemeType())
}
22 changes: 11 additions & 11 deletions src/query/functions/aggregation/base_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ import (

var (
seriesMetas = []block.SeriesMeta{
{Tags: test.StringTagsToTags(test.StringTags{{"a", "1"}, {"d", "4"}})},
{Tags: test.StringTagsToTags(test.StringTags{{"a", "1"}, {"d", "4"}})},
{Tags: test.StringTagsToTags(test.StringTags{{"a", "1"}, {"b", "2"}, {"d", "4"}})},
{Tags: test.StringTagsToTags(test.StringTags{{"a", "2"}, {"b", "2"}, {"d", "4"}})},
{Tags: test.StringTagsToTags(test.StringTags{{"b", "2"}, {"d", "4"}})},
{Tags: test.StringTagsToTags(test.StringTags{{"c", "3"}, {"d", "4"}})},
{Tags: test.StringTagsToTags(test.StringTags{{N: "a", V: "1"}, {N: "d", V: "4"}})},
{Tags: test.StringTagsToTags(test.StringTags{{N: "a", V: "1"}, {N: "d", V: "4"}})},
{Tags: test.StringTagsToTags(test.StringTags{{N: "a", V: "1"}, {N: "b", V: "2"}, {N: "d", V: "4"}})},
{Tags: test.StringTagsToTags(test.StringTags{{N: "a", V: "2"}, {N: "b", V: "2"}, {N: "d", V: "4"}})},
{Tags: test.StringTagsToTags(test.StringTags{{N: "b", V: "2"}, {N: "d", V: "4"}})},
{Tags: test.StringTagsToTags(test.StringTags{{N: "c", V: "3"}, {N: "d", V: "4"}})},
}
v = [][]float64{
{0, math.NaN(), 2, 3, 4},
Expand Down Expand Up @@ -168,11 +168,11 @@ func TestFunctionFilteringWithoutD(t *testing.T) {
}

expectedMetas := []block.SeriesMeta{
{Name: typeBytes, Tags: test.StringTagsToTags(test.StringTags{{"a", "1"}})},
{Name: typeBytes, Tags: test.StringTagsToTags(test.StringTags{{"a", "1"}, {"b", "2"}})},
{Name: typeBytes, Tags: test.StringTagsToTags(test.StringTags{{"a", "2"}, {"b", "2"}})},
{Name: typeBytes, Tags: test.StringTagsToTags(test.StringTags{{"b", "2"}})},
{Name: typeBytes, Tags: test.StringTagsToTags(test.StringTags{{"c", "3"}})},
{Name: typeBytes, Tags: test.StringTagsToTags(test.StringTags{{N: "a", V: "1"}})},
{Name: typeBytes, Tags: test.StringTagsToTags(test.StringTags{{N: "a", V: "1"}, {N: "b", V: "2"}})},
{Name: typeBytes, Tags: test.StringTagsToTags(test.StringTags{{N: "a", V: "2"}, {N: "b", V: "2"}})},
{Name: typeBytes, Tags: test.StringTagsToTags(test.StringTags{{N: "b", V: "2"}})},
{Name: typeBytes, Tags: test.StringTagsToTags(test.StringTags{{N: "c", V: "3"}})},
}
expectedMetaTags := models.EmptyTags()

Expand Down
Loading