Skip to content

Add query/mutation logging in glog V=3.#5024

Merged
danielmai merged 1 commit intomasterfrom
danielmai/glog-v3-query-log
Apr 1, 2020
Merged

Add query/mutation logging in glog V=3.#5024
danielmai merged 1 commit intomasterfrom
danielmai/glog-v3-query-log

Conversation

@danielmai
Copy link
Copy Markdown
Contributor

@danielmai danielmai commented Mar 24, 2020

Closes #4944.

By setting -v=3 or --vmodule=server=3, then query/mutation logs will appear in the Alpha log.

Example:

Query (has query: field)

I0324 15:41:27.464042    9642 server.go:771] Got a query: query:"{ q(func: has(counter.val)) { uid, val: counter.val }}"

Mutation (has mutations: field)

I0324 15:41:27.474000    9642 server.go:771] Got a query: start_ts:20006 mutations:<set_nquads:"<0x1> <counter.val> \"11\"^^<xs:int> ." commit_now:true > commit_now:true

This change is Reviewable

@danielmai danielmai requested a review from manishrjain as a code owner March 24, 2020 22:43
@danielmai danielmai requested a review from a team March 24, 2020 22:43
@sleto-it
Copy link
Copy Markdown
Contributor

Needs doc. However new section about logs can be handled as part of DGRAPH-1165

Copy link
Copy Markdown
Contributor

@animesh2049 animesh2049 left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewable status: 0 of 1 files reviewed, all discussions resolved (waiting on @manishrjain)

Copy link
Copy Markdown
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: , just a question regarding new lines in the query.

Reviewed 1 of 1 files at r1.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @danielmai and @manishrjain)


edgraph/server.go, line 771 at r1 (raw file):

	resp *api.Response, rerr error) {
	if glog.V(3) {
		glog.Infof("Got a query: %+v", req)

will new lines in the query be printed as new lines in the log? If they do the query should be stripped of new lines to make sure the log is all in a single line.

@danielmai
Copy link
Copy Markdown
Contributor Author


edgraph/server.go, line 771 at r1 (raw file):

Previously, martinmr (Martin Martinez Rivera) wrote…

will new lines in the query be printed as new lines in the log? If they do the query should be stripped of new lines to make sure the log is all in a single line.

Good point. Logs are always in a single line. Queries have \n for newlines. e.g.,

I0401 19:59:26.541382      16 server.go:771] Got a query: query:"query {\n  getGQLSchema(func: type(dgraph.graphql)) {\n    id :
uid\n    schema : dgraph.graphql.schema\n    dgraph.uid : uid\n  }\n}" read_only:true

@danielmai danielmai merged commit a3f9647 into master Apr 1, 2020
@danielmai danielmai deleted the danielmai/glog-v3-query-log branch April 1, 2020 20:07
danielmai added a commit that referenced this pull request Apr 24, 2020
Closes #4944.

By setting `-v=3` or `--vmodule=server=3`, then query/mutation logs will appear in the Alpha log.

Examples:

Query (has `query:` field)
```
I0324 15:41:27.464042    9642 server.go:771] Got a query: query:"{ q(func: has(counter.val)) { uid, val: counter.val }}"
I0401 19:59:26.541382      16 server.go:771] Got a query: query:"query {\n  getGQLSchema(func: type(dgraph.graphql)) {\n    id :
uid\n    schema : dgraph.graphql.schema\n    dgraph.uid : uid\n  }\n}" read_only:true
```

Mutation (has `mutations:` field)
```
I0324 15:41:27.474000    9642 server.go:771] Got a query: start_ts:20006 mutations:<set_nquads:"<0x1> <counter.val> \"11\"^^<xs:int> ." commit_now:true > commit_now:true
```
danielmai added a commit that referenced this pull request Apr 24, 2020
Closes #4944.

By setting `-v=3` or `--vmodule=server=3`, then query/mutation logs will appear in the Alpha log.

Examples:

Query (has `query:` field)
```
I0324 15:41:27.464042    9642 server.go:771] Got a query: query:"{ q(func: has(counter.val)) { uid, val: counter.val }}"
I0401 19:59:26.541382      16 server.go:771] Got a query: query:"query {\n  getGQLSchema(func: type(dgraph.graphql)) {\n    id :
uid\n    schema : dgraph.graphql.schema\n    dgraph.uid : uid\n  }\n}" read_only:true
```

Mutation (has `mutations:` field)
```
I0324 15:41:27.474000    9642 server.go:771] Got a query: start_ts:20006 mutations:<set_nquads:"<0x1> <counter.val> \"11\"^^<xs:int> ." commit_now:true > commit_now:true
```
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.

[Feature] Query Log

4 participants