Reduce graphql-middleware and graphql-server logs (#18738)

This commit is contained in:
Gustavo Trott 2023-09-07 11:54:27 -03:00 committed by GitHub
parent b8eade7735
commit 047eccdd92
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 19 additions and 16 deletions

View File

@ -29,7 +29,7 @@ func HasuraClient(browserConnection *common.BrowserConnection, cookies []*http.C
hasuraConnectionId := "HC" + fmt.Sprintf("%010d", lastHasuraConnectionId) hasuraConnectionId := "HC" + fmt.Sprintf("%010d", lastHasuraConnectionId)
log = log.WithField("hasuraConnectionId", hasuraConnectionId) log = log.WithField("hasuraConnectionId", hasuraConnectionId)
defer log.Infof("finished") defer log.Debugf("finished")
// Add sub-protocol // Add sub-protocol
var dialOptions websocket.DialOptions var dialOptions websocket.DialOptions
@ -80,7 +80,7 @@ func HasuraClient(browserConnection *common.BrowserConnection, cookies []*http.C
thisConnection.Websocket = c thisConnection.Websocket = c
// Log the connection success // Log the connection success
log.Infof("connected with Hasura") log.Debugf("connected with Hasura")
// Configure the wait group // Configure the wait group
var wg sync.WaitGroup var wg sync.WaitGroup

View File

@ -16,7 +16,7 @@ func HasuraConnectionReader(hc *common.HasuraConnection, fromHasuraToBrowserChan
defer wg.Done() defer wg.Done()
defer hc.ContextCancelFunc() defer hc.ContextCancelFunc()
defer log.Info("finished") defer log.Debugf("finished")
for { for {
// Read a message from hasura // Read a message from hasura
@ -50,7 +50,7 @@ func HasuraConnectionReader(hc *common.HasuraConnection, fromHasuraToBrowserChan
hc.Browserconn.ActiveSubscriptionsMutex.Lock() hc.Browserconn.ActiveSubscriptionsMutex.Lock()
delete(hc.Browserconn.ActiveSubscriptions, queryId) delete(hc.Browserconn.ActiveSubscriptions, queryId)
hc.Browserconn.ActiveSubscriptionsMutex.Unlock() hc.Browserconn.ActiveSubscriptionsMutex.Unlock()
log.Infof("Subscription with Id %s finished by Hasura.", queryId) log.Debugf("Subscription with Id %s finished by Hasura.", queryId)
} }
//Apply msg patch when it supports it //Apply msg patch when it supports it

View File

@ -21,7 +21,7 @@ func HasuraConnectionWriter(hc *common.HasuraConnection, fromBrowserChannel chan
defer wg.Done() defer wg.Done()
defer hc.ContextCancelFunc() defer hc.ContextCancelFunc()
defer log.Infof("finished") defer log.Debugf("finished")
RangeLoop: RangeLoop:
for { for {

View File

@ -47,7 +47,7 @@ func RemoveConnCacheDir(connectionId string) {
return return
} }
log.Infof("Directory of patch caches removed successfully for client %s.", connectionId) log.Debugf("Directory of patch caches removed successfully for client %s.", connectionId)
} }
func RemoveConnSubscriptionCacheFile(bConn *common.BrowserConnection, subscriptionId string) { func RemoveConnSubscriptionCacheFile(bConn *common.BrowserConnection, subscriptionId string) {
@ -61,7 +61,7 @@ func RemoveConnSubscriptionCacheFile(bConn *common.BrowserConnection, subscripti
return return
} }
log.Infof("Directory of patch caches removed successfully for client %s, subscription %s.", bConn.Id, subscriptionId) log.Debugf("Directory of patch caches removed successfully for client %s, subscription %s.", bConn.Id, subscriptionId)
} }
} }

View File

@ -63,10 +63,12 @@ func ConnectionHandler(w http.ResponseWriter, r *http.Request) {
BrowserConnectionsMutex.Lock() BrowserConnectionsMutex.Lock()
delete(BrowserConnections, browserConnectionId) delete(BrowserConnections, browserConnectionId)
BrowserConnectionsMutex.Unlock() BrowserConnectionsMutex.Unlock()
log.Infof("connection removed")
}() }()
// Log it // Log it
log.Printf("connection accepted") log.Infof("connection accepted")
// Create channels // Create channels
fromBrowserChannel1 := make(chan interface{}, bufferSize) fromBrowserChannel1 := make(chan interface{}, bufferSize)
@ -75,7 +77,7 @@ func ConnectionHandler(w http.ResponseWriter, r *http.Request) {
// Ensure a hasura client is running while the browser is connected // Ensure a hasura client is running while the browser is connected
go func() { go func() {
log.Printf("starting hasura client") log.Debugf("starting hasura client")
BrowserConnectedLoop: BrowserConnectedLoop:
for { for {
@ -84,7 +86,7 @@ func ConnectionHandler(w http.ResponseWriter, r *http.Request) {
break BrowserConnectedLoop break BrowserConnectedLoop
default: default:
{ {
log.Printf("creating hasura client") log.Debugf("creating hasura client")
BrowserConnectionsMutex.RLock() BrowserConnectionsMutex.RLock()
thisBrowserConnection := BrowserConnections[browserConnectionId] thisBrowserConnection := BrowserConnections[browserConnectionId]
BrowserConnectionsMutex.RUnlock() BrowserConnectionsMutex.RUnlock()

View File

@ -48,15 +48,15 @@ func BrowserConnectionInvalidator() {
messageCoreAsMap := messageAsMap["core"].(map[string]interface{}) messageCoreAsMap := messageAsMap["core"].(map[string]interface{})
messageBodyAsMap := messageCoreAsMap["body"].(map[string]interface{}) messageBodyAsMap := messageCoreAsMap["body"].(map[string]interface{})
sessionTokenToInvalidate := messageBodyAsMap["sessionToken"] sessionTokenToInvalidate := messageBodyAsMap["sessionToken"]
log.Infof("Received invalidate request for sessionToken %v", sessionTokenToInvalidate) log.Debugf("Received invalidate request for sessionToken %v", sessionTokenToInvalidate)
websrv.BrowserConnectionsMutex.RLock() websrv.BrowserConnectionsMutex.RLock()
for _, browserConnection := range websrv.BrowserConnections { for _, browserConnection := range websrv.BrowserConnections {
if browserConnection.SessionToken == sessionTokenToInvalidate { if browserConnection.SessionToken == sessionTokenToInvalidate {
if browserConnection.HasuraConnection != nil { if browserConnection.HasuraConnection != nil {
log.Infof("Processing invalidate request for sessionToken %v (hasura connection %v)", sessionTokenToInvalidate, browserConnection.HasuraConnection.Id) log.Debugf("Processing invalidate request for sessionToken %v (hasura connection %v)", sessionTokenToInvalidate, browserConnection.HasuraConnection.Id)
browserConnection.HasuraConnection.ContextCancelFunc() browserConnection.HasuraConnection.ContextCancelFunc()
log.Infof("Processed invalidate request for sessionToken %v (hasura connection %v)", sessionTokenToInvalidate, browserConnection.HasuraConnection.Id) log.Debugf("Processed invalidate request for sessionToken %v (hasura connection %v)", sessionTokenToInvalidate, browserConnection.HasuraConnection.Id)
} }
} }
} }

View File

@ -26,7 +26,7 @@ func BrowserConnectionReader(browserConnectionId string, ctx context.Context, c
time.Sleep(100 * time.Millisecond) time.Sleep(100 * time.Millisecond)
}() }()
defer log.Infof("finished") defer log.Debugf("finished")
for { for {
ctx, cancel := context.WithCancel(ctx) ctx, cancel := context.WithCancel(ctx)

View File

@ -10,7 +10,7 @@ func SessionTokenReader(connectionId string, browserConnectionContext context.Co
log := log.WithField("_routine", "SessionTokenReader") log := log.WithField("_routine", "SessionTokenReader")
defer wg.Done() defer wg.Done()
defer log.Info("finished") defer log.Debugf("finished")
BrowserConnectionsMutex.RLock() BrowserConnectionsMutex.RLock()
browserConnection := BrowserConnections[connectionId] browserConnection := BrowserConnections[connectionId]

View File

@ -13,7 +13,7 @@ func BrowserConnectionWriter(browserConnectionId string, ctx context.Context, c
log := log.WithField("_routine", "websocketConnectionWriter").WithField("browserConnectionId", browserConnectionId) log := log.WithField("_routine", "websocketConnectionWriter").WithField("browserConnectionId", browserConnectionId)
defer wg.Done() defer wg.Done()
defer log.Printf("finished") defer log.Debugf("finished")
RangeLoop: RangeLoop:
for { for {

View File

@ -1,6 +1,7 @@
HASURA_GRAPHQL_DATABASE_URL=postgres://postgres:bbb_graphql@localhost:5432/hasura_app HASURA_GRAPHQL_DATABASE_URL=postgres://postgres:bbb_graphql@localhost:5432/hasura_app
#HASURA_GRAPHQL_METADATA_DATABASE_URL=postgres://postgres:bbb_graphql@localhost:5432/hasura_app #HASURA_GRAPHQL_METADATA_DATABASE_URL=postgres://postgres:bbb_graphql@localhost:5432/hasura_app
#HASURA_GRAPHQL_NO_OF_RETRIES #HASURA_GRAPHQL_NO_OF_RETRIES
HASURA_GRAPHQL_LOG_LEVEL=warn
HASURA_GRAPHQL_ENABLE_CONSOLE=false HASURA_GRAPHQL_ENABLE_CONSOLE=false
HASURA_GRAPHQL_LIVE_QUERIES_MULTIPLEXED_REFETCH_INTERVAL=250 HASURA_GRAPHQL_LIVE_QUERIES_MULTIPLEXED_REFETCH_INTERVAL=250
HASURA_GRAPHQL_STREAMING_QUERIES_MULTIPLEXED_REFETCH_INTERVAL=100 HASURA_GRAPHQL_STREAMING_QUERIES_MULTIPLEXED_REFETCH_INTERVAL=100