@google-cloud/profiler
Advanced tools
Comparing version 1.1.2 to 2.0.0
@@ -7,2 +7,31 @@ # Changelog | ||
## v2.0.0 | ||
05-14-2019 13:21 PDT | ||
### Implementation Changes | ||
- build: remove support for node 6 ([#472](https://github.com/googleapis/cloud-profiler-nodejs/pull/472)) | ||
### Dependencies | ||
- fix(deps): update dependency gcp-metadata to v2 ([#481](https://github.com/googleapis/cloud-profiler-nodejs/pull/481)) | ||
- fix(deps): update dependency @google-cloud/common to v1 ([#482](https://github.com/googleapis/cloud-profiler-nodejs/pull/482)) | ||
- fix(deps): update dependency pretty-ms to v5 ([#464](https://github.com/googleapis/cloud-profiler-nodejs/pull/464)) | ||
- chore(deps): update dependency gts to v1 ([#474](https://github.com/googleapis/cloud-profiler-nodejs/pull/474)) | ||
- fix(deps): update dependency gaxios to v2 ([#469](https://github.com/googleapis/cloud-profiler-nodejs/pull/469)) | ||
- chore(deps): update dependency @types/nock to v10 ([#470](https://github.com/googleapis/cloud-profiler-nodejs/pull/470)) | ||
- chore(dep): update mocha to 6.1 ([#461](https://github.com/googleapis/cloud-profiler-nodejs/pull/461)) | ||
### Documentation | ||
- Specify default logging level ([#483](https://github.com/googleapis/cloud-profiler-nodejs/pull/483)) | ||
### Internal / Testing Changes | ||
- build: allow Node 10 to push to codecov ([#480](https://github.com/googleapis/cloud-profiler-nodejs/pull/480)) | ||
- build: patch Windows container, fixing Node 10 ([#479](https://github.com/googleapis/cloud-profiler-nodejs/pull/479)) | ||
- Revert "build!: upgrade engines field to >=8.10.0 ([#476](https://github.com/googleapis/cloud-profiler-nodejs/pull/476))" ([#477](https://github.com/googleapis/cloud-profiler-nodejs/pull/477)) | ||
- build!: upgrade engines field to >=8.10.0 ([#476](https://github.com/googleapis/cloud-profiler-nodejs/pull/476)) | ||
- chore: update to .nycrc with --all enabled ([#473](https://github.com/googleapis/cloud-profiler-nodejs/pull/473)) | ||
- fix: update dependencies for npm audit ([#468](https://github.com/googleapis/cloud-profiler-nodejs/pull/468)) | ||
- fix: add es2015 as target for tsconfig.json ([#466](https://github.com/googleapis/cloud-profiler-nodejs/pull/466)) | ||
- chore: remove old kokoro configs ([#458](https://github.com/googleapis/cloud-profiler-nodejs/pull/458)) | ||
## v1.1.2 | ||
@@ -9,0 +38,0 @@ |
@@ -48,4 +48,4 @@ "use strict"; | ||
function hasService(config) { | ||
return config.serviceContext !== undefined && | ||
typeof config.serviceContext.service === 'string'; | ||
return (config.serviceContext !== undefined && | ||
typeof config.serviceContext.service === 'string'); | ||
} | ||
@@ -63,3 +63,3 @@ /** | ||
version: process.env.GAE_VERSION || process.env.K_REVISION, | ||
} | ||
}, | ||
}; | ||
@@ -101,4 +101,3 @@ if (process.env.GCLOUD_PROFILER_LOGLEVEL !== undefined) { | ||
if (!serviceRegex.test(mergedConfig.serviceContext.service)) { | ||
throw new Error(`Service ${mergedConfig.serviceContext | ||
.service} does not match regular expression "${serviceRegex.toString()}"`); | ||
throw new Error(`Service ${mergedConfig.serviceContext.service} does not match regular expression "${serviceRegex.toString()}"`); | ||
} | ||
@@ -114,10 +113,8 @@ return mergedConfig; | ||
if (!config.zone || !config.instance) { | ||
const [instance, zone] = (yield Promise | ||
.all([ | ||
getMetadataInstanceField('name'), getMetadataInstanceField('zone') | ||
]) | ||
.catch((err) => { | ||
const [instance, zone] = (yield Promise.all([ | ||
getMetadataInstanceField('name'), | ||
getMetadataInstanceField('zone'), | ||
]).catch((err) => { | ||
// ignore errors, which will occur when not on GCE. | ||
})) || | ||
[undefined, undefined]; | ||
})) || [undefined, undefined]; | ||
if (!config.zone && zone) { | ||
@@ -226,3 +223,3 @@ config.zone = zone.substring(zone.lastIndexOf('/') + 1); | ||
const { rss, heapTotal, heapUsed } = process.memoryUsage(); | ||
logger.debug(new Date().toISOString(), 'rss', (rss / (1024 * 1024)).toFixed(3), 'MiB,', 'heap total', (heapTotal / (1024 * 1024)).toFixed(3), 'MiB,', 'heap used', (heapUsed / (1024 * 1024)).toFixed(3), 'MiB,', 'heap profile collection rate', (heapProfileCount * 1000 / (curTime - prevLogTime)).toFixed(3), 'profiles/s,', 'time profile collection rate', (timeProfileCount * 1000 / (curTime - prevLogTime)).toFixed(3), 'profiles/s'); | ||
logger.debug(new Date().toISOString(), 'rss', (rss / (1024 * 1024)).toFixed(3), 'MiB,', 'heap total', (heapTotal / (1024 * 1024)).toFixed(3), 'MiB,', 'heap used', (heapUsed / (1024 * 1024)).toFixed(3), 'MiB,', 'heap profile collection rate', ((heapProfileCount * 1000) / (curTime - prevLogTime)).toFixed(3), 'profiles/s,', 'time profile collection rate', ((timeProfileCount * 1000) / (curTime - prevLogTime)).toFixed(3), 'profiles/s'); | ||
heapProfileCount = 0; | ||
@@ -235,3 +232,6 @@ timeProfileCount = 0; | ||
if (!config.disableHeap) { | ||
const heap = yield profiler.profile({ name: 'Heap-Profile' + new Date(), profileType: 'HEAP' }); | ||
const heap = yield profiler.profile({ | ||
name: 'Heap-Profile' + new Date(), | ||
profileType: 'HEAP', | ||
}); | ||
heapProfileCount++; | ||
@@ -244,3 +244,3 @@ } | ||
profileType: 'WALL', | ||
duration: profiler.config.localTimeDurationMillis.toString() + 'ms' | ||
duration: profiler.config.localTimeDurationMillis.toString() + 'ms', | ||
}); | ||
@@ -247,0 +247,0 @@ timeProfileCount++; |
@@ -21,3 +21,10 @@ "use strict"; | ||
const pjson = require('../../package.json'); | ||
const LEVEL_NAMES = ['fatal', 'error', 'warn', 'info', 'debug', 'trace']; | ||
const LEVEL_NAMES = [ | ||
'fatal', | ||
'error', | ||
'warn', | ||
'info', | ||
'debug', | ||
'trace', | ||
]; | ||
function logLevelToName(level) { | ||
@@ -36,5 +43,9 @@ if (level === undefined) { | ||
function createLogger(level) { | ||
return consoleLogLevel({ stderr: true, prefix: pjson.name, level: logLevelToName(level) }); | ||
return consoleLogLevel({ | ||
stderr: true, | ||
prefix: pjson.name, | ||
level: logLevelToName(level), | ||
}); | ||
} | ||
exports.createLogger = createLogger; | ||
//# sourceMappingURL=logger.js.map |
@@ -30,3 +30,2 @@ "use strict"; | ||
const msToStr = require("pretty-ms"); | ||
const teeny_request_1 = require("teeny-request"); | ||
const zlib = require("zlib"); | ||
@@ -75,3 +74,4 @@ const profile_1 = require("../../proto/profile"); | ||
for (const item of b.error.details) { | ||
if (typeof item === 'object' && item.retryDelay && | ||
if (typeof item === 'object' && | ||
item.retryDelay && | ||
typeof item.retryDelay === 'string') { | ||
@@ -95,3 +95,6 @@ const backoffMillis = parseDuration(item.retryDelay); | ||
const backoffMessageRegex = /action throttled, backoff for ((?:([0-9]+)h)?(?:([0-9]+)m)?([0-9.]+)s)$/; | ||
const [, duration] = backoffMessageRegex.exec(backoffMessage) || [undefined, undefined]; | ||
const [, duration] = backoffMessageRegex.exec(backoffMessage) || [ | ||
undefined, | ||
undefined, | ||
]; | ||
if (duration) { | ||
@@ -111,3 +114,3 @@ const backoffMillis = parseDuration(duration); | ||
function isDeployment(deployment) { | ||
return (deployment.projectId === undefined || | ||
return ((deployment.projectId === undefined || | ||
typeof deployment.projectId === 'string') && | ||
@@ -118,3 +121,3 @@ (deployment.target === undefined || | ||
deployment.labels.language !== undefined && | ||
typeof deployment.labels.language === 'string'); | ||
typeof deployment.labels.language === 'string')); | ||
} | ||
@@ -126,8 +129,10 @@ /** | ||
function isRequestProfile(prof) { | ||
return prof && typeof prof.name === 'string' && | ||
return (prof && | ||
typeof prof.name === 'string' && | ||
typeof prof.profileType === 'string' && | ||
(prof.duration === undefined || typeof prof.duration === 'string') && | ||
(prof.labels === undefined || prof.labels.instance === undefined || | ||
(prof.labels === undefined || | ||
prof.labels.instance === undefined || | ||
typeof prof.labels.instance === 'string') && | ||
(prof.deployment === undefined || isDeployment(prof.deployment)); | ||
(prof.deployment === undefined || isDeployment(prof.deployment))); | ||
} | ||
@@ -227,4 +232,2 @@ /** | ||
packageJson: pjson, | ||
// tslint:disable-next-line: no-any | ||
requestModule: teeny_request_1.teenyRequest, | ||
}; | ||
@@ -234,8 +237,8 @@ super({ | ||
baseUrl: '/', | ||
// tslint:disable-next-line: no-any | ||
requestModule: teeny_request_1.teenyRequest | ||
}); | ||
this.config = config; | ||
this.logger = logger_1.createLogger(this.config.logLevel); | ||
const labels = { language: 'nodejs' }; | ||
const labels = { | ||
language: 'nodejs', | ||
}; | ||
if (this.config.zone) { | ||
@@ -250,3 +253,3 @@ labels.zone = this.config.zone; | ||
target: this.config.serviceContext.service, | ||
labels | ||
labels, | ||
}; | ||
@@ -280,4 +283,3 @@ this.profileLabels = {}; | ||
try { | ||
this.sourceMapper = | ||
yield pprof_1.SourceMapper.create(this.config.sourceMapSearchPath); | ||
this.sourceMapper = yield pprof_1.SourceMapper.create(this.config.sourceMapSearchPath); | ||
} | ||
@@ -431,3 +433,3 @@ catch (err) { | ||
case ProfileTypes.Wall: | ||
return yield this.writeTimeProfile(prof); | ||
return this.writeTimeProfile(prof); | ||
case ProfileTypes.Heap: | ||
@@ -462,3 +464,3 @@ return this.writeHeapProfile(prof); | ||
intervalMicros: this.config.timeIntervalMicros, | ||
sourceMapper: this.sourceMapper | ||
sourceMapper: this.sourceMapper, | ||
}; | ||
@@ -465,0 +467,0 @@ const p = yield pprof_1.time.profile(options); |
{ | ||
"name": "@google-cloud/profiler", | ||
"version": "1.1.2", | ||
"version": "2.0.0", | ||
"description": "Adds support for Stackdriver Profiler to Node.js applications", | ||
@@ -33,3 +33,4 @@ "repository": "googleapis/cloud-profiler-nodejs", | ||
"dependencies": { | ||
"@google-cloud/common": "^0.31.0", | ||
"gaxios": "2.0.1", | ||
"@google-cloud/common": "^1.0.0", | ||
"@types/console-log-level": "^1.4.0", | ||
@@ -42,3 +43,3 @@ "@types/semver": "^6.0.0", | ||
"findit2": "^2.2.3", | ||
"gcp-metadata": "^1.0.0", | ||
"gcp-metadata": "^2.0.0", | ||
"lodash.pickby": "^4.6.0", | ||
@@ -49,8 +50,7 @@ "p-limit": "^2.0.0", | ||
"pprof": "^0.2.0", | ||
"pretty-ms": "^4.0.0", | ||
"pretty-ms": "^5.0.0", | ||
"protobufjs": "~6.8.6", | ||
"semver": "^6.0.0", | ||
"source-map": "^0.6.1", | ||
"split": "^1.0.1", | ||
"teeny-request": "^3.3.0" | ||
"split": "^1.0.1" | ||
}, | ||
@@ -62,3 +62,3 @@ "devDependencies": { | ||
"@types/mocha": "^5.0.0", | ||
"@types/nock": "^9.1.0", | ||
"@types/nock": "^10.0.0", | ||
"@types/node": "^10.0.3", | ||
@@ -73,13 +73,13 @@ "@types/p-limit": "^2.0.0", | ||
"deep-copy": "^1.4.2", | ||
"gts": "^0.9.0", | ||
"gts": "^1.0.0", | ||
"intelli-espower-loader": "^1.0.1", | ||
"js-green-licenses": "^0.5.0", | ||
"mocha": "^6.0.0", | ||
"linkinator": "^1.1.2", | ||
"mocha": "^6.1.4", | ||
"nock": "^10.0.0", | ||
"nyc": "^13.0.0", | ||
"nyc": "^14.1.0", | ||
"sinon": "^7.0.0", | ||
"source-map-support": "^0.5.6", | ||
"tmp": "0.1.0", | ||
"typescript": "~3.4.0", | ||
"linkinator": "^1.1.2" | ||
"typescript": "~3.4.0" | ||
}, | ||
@@ -86,0 +86,0 @@ "files": [ |
@@ -108,5 +108,5 @@ # Google Cloud Profiler | ||
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, 3 sets it to info, and 4 sets it to | ||
debug. | ||
`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. | ||
@@ -113,0 +113,0 @@ So, for example, to start the profiler with the log level at debug, you would |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1192659
22980
+ Addedgaxios@2.0.1
+ Added@google-cloud/common@1.0.0(transitive)
+ Added@google-cloud/projectify@1.0.4(transitive)
+ Added@google-cloud/promisify@1.0.4(transitive)
+ Addedarrify@2.0.1(transitive)
+ Addedgaxios@2.0.1(transitive)
+ Addedgcp-metadata@2.0.4(transitive)
+ Addedgoogle-auth-library@4.2.6(transitive)
+ Addedgoogle-p12-pem@2.0.5(transitive)
+ Addedgtoken@3.0.2(transitive)
+ Addedpretty-ms@5.1.0(transitive)
- Removedteeny-request@^3.3.0
- Removed@google-cloud/common@0.31.1(transitive)
- Removed@google-cloud/projectify@0.3.3(transitive)
- Removed@google-cloud/promisify@0.4.0(transitive)
- Removed@types/duplexify@3.6.4(transitive)
- Removedarrify@1.0.1(transitive)
- Removedgaxios@1.8.4(transitive)
- Removedgcp-metadata@1.0.0(transitive)
- Removedgoogle-auth-library@3.1.2(transitive)
- Removedgoogle-p12-pem@1.0.5(transitive)
- Removedgtoken@2.3.3(transitive)
- Removedpretty-ms@4.0.0(transitive)
Updated@google-cloud/common@^1.0.0
Updatedgcp-metadata@^2.0.0
Updatedpretty-ms@^5.0.0