diff --git a/CHANGES_NEXT_RELEASE b/CHANGES_NEXT_RELEASE index 9dcd083..23788e0 100644 --- a/CHANGES_NEXT_RELEASE +++ b/CHANGES_NEXT_RELEASE @@ -1,3 +1,4 @@ +- Add: conf and env var (DISABLE_DOMAIN_MIDDLEWARE) to disable domain middleware to reduce overhead (but loosing some info in logs) (#498) - Upgrade mustache dep from 2.2.1 to 2.3.2 - Upgrade node-cache dep from 1.0.3 to 5.1.2 - Add: new API to retrieve and reset cache stats (GET, DELETE /admin/cacheStats) diff --git a/README.md b/README.md index 11f8504..8804446 100644 --- a/README.md +++ b/README.md @@ -483,6 +483,7 @@ Right Attempt | ResponseStatus=200 | Token=860864fb6d1a4c8a8cb7d59d16daaa52 | Or * `config.bypassRoleId`: ID of the role that will be considered to have administrative rights over the proxy (so being transparently proxied without validation). Valid values are Role UUIDs. E.g.: `db50362d5f264c8292bebdb5c5783741`. * `config.dieOnRedirectError`: this flags changes the behavior of the PEP Proxy when an error is received when redirecting a request. If the flag is true, the PEP Proxy process is shut down immediately; if it is false, the behavior is the usual: generate a 501 Code error. * `config.bodyLimit`: Controls the maximum request body size allowed, in bytes. Default is 1 Mb +* `config.disableDomainMiddleware`:Disable domain middleware used for logging. Disabled will reduce overhead, but loses info (transaction, correlator, service, subservice, etc) in logs. Default is false. ### Authentication configuration * `config.authentication.checkHeaders`: when the proxy is working with the access control disabled (just user authentication), indicates whether the `fiware-service` and `fiware-servicepath` headers should be checked for existance and validity (checking: the headers exist, thy are not empty and the user is really part of the service and subservice mentioned in the header). This option is ignored when authorization is enabled, and considered to be `true` (as the headers constitute a mandatory part of the authorization process). Default value is `true`. @@ -538,8 +539,9 @@ Some of the configuration values for the attributes above mentioned can be overr | PROXY_PASSWORD | config.authentication.password | | PROXY_PASSWORD | config.authentication.password | | COMPONENT_NAME | config.componentName | -| COMPONENT_PLUGIN | config.middlewares and config.componentName if no COMPONENT_NAME provided | -| BODY_LIMIT | config.bodyLimit | +| COMPONENT_PLUGIN | config.middlewares and config.componentName if no COMPONENT_NAME provided | +| BODY_LIMIT | config.bodyLimit | +| DISABLE_DOMAIN_MIDDLEWARE | config.disableDomainMiddleware | ### Component configuration A special environment variable, called `COMPONENT_PLUGIN` can be set with one of this values: `orion`, `perseo`, `keypass` and `rest`. This variable can be used to select what component plugin to load in order to determine the action of the incoming requests. This variable also rewrites `config.componentName` configuration paramenter. diff --git a/bin/pepProxy b/bin/pepProxy index 7659b41..7cf38fa 100755 --- a/bin/pepProxy +++ b/bin/pepProxy @@ -60,7 +60,8 @@ function loadConfiguration() { 'PROXY_PASSWORD', 'COMPONENT_PLUGIN', 'COMPONENT_NAME', - 'BODY_LIMIT' + 'BODY_LIMIT', + 'DISABLE_DOMAIN_MIDDLEWARE' ]; for (var i = 0; i < environmentValues.length; i++) { @@ -147,6 +148,9 @@ function loadConfiguration() { if (process.env.BODY_LIMIT) { config.bodyLimit = process.env.BODY_LIMIT; } + if (process.env.DISABLE_DOMAIN_MIDDLEWARE) { + config.disableDomainMiddleware = process.env.DISABLE_DOMAIN_MIDDLEWARE == 'true'; + } } loadConfiguration(); diff --git a/config.js b/config.js index c993e73..9cb7f4a 100644 --- a/config.js +++ b/config.js @@ -181,6 +181,10 @@ config.maxQueuedClients = 1000; */ config.bodyLimit = 1048576; - +/** + * Disable domain middleware used for logging. Disabled will reduce overhead, but loses info (transaction, correlator, service, + * subservice, etc) in logs. Default is false. + */ +config.disableDomainMiddleware = false; module.exports = config; diff --git a/lib/fiware-pep-steelskin.js b/lib/fiware-pep-steelskin.js index f6e5049..165ca1e 100644 --- a/lib/fiware-pep-steelskin.js +++ b/lib/fiware-pep-steelskin.js @@ -230,7 +230,9 @@ function initializeProxy(proxyObj, callback) { proxyObj.proxy.use(xmlRawBody); proxyObj.proxy.use(rawBody); proxyObj.proxy.use(bodyParser.urlencoded({limit: config.bodyLimit ? config.bodyLimit : '1Mb', extended: true})); - proxyObj.proxy.use(domainMiddleware); + if (!config.disableDomainMiddleware) { + proxyObj.proxy.use(domainMiddleware); + } if (config.logLevel && config.logLevel.toUpperCase() === 'DEBUG') { proxyObj.proxy.use(traceRequest); @@ -314,7 +316,9 @@ function initializeAdmin(proxyObj, callback) { proxyObj.administration.use(bodyParser.json({limit: config.bodyLimit ? config.bodyLimit : '1Mb'})); proxyObj.administration.use(bodyParser.urlencoded({limit: config.bodyLimit ? config.bodyLimit : '1Mb', extended: true})); - proxyObj.administration.use(domainMiddleware); + if (!config.disableDomainMiddleware) { + proxyObj.administration.use(domainMiddleware); + } proxyObj.administration.use(handleError); adminMiddleware.loadContextRoutes(proxyObj.administration); diff --git a/lib/services/cacheUtils.js b/lib/services/cacheUtils.js index ba7ca6c..be8dbde 100644 --- a/lib/services/cacheUtils.js +++ b/lib/services/cacheUtils.js @@ -102,8 +102,9 @@ function createDomainEnabledCacheHandler(domain, processValueFn, cache, cacheTyp callback(error); } else { var currentValue = cache.data[cacheType].get(cacheKey) || value; - - domain.enter(); + if (!config.disableDomainMiddleware) { + domain.enter(); + } logger.debug('Value found for cache type [%s] key [%s]: %j', cacheType, cacheKey, value); logger.debug('Processing with value: %s', JSON.stringify(cache.data[cacheType].get(cacheKey))); diff --git a/lib/services/keystoneAuth.js b/lib/services/keystoneAuth.js index 18140de..45935c9 100644 --- a/lib/services/keystoneAuth.js +++ b/lib/services/keystoneAuth.js @@ -429,7 +429,9 @@ function extractRoles(req, res, next) { function domainContinuator(domain, callback) { return function() { - domain.enter(); + if (!config.disableDomainMiddleware) { + domain.enter(); + } callback(); }; }