Giter VIP home page Giter VIP logo

cloud-profiler-nodejs's Introduction

Google Cloud Platform logo

release level npm version

Adds support for Cloud Profiler to Node.js applications

A comprehensive list of changes in each version may be found in the CHANGELOG.

Read more about the client libraries for Cloud APIs, including the older Google APIs Client Libraries, in Client Libraries Explained.

Table of contents:

Quickstart

Before you begin

  1. Select or create a Cloud Platform project.
  2. Enable the Cloud Profiler API.
  3. Set up authentication with a service account so you can access the API from your local workstation.

Installing the client library

npm install @google-cloud/profiler

Prerequisites

  1. Your application will need to be using Node.js version between 14 and 20.

  2. @google-cloud/profiler depends on the pprof module, a module with a native component that is used to collect profiles with v8's CPU and Heap profilers. You may need to install additional dependencies to build the pprof module.

    • For Linux: pprof has prebuilt binaries available for Linux and Alpine Linux for Node 14 and 16. No additional dependencies are required.
    • For other environments: when using @google-cloud/profiler on environments that pprof does not have prebuilt binaries for, the module node-gyp will be used to build binaries. See node-gyp's documentation for information on dependencies required to build binaries with node-gyp.
  3. You will need a project in the [Google Developers Console][cloud-console]. Your application can run anywhere, but the profiler data is associated with a particular project.

  4. You will need to enable the Cloud Profiler API for your project.

Basic Set-up

  1. Install @google-cloud/profiler with npm or add to your package.json.

    # Install through npm while saving to the local 'package.json'
    npm install --save @google-cloud/profiler
  2. Include and start the profiler at the beginning of your application:

    require('@google-cloud/profiler').start().catch((err) => {
    console.log(`Failed to start profiler: ${err}`);
    });

    Some environments require a configuration to be passed to the start() function. For more details on this, see instructions for running outside of Google Cloud Platform, on App Engine flexible environment, on Google Compute Engine, and on Google Container Engine.

  3. If you are running your application locally, or on a machine where you are using the [Google Cloud SDK][gcloud-sdk], make sure to log in with the application default credentials:

    gcloud beta auth application-default login

    Alternatively, you can set GOOGLE_APPLICATION_CREDENTIALS. For more details on this, see Running elsewhere

Configuration

See the default configuration for a list of possible configuration options. These options can be passed to the agent through the object argument to the start command shown below:

await require('@google-cloud/profiler').start({disableTime: true});

Alternatively, you can provide the configuration through a config file. This can be useful if you want to load our module using --require on the command line (which requires and starts the agent) instead of editing your main script. The GCLOUD_PROFILER_CONFIG environment variable should point to your configuration file.

export GCLOUD_PROFILER_CONFIG=./path/to/your/profiler/configuration.js

Changing log level

The profiler writes log statements to the console log for diagnostic purposes. By default, the log level is set to warn. You can adjust this by setting logLevel in the config. Setting logLevel to 0 will disable logging, 1 sets log level to error, 2 sets it to warn (default), 3 sets it to info, and 4 sets it to debug.

So, for example, to start the profiler with the log level at debug, you would do this:

await require('@google-cloud/profiler').start({logLevel: 4});

Disabling heap or time profile collection

By default, the profiler collects both heap profiles, which show memory allocations, and time profiles, which capture how much wall-clock time is spent in different locations of the code. Using the configuration, it is possible to disable the collection of either type of profile.

To disable time profile collection, set disableTime to true:

await require('@google-cloud/profiler').start({disableTime: true});

To disable heap profile collection, set disableHeap to true:

await require('@google-cloud/profiler').start({disableHeap: true});

Running on Google Cloud Platform

There are three different services that can host Node.js applications within Google Cloud Platform: Google App Engine flexible environment, Google Compute Engine, and Google Container Engine. After installing @google-cloud/profiler in your project and ensuring that the environment you are using uses a supported version of Node.js, follow the service-specific instructions to enable the profiler.

Running on App Engine flexible environment

To enable the profiling agent for a Node.js program running in the App Engine flexible environment, import the agent at the top of your application’s main script or entry point by including the following code snippet:

require('@google-cloud/profiler').start();

You can specify which version of Node.js you're using by adding a snippet like the following to your package.json:

"engines": {
    "node": ">=14.0.0"
}

The above snippet will ensure that you're using 14.0.0 or greater.

Deploy your application to App Engine Flexible environment as usual.

Running on Google Compute Engine

To enable the profiling agent for a Node.js program running in the Google Compute Engine environment, import the agent at the top of your application’s main script or entry point by including the following code snippet:

require('@google-cloud/profiler').start({
serviceContext: {
    service: 'your-service',
    version: '1.0.0'
}
});

Running on Google Container Engine

To enable the profiling agent for a Node.js program running in the Google Container Engine environment, import the agent at the top of your application’s main script or entry point by including the following code snippet:

require('@google-cloud/profiler').start({
serviceContext: {
    service: 'your-service',
    version: '1.0.0'
}
});

Running on Istio

On Istio, the GCP Metadata server may not be available for a few seconds after your application has started. When this occurs, the profiling agent may fail to start because it cannot initialize required fields. One can retry when starting the profiler with the following snippet.

const profiler = require('@google-cloud/profiler');
async function startProfiler() {
for (let i = 0; i < 3; i++) {
    try {
    await profiler.start({
        serviceContext: {
        service: 'your-service',
        version: '1.0.0',
        },
    });
    } catch(e) {
    console.log(`Failed to start profiler: ${e}`);
    }

    // Wait for 1 second before trying again.
    await new Promise(r => setTimeout(r, 1000));
}
}
startProfiler();

Running elsewhere

You can still use @google-cloud/profiler if your application is running outside of Google Cloud Platform, for example, running locally, on-premise, or on another cloud provider.

  1. You will need to specify your project id and the service you want the collected profiles to be associated with, and (optionally) the version of the service when starting the profiler:
    await require('@google-cloud/profiler').start({
    projectId: 'project-id',
    serviceContext: {
        service: 'your-service',
        version: '1.0.0'
    }
    });
  1. You will need to provide credential for your application.
  • If you are running your application on a development machine or test environment where you are using the [gcloud command line tools][gcloud-sdk], and are logged using gcloud beta auth application-default login, you already have sufficient credentials, and a service account key is not required.

  • You can provide credentials via [Application Default Credentials][app-default-credentials]. This is the recommended method. 1. [Create a new JSON service account key][service-account]. 2. Copy the key somewhere your application can access it. Be sure not to expose the key publicly. 3. Set the environment variable GOOGLE_APPLICATION_CREDENTIALS to the full path to the key. The profiler will automatically look for this environment variable.

  • You may set the keyFilename or credentials configuration field to the full path or contents to the key file, respectively. Setting either of these fields will override either setting GOOGLE_APPLICATION_CREDENTIALS or logging in using gcloud.

    This is how you would set keyFilename:

    await require('@google-cloud/profiler').start({
        projectId: 'project-id',
        serviceContext: {
        service: 'your-service',
        version: '1.0.0'
        },
        keyFilename: '/path/to/keyfile'
    });

    This is how you would set credentials:

    await require('@google-cloud/profiler').start({
        projectId: 'project-id',
        serviceContext: {
        service: 'your-service',
        version: '1.0.0'
        },
        credentials: {
        client_email: 'email',
        private_key: 'private_key'
        }
    });

Samples

Samples are in the samples/ directory. Each sample's README.md has instructions for running its sample.

Sample Source Code Try it
App source code Open in Cloud Shell
Snippets source code Open in Cloud Shell

The Cloud Profiler Node.js Client API Reference documentation also contains samples.

Supported Node.js Versions

Our client libraries follow the Node.js release schedule. Libraries are compatible with all current active and maintenance versions of Node.js. If you are using an end-of-life version of Node.js, we recommend that you update as soon as possible to an actively supported LTS version.

Google's client libraries support legacy versions of Node.js runtimes on a best-efforts basis with the following warnings:

  • Legacy versions are not tested in continuous integration.
  • Some security patches and features cannot be backported.
  • Dependencies cannot be kept up-to-date.

Client libraries targeting some end-of-life versions of Node.js are available, and can be installed through npm dist-tags. The dist-tags follow the naming convention legacy-(version). For example, npm install @google-cloud/profiler@legacy-8 installs client libraries for versions compatible with Node.js 8.

Versioning

This library follows Semantic Versioning.

This library is considered to be stable. The code surface will not change in backwards-incompatible ways unless absolutely necessary (e.g. because of critical security issues) or with an extensive deprecation period. Issues and requests against stable libraries are addressed with the highest priority.

More Information: Google Cloud Platform Launch Stages

Contributing

Contributions welcome! See the Contributing Guide.

Please note that this README.md, the samples/README.md, and a variety of configuration files in this repository (including .nycrc and tsconfig.json) are generated from a central template. To edit one of these files, make an edit to its templates in directory.

License

Apache Version 2.0

See LICENSE

cloud-profiler-nodejs's People

Contributors

aabmass avatar aalexand avatar alexander-fenster avatar amchiclet avatar barrytam20 avatar bcoe avatar fhinkel avatar gcf-owl-bot[bot] avatar greenkeeper[bot] avatar jinwoo avatar jkwlui avatar jonahsnider avatar jqll avatar justbeingjustin avatar justinbeckwith avatar kalyanac avatar kjin avatar macieksmuga avatar nolanmar511 avatar ofrobots avatar parthea avatar psx95 avatar release-please[bot] avatar renovate-bot avatar renovate[bot] avatar sofisl avatar summer-ji-eng avatar surferjeffatgoogle avatar yoshi-automation avatar zamnuts avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cloud-profiler-nodejs's Issues

Incorrect source file names in time profiles in Node 8

For the sample application, a time profile indicated that the function 'fill' was located within the source file below, when it should be marked as within 'buffer.js'. This is likely a problem with serialization, and since much of the serialization code is shared, heap profiles may also be impacted.

const profiler = require('@google-cloud/profiler')

let count = 0;
function additionFunction() {
    let a = 0
          for (var i = 0; i < 10000; i++) {
                a = a + 3;
                a = a * a;
                a = Math.sqrt(a);
                  }
      setImmediate(additionFunction);
}

function fillBuffer() {
    var buffer = new Buffer(500);
    for (var k = 0; k < 1e2; k++)
      buffer.fill(0);
    setImmediate(fillBuffer);
}

profiler.start({
    projectId: 'nolanmar-testappstandard',
      logLevel: 5,
        serviceContext: {
              service: 'app-std',
                  version: '0'
                        },
});

additionFunction();
fillBuffer();

Update @google-cloud/common to 0.16.0

After updating google-cloud/common to 0.16.0, I saw this error when collecting profiles on GCE:

Error: Sorry, we cannot connect to Cloud Services without a project ID. You may specify one with an environment variable named "GCLOUD_PROJECT". See https://googlecloudplatform.github.io/google-cloud-node/#/docs/guides/authentication for a detailed guide on creating an authenticated connection.

I filed a issue with googleapis/nodejs-common here.

I'll need to update googleapis/nodejs-common to 0.16.0 more carefully.

Figure out npm module name

Right now the module is called @google-cloud/profiler. Is that the name we would like to publish this as, or do we want be consistent with Trace and Debug agents and call this @google-cloud/profile-agent (profiler-agent?).

What is going to the name of the future veneer client library for the profiler api?

How is the agent named in other languages?

/cc @JustinBeckwith @jmdobry @lukesneeringer @aalexand

Sporadic ESOCKETTIMEDOUT error during profiling

I am running the following program on GCE:

require('@google-cloud/profiler').start({
    serviceContext: {
    service: 'test-service',
    version: '1.0.0',
    logLevel: 4,
  },
});

var doSomeWork = () => {
  console.log("doing some work");
  for (var i = 0; i < 1e8; i++) {
  }
};

setInterval(doSomeWork, 1000);

Once in a while I am getting an error like:

...
doing some work
doing some work
ERROR:@google-cloud/profiler: Error requesting profile type to be collected: Error: ESOCKETTIMEDOUT.
doing some work
doing some work
...

There may be some unexpected timeout happening on the profile creation.

Update gcp-metadata to latest version (0.6.1)

Integration tests failed when attempting to update this (here).

This may be because gcp-metadata has had changes to its API from 0.5.0, so code needs to be updated to use 0.6.1. Further investigation of failing tests is needed.

Do not ask CPU profiler for individual samples as timestamps are discarded anyway?

The CPU profiler start is currently called from here: https://github.com/GoogleCloudPlatform/cloud-profiler-nodejs/blob/8b418473fc57e0f77737f8461bace4e95e98296d/bindings/time-profiler.cc#L64.

And the ts code passes true to the record_samples argument from here: https://github.com/GoogleCloudPlatform/cloud-profiler-nodejs/blob/8b418473fc57e0f77737f8461bace4e95e98296d/ts/src/profilers/time-profiler.ts#L39.

The record_samples parameter is documented here: https://github.com/nodejs/node/blob/4e15679c026d2969efa276149282df388e0533b3/deps/v8/include/v8-profiler.h#L319 as

   * |record_samples| parameter controls whether individual samples should
   * be recorded in addition to the aggregated tree.

But it appears the profiler only uses aggregated information to populate the profile since the information is accessed using the top-down root which is aggregated structure: https://github.com/GoogleCloudPlatform/cloud-profiler-nodejs/blob/8b418473fc57e0f77737f8461bace4e95e98296d/bindings/time-profiler.cc#L51.

The sample count is converted to the JS land here - https://github.com/GoogleCloudPlatform/cloud-profiler-nodejs/blob/8b418473fc57e0f77737f8461bace4e95e98296d/bindings/time-profiler.cc#L53 but it doesn't seem to be used while converting the profile to profile.proto.

So it seems that we ask the profiler to store the individual samples but don't really need it.

@nolanmar511 @ofrobots WDYT?

installing with npm

Right now, when I try npm install https://github.com/GoogleCloudPlatform/cloud-profiler-nodejs.git, I get

npm ERR! code 128
npm ERR! Command failed: /usr/bin/git submodule update -q --init --recursive
npm ERR! fatal: No url found for submodule path 'third_party/googleapis/third_party/boringssl-with-bazel' in .gitmodules
npm ERR! 

npm ERR! A complete log of this run can be found in:
npm ERR!     /usr/local/google/home/nolanmar/.npm/_logs/2017-11-02T22_08_07_487Z-debug.log

Previously, when I tried to install from github, the typescript wasn't compiled to javascript.

@ofrobots -- any tips on how to make this work? I'm also open to just making an npm module, if that's easier. We'd like for there to be a way for users to install this module pretty soon so we can start testing that out a bit more.

Missing protobufjs/minimal

I got this error when starting with the profiler on App Engine Flex:

module.js:471
throw err;
^
Error: Cannot find module 'protobufjs/minimal'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object. (/home/nolanmar/src/nolanmartestappflex/nodejs_mvms_quickstart-2017-11-16-16-28/1-hello-world/node_modules/@google-cloud/profiler/proto/profile.js:4:17)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)

Sporadic heap profiler segfault with Node.js 6

Using node version 6.12.0, there are sporadic segmentation faults.

Running with gdb, the backtrace looked like this:

#0  0x0000000000c7b5a7 in v8::internal::InnerPointerToCodeCache::GetCacheEntry(unsigned char*) ()
#1  0x0000000000c7d0ef in v8::internal::StackFrame::GetCallerState(v8::internal::StackFrame::State*) const ()
#2  0x0000000000c7941d in v8::internal::StackFrameIterator::Advance() ()
#3  0x0000000000c79a28 in v8::internal::StackTraceFrameIterator::Advance() ()
#4  0x0000000000e439c4 in v8::internal::SamplingHeapProfiler::AddStack() ()
#5  0x0000000000e44996 in v8::internal::SamplingHeapProfiler::SampleObject(unsigned char*, unsigned long) ()
#6  0x0000000000cf277e in v8::internal::FreeList::Allocate(int) ()
#7  0x0000000000c5e350 in v8::internal::PagedSpace::AllocateRawUnaligned(int, v8::internal::PagedSpace::UpdateSkipList) ()
#8  0x0000000000c94d87 in v8::internal::Heap::AllocateRaw(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) ()
#9  0x0000000000ca5d20 in v8::internal::Heap::AllocateCode(int, bool) ()
#10 0x0000000000c67068 in v8::internal::Factory::NewCode(v8::internal::CodeDesc const&, unsigned int, v8::internal::Handle<v8::internal::Object>, bool, bool, int, bool) ()
#11 0x0000000000a28bc7 in v8::internal::CodeGenerator::MakeCodeEpilogue(v8::internal::MacroAssembler*, v8::internal::CompilationInfo*) ()
#12 0x0000000000c7f78d in v8::internal::FullCodeGenerator::MakeCode(v8::internal::CompilationInfo*) ()
#13 0x0000000000b4e6de in v8::internal::(anonymous namespace)::GenerateBaselineCode(v8::internal::CompilationInfo*) ()
#14 0x0000000000b50ac0 in v8::internal::(anonymous namespace)::GetUnoptimizedCodeCommon(v8::internal::CompilationInfo*) ()
#15 0x0000000000b58186 in v8::internal::(anonymous namespace)::GetLazyCode(v8::internal::Handle<v8::internal::JSFunction>) ()
#16 0x0000000000b5840c in v8::internal::Compiler::Compile(v8::internal::Handle<v8::internal::JSFunction>, v8::internal::Compiler::ClearExceptionFlag) ()
#17 0x0000000000e8cf66 in v8::internal::Runtime_CompileLazy(int, v8::internal::Object**, v8::internal::Isolate*) ()
#18 0x00000f2b0c5092a7 in ?? ()
#19 0x00000f2b0c5091e1 in ?? ()
#20 0x00007fffffffcea0 in ?? ()
#21 0x0000000300000000 in ?? ()
#22 0x00007fffffffcef8 in ?? ()
#23 0x00000f2b0c530b18 in ?? ()
#24 0x00001e6d6a30fed1 in ?? ()
#25 0x00001bf16d304381 in ?? ()
#26 0x00001e6d6a30fed1 in ?? ()
#27 0x0000000200000000 in ?? ()
#28 0x00000f2b0c530a81 in ?? ()
#29 0x0000000c00000000 in ?? ()
#30 0x00007fffffffcf98 in ?? ()
#31 0x00000f2b0d3ca1ce in ?? ()
#32 0x00001e6d6a310a49 in ?? ()
#33 0x00001e6d6a311019 in ?? ()
#34 0x00001bf16d304381 in ?? ()
#35 0x00001e6d6a30fed1 in ?? ()
#36 0x00001e6d6a310909 in ?? ()
#37 0x00001bf16d304381 in ?? ()
#38 0x00001bf16d304381 in ?? ()
#39 0x00001bf16d304381 in ?? ()
#40 0x00001e6d6a3121b1 in ?? ()
#41 0x00001e6d6a311051 in ?? ()
#42 0x00001e6d6a30f4e1 in ?? ()
#43 0x00001e6d6a311019 in ?? ()
#44 0x00001e6d6a310e49 in ?? ()
#45 0x00001e6d6a310b91 in ?? ()
#46 0x00001e6d6a310ad9 in ?? ()
#47 0x00001e6d6a310a49 in ?? ()
#48 0x00000cb0b2b553e1 in ?? ()
#49 0x00001e6d6a3108a1 in ?? ()
#50 0x00007fffffffd010 in ?? ()
#51 0x00000f2b0d3ebdca in ?? ()
#52 0x00001e6d6a30ff41 in ?? ()
#53 0x00001e6d6a30fed1 in ?? ()
#54 0x00001e6d6a30b4e9 in ?? ()
#55 0x00001e6d6a3105c1 in ?? ()
#56 0x00001bf16d304381 in ?? ()
#57 0x00000cb0b2b553e1 in ?? ()
#58 0x00001e6d6a3105c1 in ?? ()
#59 0x00001e6d6a3104a9 in ?? ()
#60 0x00001e6d6a310211 in ?? ()
#61 0x00001e6d6a30ff41 in ?? ()
#62 0x00001e6d6a30fed1 in ?? ()
#63 0x00000cb0b2b5eeb1 in ?? ()
#64 0x00001e6d6a30fe99 in ?? ()
#65 0x00007fffffffd060 in ?? ()
#66 0x00000f2b0d372dd1 in ?? ()
#67 0x000003e800000000 in ?? ()
#68 0x00001e6d6a30b459 in ?? ()
#69 0x00000cb0b2bcd6a1 in ?? ()

"Unauthorized" error when credentials expire

The call to the request to create a profile can hang for up to an hour. If the credentials expire while this request is hanging, then an 'Unauthorized' error is returned.

To reduce the frequency of this error, we want to refresh the token before it has expired when making requests.

Setting logLevel to 4 (or 5) doesn't seem to enable the debug logging

I tried something like

require('@google-cloud/profiler').start({
    serviceContext: {
    service: 'nodejs',
    version: '2.0.0',
    logLevel: 5,
  },
});
var doSomeWork = () => {
  console.log("doing some work");
  for (var i = 0; i < 1e8; i++) {
  }
};

but when I ran the program I don't see any debug message on the console. The data is collected though so it seems the profiler is running so it only seems a logging issue.

npm install fails on travis testing with node 6

npm install is failling with the following error during travis testing when run with node 6:

35.69s$ npm install 
npm ERR! Linux 4.9.6-040906-generic
npm ERR! argv "/home/travis/.nvm/versions/node/v6.12.2/bin/node" "/home/travis/.nvm/versions/node/v6.12.2/bin/npm" "install"
npm ERR! node v6.12.2
npm ERR! npm  v3.10.10
npm ERR! code EREADFILE
npm ERR! Error extracting /home/travis/.npm/clang-format/1.0.40/package.tgz archive: ENOENT: no such file or directory, open '/home/travis/.npm/clang-format/1.0.40/package.tgz'
npm ERR! 
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>
npm ERR! Please include the following file with any support request:
npm ERR!     /home/travis/build/GoogleCloudPlatform/cloud-profiler-nodejs/npm-debug.log

Change the default log level for "warning" and adhere that in the source

And further:

  • The default level should be “warning”.
  • Use error level for only for invalid profiler configuration by user. Should not be more than a couple in the whole source of the agent.
  • Use warning level for persistent / unexpected errors which user should know about because they degrade the profiling quality. Should be used very sparingly.
  • The info and debug levels should be used for logging information that can be useful to investigate issues. Getting this will require users to change the default log level per maintainer request.

Add back source-map-support for better stack traces

When running tests in #56, tests passed prior to merging in #60 and failed after, with the following stack trace:

/usr/local/google/home/nolanmar/cloud-profiler-nodejs/node_modules/source-map/lib/util.js:344
  var cmp = mappingA.generatedLine - mappingB.generatedLine;
                                              ^

TypeError: Cannot read property 'generatedLine' of undefined
    at compareByGeneratedPositionsDeflated (/usr/local/google/home/nolanmar/cloud-profiler-nodejs/node_modules/source-map/lib/util.js:344:47)
    at doQuickSort (/usr/local/google/home/nolanmar/cloud-profiler-nodejs/node_modules/source-map/lib/quick-sort.js:88:11)
    at exports.quickSort (/usr/local/google/home/nolanmar/cloud-profiler-nodejs/node_modules/source-map/lib/quick-sort.js:113:3)
    at BasicSourceMapConsumer.SourceMapConsumer_parseMappings [as _parseMappings] (/usr/local/google/home/nolanmar/cloud-profiler-nodejs/node_modules/source-map/lib/source-map-consumer.js:564:5)
    at BasicSourceMapConsumer.get [as _generatedMappings] (/usr/local/google/home/nolanmar/cloud-profiler-nodejs/node_modules/source-map/lib/source-map-consumer.js:70:12)
    at BasicSourceMapConsumer.SourceMapConsumer_originalPositionFor [as originalPositionFor] (/usr/local/google/home/nolanmar/cloud-profiler-nodejs/node_modules/source-map/lib/source-map-consumer.js:655:12)
    at mapSourcePosition (/usr/local/google/home/nolanmar/cloud-profiler-nodejs/node_modules/source-map-support/source-map-support.js:199:42)
    at wrapCallSite (/usr/local/google/home/nolanmar/cloud-profiler-nodejs/node_modules/source-map-support/source-map-support.js:343:20)
    at /usr/local/google/home/nolanmar/cloud-profiler-nodejs/node_modules/source-map-support/source-map-support.js:378:26
    at Array.map (<anonymous>)
    at Function.prepareStackTrace (/usr/local/google/home/nolanmar/cloud-profiler-nodejs/node_modules/source-map-support/source-map-support.js:377:24)
    at /usr/local/google/home/nolanmar/cloud-profiler-nodejs/node_modules/mocha/lib/reporters/base.js:184:21
    at Array.forEach (<anonymous>)
    at Function.exports.list (/usr/local/google/home/nolanmar/cloud-profiler-nodejs/node_modules/mocha/lib/reporters/base.js:167:12)
    at Spec.Base.epilogue (/usr/local/google/home/nolanmar/cloud-profiler-nodejs/node_modules/mocha/lib/reporters/base.js:344:10)
    at emitNone (events.js:111:20)
    at Runner.emit (events.js:208:7)
    at /usr/local/google/home/nolanmar/cloud-profiler-nodejs/node_modules/mocha/lib/runner.js:829:12
    at done (/usr/local/google/home/nolanmar/cloud-profiler-nodejs/node_modules/mocha/lib/runner.js:666:7)
    at Runner.next [as nextSuite] (/usr/local/google/home/nolanmar/cloud-profiler-nodejs/node_modules/mocha/lib/runner.js:633:16)
    at Runner.uncaught (/usr/local/google/home/nolanmar/cloud-profiler-nodejs/node_modules/mocha/lib/runner.js:754:17)
    at process.uncaught (/usr/local/google/home/nolanmar/cloud-profiler-nodejs/node_modules/mocha/lib/runner.js:821:10)
    at emitOne (events.js:116:13)
    at process.emit (events.js:211:7)
    at processEmit (/usr/local/google/home/nolanmar/cloud-profiler-nodejs/node_modules/nyc/node_modules/signal-exit/index.js:155:32)
    at process.emit (/usr/local/google/home/nolanmar/cloud-profiler-nodejs/node_modules/source-map-support/source-map-support.js:439:21)
    at process._fatalException (bootstrap_node.js:374:26)

#56 will undo changes from #60.

Memory leak in Heap Profiler

There is a memory leak when using the profiler and collecting just time profiles, just heap profiles, or both time and heap profiles.
Increasing the rate at which profiles are collected seems to increase the rate at which memory leaks. When using process.memoryUsage() to look at memory used, RSS increases notable and heapTotal seems to roughly constant.

Profiler no longer works when projectId is not specified.

I've been working on the e2e testing, and I had been working on a stale branch in my repo.
I updated the branch I've been working on today, and started seeing messages like this logged: WARN:@google-cloud/profiler: Failed to create profile, waiting 1.4s to try again: Error: Bad Request.

I did more testing and it looks like this happens only when the projectId is not specified (I'm testing one GCE). This does happen with the current release of the profiling agent.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.