-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Add support to show metrics #4033
Merged
Merged
Changes from 3 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
e25e61a
add metrics for attributes
382e964
call recursively
0a8c19d
change destuid to src uid
poonai fefda14
moved to execution result
c7c8608
Merge branch 'master' of https://github.com/dgraph-io/dgraph into bal…
b4a5cff
add api
24eea69
test added
9e43fb3
don't return
poonai 2550922
typo fixed
poonai d1a0444
Merge branch 'master' of https://github.com/dgraph-io/dgraph into bal…
poonai ffa28fc
fix sys test
071e164
increment one for the systest index test. beacuse, num_uid will give …
c5c10a8
Merge branch 'master' of https://github.com/dgraph-io/dgraph into bal…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,15 +41,19 @@ import ( | |
// ToJson converts the list of subgraph into a JSON response by calling toFastJSON. | ||
func ToJson(l *Latency, sgl []*SubGraph) ([]byte, error) { | ||
sgr := &SubGraph{} | ||
metricsMap := map[string]int{} | ||
for _, sg := range sgl { | ||
if sg.Params.Alias == "var" || sg.Params.Alias == "shortest" { | ||
continue | ||
} | ||
if sg.Params.GetUid { | ||
sgr.Params.GetUid = true | ||
} | ||
// calculate metrics for this query. | ||
calculateMetrics(sg, metricsMap) | ||
sgr.Children = append(sgr.Children, sg) | ||
} | ||
fmt.Println(metricsMap) | ||
return sgr.toFastJSON(l) | ||
} | ||
|
||
|
@@ -810,3 +814,23 @@ func (sg *SubGraph) preTraverse(uid uint64, dst outputNode) error { | |
|
||
return nil | ||
} | ||
|
||
// calculateMetrics populates the given map with the number of uids are gathered for each | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. calculateMetrics populates the given map with the number of uids |
||
// attributes. | ||
func calculateMetrics(sg *SubGraph, metrics map[string]int) { | ||
mangalaman93 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// we'll calculate srcUid of the each attribute. because, these are number of uids | ||
// processed by this attribute. | ||
prev := metrics[sg.Attr] | ||
// QUESTION: @manish @pawan: should I add destuid or length of posting list?. | ||
prev = prev + len(sg.SrcUIDs.GetUids()) | ||
metrics[sg.Attr] = prev | ||
mangalaman93 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
// add all the uids gathered by filters | ||
mangalaman93 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
for _, filter := range sg.Filters { | ||
calculateMetrics(filter, metrics) | ||
} | ||
// calculate metrics for the childres as well. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
for _, child := range sg.Children { | ||
calculateMetrics(child, metrics) | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Is this for logging purposes or to console to validate?