Global

Methods

(async) createProfiler()

Initializes the config, and starts heap profiler if the heap profiler is needed. Returns a profiler if creation is successful. Otherwise, returns rejected promise.

getResponseErrorMessage(response)

Parameters:
Name Type Description
response
Returns:
Type Description

the error's message, if present. Otherwise returns the message of the response body, if that field exists, or the response status message.

getServerResponseBackoff()

Returns:
Type Description

number indicated by backoff if the response indicates a backoff and that backoff is greater than 0. Otherwise returns undefined.

initConfigLocal()

Sets unset values in the configuration to the value retrieved from environment variables or specified in defaultConfig. Throws error if value that must be set cannot be initialized.

(async) initConfigMetadata()

Sets unset values in the configuration which can be retrieved from GCP metadata.

isBackoffResponseError()

Returns:
Type Description

true if error is a BackoffResponseError and false otherwise

isDeployment()

Returns:
Type Description

true if an deployment is a Deployment and false otherwise.

isErrorResponseStatusCode()

Returns:
Type Description

true iff http status code indicates an error.

isRequestProfile()

Returns:
Type Description

true if an prof is a RequestProfile and false otherwise.

nodeVersionOkay()

Returns true if the version passed in satifised version requirements specified in the profiler's package.json.

Exported for testing.

parseBackoffDuration()

Returns:
Type Description

if the backoff duration can be parsed, then the backoff duration in ms, otherwise undefined.

Public for testing.

(async) profileBytes(p)

Converts a profile to a compressed, base64 encoded string.

Work for converting profile is done on the event loop. In particular, profile encoding is done on the event loop. So, this does block execution of the program, but for a short period of time, since profiles are small.

Parameters:
Name Type Description
p

profile to be converted to string.

responseToProfileOrError(response)

Parameters:
Name Type Description
response
Returns:
Type Description

profile iff response indicates success and the returned profile was valid.

Throws:

error when the response indicated failure or the returned profile was not valid.

(async) start()

Starts the profiling agent and returns a promise. If any error is encountered when configuring the profiler the promise will be rejected. Resolves when profiling is started.

config - Config describing configuration for profiling.

Examples
profiler.start();
profiler.start(config);

(async) startLocal()

For debugging purposes. Collects profiles and discards the collected profiles.