mirror of
https://github.com/lukaszraczylo/graphql-monitoring-proxy.git
synced 2026-06-05 23:03:48 +00:00
Add ability to enable / disable access log.
In high frequency environments it can be a little bit noisy.
This commit is contained in:
@@ -37,6 +37,7 @@ I wanted to monitor the queries and responses of our graphql endpoint, but we di
|
|||||||
* `CACHE_TTL` - the cache TTL (default: `60s`)
|
* `CACHE_TTL` - the cache TTL (default: `60s`)
|
||||||
* `LOG_LEVEL` - the log level (default: `info`)
|
* `LOG_LEVEL` - the log level (default: `info`)
|
||||||
* `BLOCK_SCHEMA_INTROSPECTION` - blocks the schema introspection (default: `false`)
|
* `BLOCK_SCHEMA_INTROSPECTION` - blocks the schema introspection (default: `false`)
|
||||||
|
* `ENABLE_ACCESS_LOG` - enable the access log (default: `false`)
|
||||||
|
|
||||||
### Caching
|
### Caching
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ func parseConfig() {
|
|||||||
c.Logger = libpack_logging.NewLogger()
|
c.Logger = libpack_logging.NewLogger()
|
||||||
c.Client.GQLClient = graphql.NewConnection()
|
c.Client.GQLClient = graphql.NewConnection()
|
||||||
c.Client.GQLClient.SetEndpoint(c.Server.HostGraphQL)
|
c.Client.GQLClient.SetEndpoint(c.Server.HostGraphQL)
|
||||||
|
c.Server.AccessLog = envutil.GetBool("ENABLE_ACCESS_LOG", false)
|
||||||
cfg = &c
|
cfg = &c
|
||||||
enableCache() // takes close to no resources, but can be used with dynamic query cache
|
enableCache() // takes close to no resources, but can be used with dynamic query cache
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,7 +77,9 @@ func processGraphQLRequest(c *fiber.Ctx) error {
|
|||||||
}
|
}
|
||||||
time_taken := time.Since(t)
|
time_taken := time.Since(t)
|
||||||
|
|
||||||
cfg.Logger.Info("Request processed", map[string]interface{}{"ip": c.IP(), "user_id": extracted_user_id, "op_type": opType, "op_name": opName, "time": time_taken, "cache": was_cached})
|
if cfg.Server.AccessLog {
|
||||||
|
cfg.Logger.Info("Request processed", map[string]interface{}{"ip": c.IP(), "user_id": extracted_user_id, "op_type": opType, "op_name": opName, "time": time_taken, "cache": was_cached})
|
||||||
|
}
|
||||||
cfg.Monitoring.Increment(libpack_monitoring.MetricsSucceeded, nil)
|
cfg.Monitoring.Increment(libpack_monitoring.MetricsSucceeded, nil)
|
||||||
|
|
||||||
labels := map[string]string{
|
labels := map[string]string{
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ type config struct {
|
|||||||
PortGraphQL int
|
PortGraphQL int
|
||||||
PortMonitoring int
|
PortMonitoring int
|
||||||
HostGraphQL string
|
HostGraphQL string
|
||||||
|
AccessLog bool
|
||||||
}
|
}
|
||||||
|
|
||||||
Client struct {
|
Client struct {
|
||||||
|
|||||||
Reference in New Issue
Block a user