-
Notifications
You must be signed in to change notification settings - Fork 455
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] Add pickled format for graphite render endpoint #1446
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1446 +/- ##
========================================
+ Coverage 70.8% 70.8% +<.1%
========================================
Files 836 837 +1
Lines 71507 71606 +99
========================================
+ Hits 50676 50748 +72
- Misses 17532 17546 +14
- Partials 3299 3312 +13
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #1446 +/- ##
========================================
- Coverage 70.8% 70.8% -0.1%
========================================
Files 836 837 +1
Lines 71507 71609 +102
========================================
+ Hits 50676 50709 +33
- Misses 17532 17577 +45
- Partials 3299 3323 +24
Continue to review full report at Codecov.
|
|
||
// NewWriter creates a new pickle writer. | ||
func NewWriter(w io.Writer) *Writer { | ||
// TODO(mmihic): Consider pooling |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove
"math" | ||
"testing" | ||
|
||
"github.com/hydrogen18/stalecucumber" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sure this license is okay to use: https://github.com/hydrogen18/stalecucumber/blob/master/LICENSE
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point; I think that's more permissive than apache2 but will double check
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Explicitly called out as legit here: http://www.apache.org/legal/resolved.html#category-a
for i := 0; i < s.Len(); i++ { | ||
pw.WriteFloat64(s.ValueAt(i)) | ||
} | ||
pw.EndList() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need:
pw.WriteDictKey("graphOptions")
pw.BeginDict()
for k, v := range s.GraphOptions {
pw.WriteDictKey(k)
pw.WriteString(v)
}
pw.EndDict()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got rid of this since we don't take graph options as an arg; it's things for display options like color
etc
src/query/api/v1/httpd/handler.go
Outdated
@@ -103,7 +103,7 @@ func NewHandler( | |||
embeddedDbCfg *dbconfig.DBConfiguration, | |||
scope tally.Scope, | |||
) (*Handler, error) { | |||
r := mux.NewRouter() | |||
r := mux.NewRouter().StrictSlash(true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We want to redirect?
Also, guess other people are confused... gorilla/mux#145
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops this was me trying things out and accidentally adding it here
m3query := translateQuery(query, opts) | ||
m3query, err := translateQuery(query, opts) | ||
if err != nil { | ||
// NB: error here implies the query cannot be translated; empty set expected |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like we should just return the error, no? we can discuss offline.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is mostly for graphite web integration which is happier receiving empty results
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log error instead then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a log
|
||
// A Writer is capable writing out the opcodes required by the pickle format. | ||
// Note that this is a very limited implementation of pickling; just enough for | ||
// us to implement the opcodes required by graphite /render |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.
at the end :)
p.WriteString(s) | ||
} | ||
|
||
// EndDict ends marshalling a python dict |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
p.err = p.w.WriteByte(opSetItems) | ||
} | ||
|
||
// BeginList begins writing a new python list |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
_, p.err = p.w.Write(listStart) | ||
} | ||
|
||
// EndList ends writing a python list |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
p.w.WriteByte(opAppends) | ||
} | ||
|
||
// WriteNone writes a python None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same with all comments!
w.WriteString("hello world") | ||
w.WriteDictKey("nested") | ||
w.BeginDict() | ||
w.WriteDictKey("monkeyFoods") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you clean up the actual wording :) monkeyFoods
is kind of weird..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just test data, but changed 👍
matchers := graphiteStorage.TranslateQueryToMatchers(query) | ||
matchers, err := graphiteStorage.TranslateQueryToMatchers(query) | ||
if err != nil { | ||
return nil, xhttp.NewParseError(fmt.Errorf("invalid 'query': %s", query), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the quotes? 'query'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It provides some additional context that specifically the query
parameter is the issue
|
||
package pickle | ||
|
||
// op list. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add an additional comment explaining what these are used for?
@@ -47,18 +48,40 @@ func NewM3WrappedStorage(m3storage storage.Storage) Storage { | |||
return &m3WrappedStore{m3: m3storage} | |||
} | |||
|
|||
// TranslateQueryToMatchers converts a graphite query to tag matcher pairs. | |||
func TranslateQueryToMatchers(query string) models.Matchers { | |||
// translates a graphite query to tag matcher pairs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.
here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
No description provided.