lib/configuration.js
function(givenConfig, logger) {
  /**
   * The _logger property caches the logger instance created at the top-level
   * for configuration logging purposes.
   * @memberof Configuration
   * @private
   * @type {Object}
   * @defaultvalue Object
   */
  this._logger = logger;
  /**
   * The _reportUncaughtExceptions property is meant to contain the optional
   * runtime configuration property reportUncaughtExceptions. This property will
   * default to true if not given false through the runtime configuration
   * meaning that the default behavior is to catch uncaught exceptions, report
   * them to the Stackdriver Errors API and then exit. If given false uncaught
   * exceptions will not be listened for and not be caught or reported.
   * @memberof Configuration
   * @private
   * @type {Boolean}
   * @defaultvalue true
   */
  this._reportUncaughtExceptions = true;
  /**
   * The _shouldReportErrorsToAPI property is meant to denote whether or not
   * the Stackdriver error reporting library will actually try to report Errors
   * to the Stackdriver Error API. The value of this property is derived from
   * the `NODE_ENV` environmental variable or the value of the ignoreEnvironmentCheck
   * property if present in the runtime configuration. If either the `NODE_ENV` 
   * variable is set to 'production' or the ignoreEnvironmentCheck propery on 
   * the runtime configuration is set to true then the error reporting library will 
   * attempt to send errors to the Error API. Otherwise the value will remain 
   * false and errors will not be reported to the API.
   * @memberof Configuration
   * @private
   * @type {Boolean}
   * @defaultvalue false
   */
  this._shouldReportErrorsToAPI = false;
  /**
   * The _projectId property is meant to contain the string project id that the
   * hosting application is running under. The project id is a unique string
   * identifier for the project. If the Configuration instance is not able to
   * retrieve a project id from the metadata service or the runtime-given
   * configuration then the property will remain null. If given both a project
   * id through the metadata service and the runtime configuration then the
   * instance will assign the value given by the metadata service over the
   * runtime configuration. If the instance is unable to retrieve a valid
   * project id or number from runtime configuration and the metadata service
   * then this will trigger the `error` event in which listening components must
   * operate in 'offline' mode.
   * {@link https://cloud.google.com/compute/docs/storing-retrieving-metadata}
   * @memberof Configuration
   * @private
   * @type {String|Null}
   * @defaultvalue null
   */
  this._projectId = null;
  /**
   * The _key property is meant to contain the optional Stackdriver API key that
   * may be used in place of default application credentials to authenticate
   * with the Stackdriver Error API. This property will remain null if a key
   * is not given in the runtime configuration or an invalid type is given as
   * the runtime configuration.
   * {@link https://support.google.com/cloud/answer/6158862?hl=en}
   * @memberof Configuration
   * @private
   * @type {String|Null}
   * @defaultvalue null
   */
  this._key = null;
  /**
   * The _keyFilename property is meant to contain a path to a file containing
   * user or service account credentials, which will be used in place of
   * application default credentials. This property will remain null if no
   * value for keyFilename is given in the runtime configuration.
   * @memberof Configuration
   * @private
   * @type {String|Null}
   * @defaultvalue null
   */
  this._keyFilename = null;
  /**
   * The _credentials property is meant to contain an object representation of
   * user or service account credentials, which will be used in place of
   * application default credentials. This property will remain null if no
   * value for credentials is given in the runtime configuration.
   * @memberof Configuration
   * @private
   * @type {Credentials|Null}
   * @defaultvalue null
   */
  this._credentials = null;
  /**
   * The _serviceContext property is meant to contain the optional service
   * context information which may be given in the runtime configuration. If
   * not given in the runtime configuration then the property value will remain
   * null.
   * @memberof Configuration
   * @private
   * @type {Object}
   */
  this._serviceContext = {service: 'nodejs', version: ''};
  /**
   * The _version of the Error reporting library that is currently being run.
   * This information will be logged in errors communicated to the Stackdriver
   * Error API.
   * @memberof Configuration
   * @private
   * @type {String}
   */
  this._version = version;
  /**
   * The _givenConfiguration property holds a ConfigurationOptions object
   * which, if valid, will be merged against by the values taken from the meta-
   * data service. If the _givenConfiguration property is not valid then only
   * metadata values will be used in the Configuration instance.
   * @memberof Configuration
   * @private
   * @type {Object|Null}
   * @defaultvalue null
   */
  this._givenConfiguration = isPlainObject(givenConfig) ? givenConfig : {};
  this._checkLocalServiceContext();
  this._gatherLocalConfiguration();
}
function(givenConfig, logger) {
  /**
   * The _logger property caches the logger instance created at the top-level
   * for configuration logging purposes.
   * @memberof Configuration
   * @private
   * @type {Object}
   * @defaultvalue Object
   */
  this._logger = logger;
  /**
   * The _reportUncaughtExceptions property is meant to contain the optional
   * runtime configuration property reportUncaughtExceptions. This property will
   * default to true if not given false through the runtime configuration
   * meaning that the default behavior is to catch uncaught exceptions, report
   * them to the Stackdriver Errors API and then exit. If given false uncaught
   * exceptions will not be listened for and not be caught or reported.
   * @memberof Configuration
   * @private
   * @type {Boolean}
   * @defaultvalue true
   */
  this._reportUncaughtExceptions = true;
  /**
   * The _shouldReportErrorsToAPI property is meant to denote whether or not
   * the Stackdriver error reporting library will actually try to report Errors
   * to the Stackdriver Error API. The value of this property is derived from
   * the `NODE_ENV` environmental variable or the value of the ignoreEnvironmentCheck
   * property if present in the runtime configuration. If either the `NODE_ENV` 
   * variable is set to 'production' or the ignoreEnvironmentCheck propery on 
   * the runtime configuration is set to true then the error reporting library will 
   * attempt to send errors to the Error API. Otherwise the value will remain 
   * false and errors will not be reported to the API.
   * @memberof Configuration
   * @private
   * @type {Boolean}
   * @defaultvalue false
   */
  this._shouldReportErrorsToAPI = false;
  /**
   * The _projectId property is meant to contain the string project id that the
   * hosting application is running under. The project id is a unique string
   * identifier for the project. If the Configuration instance is not able to
   * retrieve a project id from the metadata service or the runtime-given
   * configuration then the property will remain null. If given both a project
   * id through the metadata service and the runtime configuration then the
   * instance will assign the value given by the metadata service over the
   * runtime configuration. If the instance is unable to retrieve a valid
   * project id or number from runtime configuration and the metadata service
   * then this will trigger the `error` event in which listening components must
   * operate in 'offline' mode.
   * {@link https://cloud.google.com/compute/docs/storing-retrieving-metadata}
   * @memberof Configuration
   * @private
   * @type {String|Null}
   * @defaultvalue null
   */
  this._projectId = null;
  /**
   * The _key property is meant to contain the optional Stackdriver API key that
   * may be used in place of default application credentials to authenticate
   * with the Stackdriver Error API. This property will remain null if a key
   * is not given in the runtime configuration or an invalid type is given as
   * the runtime configuration.
   * {@link https://support.google.com/cloud/answer/6158862?hl=en}
   * @memberof Configuration
   * @private
   * @type {String|Null}
   * @defaultvalue null
   */
  this._key = null;
  /**
   * The _keyFilename property is meant to contain a path to a file containing
   * user or service account credentials, which will be used in place of
   * application default credentials. This property will remain null if no
   * value for keyFilename is given in the runtime configuration.
   * @memberof Configuration
   * @private
   * @type {String|Null}
   * @defaultvalue null
   */
  this._keyFilename = null;
  /**
   * The _credentials property is meant to contain an object representation of
   * user or service account credentials, which will be used in place of
   * application default credentials. This property will remain null if no
   * value for credentials is given in the runtime configuration.
   * @memberof Configuration
   * @private
   * @type {Credentials|Null}
   * @defaultvalue null
   */
  this._credentials = null;
  /**
   * The _serviceContext property is meant to contain the optional service
   * context information which may be given in the runtime configuration. If
   * not given in the runtime configuration then the property value will remain
   * null.
   * @memberof Configuration
   * @private
   * @type {Object}
   */
  this._serviceContext = {service: 'nodejs', version: ''};
  /**
   * The _version of the Error reporting library that is currently being run.
   * This information will be logged in errors communicated to the Stackdriver
   * Error API.
   * @memberof Configuration
   * @private
   * @type {String}
   */
  this._version = version;
  /**
   * The _givenConfiguration property holds a ConfigurationOptions object
   * which, if valid, will be merged against by the values taken from the meta-
   * data service. If the _givenConfiguration property is not valid then only
   * metadata values will be used in the Configuration instance.
   * @memberof Configuration
   * @private
   * @type {Object|Null}
   * @defaultvalue null
   */
  this._givenConfiguration = isPlainObject(givenConfig) ? givenConfig : {};
  this._checkLocalServiceContext();
  this._gatherLocalConfiguration();
}
function ( givenConfig , logger ) { /**
   * The _logger property caches the logger instance created at the top-level
   * for configuration logging purposes.
   * @memberof Configuration
   * @private
   * @type {Object}
   * @defaultvalue Object
   */ this . _logger = logger ; /**
   * The _reportUncaughtExceptions property is meant to contain the optional
   * runtime configuration property reportUncaughtExceptions. This property will
   * default to true if not given false through the runtime configuration
   * meaning that the default behavior is to catch uncaught exceptions, report
   * them to the Stackdriver Errors API and then exit. If given false uncaught
   * exceptions will not be listened for and not be caught or reported.
   * @memberof Configuration
   * @private
   * @type {Boolean}
   * @defaultvalue true
   */ this . _reportUncaughtExceptions = true ; /**
   * The _shouldReportErrorsToAPI property is meant to denote whether or not
   * the Stackdriver error reporting library will actually try to report Errors
   * to the Stackdriver Error API. The value of this property is derived from
   * the `NODE_ENV` environmental variable or the value of the ignoreEnvironmentCheck
   * property if present in the runtime configuration. If either the `NODE_ENV` 
   * variable is set to 'production' or the ignoreEnvironmentCheck propery on 
   * the runtime configuration is set to true then the error reporting library will 
   * attempt to send errors to the Error API. Otherwise the value will remain 
   * false and errors will not be reported to the API.
   * @memberof Configuration
   * @private
   * @type {Boolean}
   * @defaultvalue false
   */ this . _shouldReportErrorsToAPI = false ; /**
   * The _projectId property is meant to contain the string project id that the
   * hosting application is running under. The project id is a unique string
   * identifier for the project. If the Configuration instance is not able to
   * retrieve a project id from the metadata service or the runtime-given
   * configuration then the property will remain null. If given both a project
   * id through the metadata service and the runtime configuration then the
   * instance will assign the value given by the metadata service over the
   * runtime configuration. If the instance is unable to retrieve a valid
   * project id or number from runtime configuration and the metadata service
   * then this will trigger the `error` event in which listening components must
   * operate in 'offline' mode.
   * {@link https://cloud.google.com/compute/docs/storing-retrieving-metadata}
   * @memberof Configuration
   * @private
   * @type {String|Null}
   * @defaultvalue null
   */ this . _projectId = null ; /**
   * The _key property is meant to contain the optional Stackdriver API key that
   * may be used in place of default application credentials to authenticate
   * with the Stackdriver Error API. This property will remain null if a key
   * is not given in the runtime configuration or an invalid type is given as
   * the runtime configuration.
   * {@link https://support.google.com/cloud/answer/6158862?hl=en}
   * @memberof Configuration
   * @private
   * @type {String|Null}
   * @defaultvalue null
   */ this . _key = null ; /**
   * The _keyFilename property is meant to contain a path to a file containing
   * user or service account credentials, which will be used in place of
   * application default credentials. This property will remain null if no
   * value for keyFilename is given in the runtime configuration.
   * @memberof Configuration
   * @private
   * @type {String|Null}
   * @defaultvalue null
   */ this . _keyFilename = null ; /**
   * The _credentials property is meant to contain an object representation of
   * user or service account credentials, which will be used in place of
   * application default credentials. This property will remain null if no
   * value for credentials is given in the runtime configuration.
   * @memberof Configuration
   * @private
   * @type {Credentials|Null}
   * @defaultvalue null
   */ this . _credentials = null ; /**
   * The _serviceContext property is meant to contain the optional service
   * context information which may be given in the runtime configuration. If
   * not given in the runtime configuration then the property value will remain
   * null.
   * @memberof Configuration
   * @private
   * @type {Object}
   */ this . _serviceContext = { service : 'nodejs' , version : '' } ; /**
   * The _version of the Error reporting library that is currently being run.
   * This information will be logged in errors communicated to the Stackdriver
   * Error API.
   * @memberof Configuration
   * @private
   * @type {String}
   */ this . _version = version ; /**
   * The _givenConfiguration property holds a ConfigurationOptions object
   * which, if valid, will be merged against by the values taken from the meta-
   * data service. If the _givenConfiguration property is not valid then only
   * metadata values will be used in the Configuration instance.
   * @memberof Configuration
   * @private
   * @type {Object|Null}
   * @defaultvalue null
   */ this . _givenConfiguration = isPlainObject ( givenConfig ) ? givenConfig : { } ; this . _checkLocalServiceContext ( ) ; this . _gatherLocalConfiguration ( ) ; }
The Configuration constructor function initializes several internal
properties on the Configuration instance and accepts a runtime-given
configuration object which may be used by the Configuration instance
depending on the initialization transaction that occurs with the meta-data
service.
@class Configuration
@classdesc The Configuration class represents the runtime configuration of
the Stackdriver error handling library. This Configuration class accepts the
configuration options potentially given through the application interface
but it also preferences values received from the metadata service over
values given through the application interface. Becuase the Configuration
class must handle async network I/O it exposes some methods as async
functions which may cache their interactions results to speed access to
properties.
@param {ConfigurationOptions} givenConfig - The config given by the
hosting application at runtime. Configuration values will only be observed
if they are given as a plain JS object; all other values will be ignored.
@param {Object} logger - The logger instance created when the library API has
been initialized.
The Configuration constructor function initializes several internal properties on the Configuration instance and accepts a runtime - given configuration object which may be used by the Configuration instance depending on the initialization transaction that occurs with the meta - data service .