Skip to content

Commit

Permalink
Add LogRequest variable to config input (#5197)
Browse files Browse the repository at this point in the history
Fixes: DGRAPH-1123

This PR adds support for logRequest config param. logRequest can have true/false values. True
value of logRequest enables logging of all requests coming to alphas. False value of logRequest
disables it.
Users will be able to dynamically change this param using graphql admin endpoint.
Sample query:

mutation {
  config(input: {logRequest: true}){
    response {
      code
      message
    }
  }
}
Internally we have added one more field in WorkerOptions(WorkerConfig) called as LogRequest
of int32 type. Value of this field is checked atomically upon every request arrival. If value of
LogRequest is 1, it results in logging of requests.

Co-authored-by: Ashish Goswami <[email protected]>
(cherry picked from commit 449c06b)
  • Loading branch information
animesh2049 authored and OmarAyo committed Dec 8, 2020
1 parent e33bb1d commit be7fced
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion graphql/admin/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func resolveUpdateConfig(ctx context.Context, m schema.Mutation) (*resolve.Resol

if input.LruMB > 0 {
if err = worker.UpdateLruMb(input.LruMB); err != nil {
return resolve.EmptyResult(m, err), false
return emptyResult(m, err), false
}
}

Expand Down
4 changes: 2 additions & 2 deletions x/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ type WorkerOptions struct {
StartTime time.Time
// LudicrousMode is super fast mode with fewer guarantees.
LudicrousMode bool
// EncryptionKey is the key used for encryption at rest, backups, exports. Enterprise only feature.
EncryptionKey SensitiveByteSlice
// BadgerKeyFile is the file containing the key used for encryption. Enterprise only feature.
BadgerKeyFile string
// LogRequest indicates whether alpha should log all query/mutation requests coming to it.
// Ideally LogRequest should be a bool value. But we are reading it using atomics across
// queries hence it has been kept as int32. LogRequest value 1 enables logging of requests
Expand Down

0 comments on commit be7fced

Please sign in to comment.