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

feat: add metrics cost to grpc and http header #6148

Merged
merged 8 commits into from
Aug 10, 2020
Merged

Conversation

poonai
Copy link
Contributor

@poonai poonai commented Aug 7, 2020


This change is Reviewable

பாலாஜி and others added 3 commits August 7, 2020 12:05
Signed-off-by: பாலாஜி <[email protected]>
Signed-off-by: Balaji <[email protected]>
Signed-off-by: Balaji <[email protected]>
Copy link
Contributor

@gja gja left a comment

Choose a reason for hiding this comment

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

Small feedback, but looks good

x/x.go Outdated Show resolved Hide resolved
@@ -196,6 +196,37 @@ func queryWithTs(queryText, contentType, debug string, ts uint64) (string, uint6
return string(output), startTs, err
}

func queryWithTsForCost(queryText, contentType, debug string, ts uint64) (string,
Copy link
Contributor

Choose a reason for hiding this comment

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

rather than making this a new function, you should probably pass options to queryWithTs(). Or if you don't want to do update all the callers.

type validationOpts struct {
  ResponseCallback func() 
}

func _queryWithTs(..., opts *validationOpts) {
...
context := map[string]interface{}
  if opt.ResponseCallback {
    err := opt.ResponseCallback(context, response)
  }

  return ..., context, error
}

func Test...() {
  ...
  queryWithTs(..., &callbackOptions{ResponseCallback: func() { // put cost into context }})
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've made it to return resp instead of passing the validation function.

பாலாஜி added 3 commits August 7, 2020 14:17
Signed-off-by: பாலாஜி <[email protected]>
Signed-off-by: பாலாஜி <[email protected]>
Signed-off-by: பாலாஜி <[email protected]>
x/x.go Outdated
@@ -146,6 +146,7 @@ const (
AccessControlAllowedHeaders = "X-Dgraph-AccessToken, " +
"Content-Type, Content-Length, Accept-Encoding, Cache-Control, " +
"X-CSRF-Token, X-Auth-Token, X-Requested-With"
DgraphCostHeader = "numUids"
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh sorry, I should have been explicit 🙈.. Let's keep it similar to graphql.

Dgraph-TouchedUids

Copy link
Contributor

@martinmr martinmr left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 1 of 4 files at r1, 1 of 2 files at r2, 1 of 1 files at r4, 1 of 1 files at r5.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @balajijinnah, @gja, @manishrjain, @pawanrawal, and @vvbalaji-dgraph)


dgraph/cmd/alpha/http_test.go, line 199 at r5 (raw file):

}

func queryWithTsForResp(queryText, contentType, debug string, ts uint64) (string,

Add a comment for these functions so it's clearer what the difference is to the other function with a similar name.

Signed-off-by: பாலாஜி <[email protected]>
Copy link
Contributor

@darkn3rd darkn3rd left a comment

Choose a reason for hiding this comment

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

Unit Tests for the Metric?

Reviewed 1 of 4 files at r1, 1 of 2 files at r2, 1 of 1 files at r5, 1 of 1 files at r6.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @balajijinnah, @gja, @manishrjain, @pawanrawal, and @vvbalaji-dgraph)

@poonai poonai changed the title add metrics cost to grpc and http header feat: add metrics cost to grpc and http header Aug 10, 2020
@poonai
Copy link
Contributor Author

poonai commented Aug 10, 2020

@darkn3rd I've added integration test. That should be enough.

@poonai poonai merged commit d1c3cd7 into master Aug 10, 2020
@poonai poonai deleted the balaji/metrics_slash branch August 10, 2020 04:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants