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] Add pickled format for graphite render endpoint #1446

Merged
merged 6 commits into from
Mar 15, 2019

Conversation

arnikola
Copy link
Collaborator

No description provided.

@codecov
Copy link

codecov bot commented Mar 13, 2019

Codecov Report

Merging #1446 into master will increase coverage by <.1%.
The diff coverage is 47.8%.

Impacted file tree graph

@@           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
Flag Coverage Δ
#aggregator 82.3% <ø> (ø) ⬆️
#cluster 85.8% <ø> (ø) ⬆️
#collector 63.7% <ø> (ø) ⬆️
#dbnode 80.8% <ø> (ø) ⬆️
#m3em 73.2% <ø> (ø) ⬆️
#m3ninx 74.2% <ø> (ø) ⬆️
#m3nsch 51.1% <ø> (ø) ⬆️
#metrics 17.6% <ø> (ø) ⬆️
#msg 74.9% <ø> (-0.2%) ⬇️
#query 65.7% <47.8%> (-0.2%) ⬇️
#x 76% <ø> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3f4f16e...e58c632. Read the comment docs.

@codecov
Copy link

codecov bot commented Mar 13, 2019

Codecov Report

Merging #1446 into master will decrease coverage by <.1%.
The diff coverage is 48.7%.

Impacted file tree graph

@@           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
Flag Coverage Δ
#aggregator 82.3% <ø> (-0.1%) ⬇️
#cluster 85.8% <ø> (ø) ⬆️
#collector 63.7% <ø> (ø) ⬆️
#dbnode 80.6% <ø> (-0.1%) ⬇️
#m3em 73.2% <ø> (ø) ⬆️
#m3ninx 74.2% <ø> (ø) ⬆️
#m3nsch 51.1% <ø> (ø) ⬆️
#metrics 17.6% <ø> (ø) ⬆️
#msg 74.9% <ø> (-0.2%) ⬇️
#query 65.7% <48.7%> (-0.2%) ⬇️
#x 76% <ø> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3f4f16e...e57545f. Read the comment docs.


// NewWriter creates a new pickle writer.
func NewWriter(w io.Writer) *Writer {
// TODO(mmihic): Consider pooling
Copy link
Collaborator

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"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

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

Copy link
Collaborator Author

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()
Copy link
Collaborator

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()

Copy link
Collaborator Author

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

@@ -103,7 +103,7 @@ func NewHandler(
embeddedDbCfg *dbconfig.DBConfiguration,
scope tally.Scope,
) (*Handler, error) {
r := mux.NewRouter()
r := mux.NewRouter().StrictSlash(true)
Copy link
Collaborator

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

Copy link
Collaborator Author

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
Copy link
Collaborator

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.

Copy link
Collaborator Author

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

Log error instead then?

Copy link
Collaborator Author

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
Copy link
Collaborator

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
Copy link
Collaborator

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
Copy link
Collaborator

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
Copy link
Collaborator

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
Copy link
Collaborator

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")
Copy link
Collaborator

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..

Copy link
Collaborator Author

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),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why the quotes? 'query'

Copy link
Collaborator Author

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.
Copy link
Collaborator

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
Copy link
Collaborator

Choose a reason for hiding this comment

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

. here

Copy link
Collaborator

@benraskin92 benraskin92 left a comment

Choose a reason for hiding this comment

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

LGTM

@arnikola arnikola merged commit 55d8b41 into master Mar 15, 2019
@justinjc justinjc deleted the arnikola/pickle-format branch June 17, 2019 21:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants