@google-cloud/profiler
Advanced tools
Comparing version 0.2.2 to 0.2.3
@@ -16,3 +16,2 @@ /** | ||
*/ | ||
import * as consoleLogLevel from 'console-log-level'; | ||
import { SemVer } from 'semver'; | ||
@@ -49,3 +48,2 @@ import { Config } from './config'; | ||
export declare function start(config?: Config): Promise<void>; | ||
export declare function logLevelToName(level?: number): consoleLogLevel.LogLevelNames; | ||
/** | ||
@@ -52,0 +50,0 @@ * For debugging purposes. Collects profiles and discards the collected |
@@ -26,3 +26,2 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const consoleLogLevel = require("console-log-level"); | ||
const delay_1 = require("delay"); | ||
@@ -34,5 +33,7 @@ const extend = require("extend"); | ||
const config_1 = require("./config"); | ||
const logger_1 = require("./logger"); | ||
const profiler_1 = require("./profiler"); | ||
const heapProfiler = require("./profilers/heap-profiler"); | ||
const pjson = require('../../package.json'); | ||
const serviceRegex = /^[a-z]([-a-z0-9_.]{0,253}[a-z0-9])?$/; | ||
/** | ||
@@ -90,4 +91,8 @@ * @return value of metadata field. | ||
if (!hasService(mergedConfig)) { | ||
throw new Error('Service must be specified in the configuration.'); | ||
throw new Error('Service must be specified in the configuration'); | ||
} | ||
if (!serviceRegex.test(mergedConfig.serviceContext.service)) { | ||
throw new Error(`Service ${mergedConfig.serviceContext | ||
.service} does not match regular expression "${serviceRegex.toString()}"`); | ||
} | ||
return mergedConfig; | ||
@@ -186,22 +191,5 @@ } | ||
exports.start = start; | ||
const LEVEL_NAMES = ['fatal', 'error', 'warn', 'info', 'debug', 'trace']; | ||
function logLevelToName(level) { | ||
if (level === undefined) { | ||
level = config_1.defaultConfig.logLevel; | ||
} | ||
else if (level < 0) { | ||
level = 0; | ||
} | ||
else if (level > 4) { | ||
level = 4; | ||
} | ||
return LEVEL_NAMES[level]; | ||
} | ||
exports.logLevelToName = logLevelToName; | ||
function logError(msg, config) { | ||
const logger = consoleLogLevel({ | ||
stderr: true, | ||
prefix: pjson.name, | ||
level: logLevelToName(config.logLevel) | ||
}); | ||
// FIXME: do not create a new logger on each error. | ||
const logger = logger_1.createLogger(config.logLevel); | ||
logger.error(msg); | ||
@@ -224,7 +212,3 @@ } | ||
// Set up periodic logging. | ||
const logger = consoleLogLevel({ | ||
stderr: true, | ||
prefix: pjson.name, | ||
level: logLevelToName(config.logLevel) | ||
}); | ||
const logger = logger_1.createLogger(config.logLevel); | ||
let heapProfileCount = 0; | ||
@@ -231,0 +215,0 @@ let timeProfileCount = 0; |
@@ -27,3 +27,2 @@ "use strict"; | ||
const common_1 = require("@google-cloud/common"); | ||
const consoleLogLevel = require("console-log-level"); | ||
const pify = require("pify"); | ||
@@ -34,3 +33,3 @@ const msToStr = require("pretty-ms"); | ||
const profile_1 = require("../../proto/profile"); | ||
const index_1 = require("./index"); | ||
const logger_1 = require("./logger"); | ||
const heapProfiler = require("./profilers/heap-profiler"); | ||
@@ -225,7 +224,3 @@ const time_profiler_1 = require("./profilers/time-profiler"); | ||
this.config = config; | ||
this.logger = consoleLogLevel({ | ||
stderr: true, | ||
prefix: pjson.name, | ||
level: index_1.logLevelToName(this.config.logLevel) | ||
}); | ||
this.logger = logger_1.createLogger(this.config.logLevel); | ||
const labels = { language: 'nodejs' }; | ||
@@ -232,0 +227,0 @@ if (this.config.zone) { |
{ | ||
"name": "@google-cloud/profiler", | ||
"version": "0.2.2", | ||
"version": "0.2.3", | ||
"description": "Adds support for Stackdriver Profiler to node.js applications", | ||
"repository": "GoogleCloudPlatform/cloud-profiler-nodejs", | ||
"repository": "googleapis/cloud-profiler-nodejs", | ||
"main": "out/src/index.js", | ||
@@ -29,3 +29,3 @@ "types": "out/src/index.d.ts", | ||
"dependencies": { | ||
"@google-cloud/common": "^0.25.0", | ||
"@google-cloud/common": "^0.26.0", | ||
"@types/console-log-level": "^1.4.0", | ||
@@ -37,4 +37,4 @@ "@types/semver": "^5.5.0", | ||
"extend": "^3.0.1", | ||
"gcp-metadata": "^0.8.0", | ||
"nan": "^2.8.0", | ||
"gcp-metadata": "^0.9.0", | ||
"nan": "^2.11.1", | ||
"parse-duration": "^0.1.1", | ||
@@ -56,6 +56,6 @@ "pify": "^4.0.0", | ||
"@types/request": "^2.47.1", | ||
"@types/sinon": "^5.0.1", | ||
"@types/sinon": "5.0.5", | ||
"codecov": "^3.0.0", | ||
"deep-copy": "^1.4.2", | ||
"gts": "^0.8.0", | ||
"gts": "^0.9.0", | ||
"intelli-espower-loader": "^1.0.1", | ||
@@ -66,6 +66,6 @@ "js-green-licenses": "^0.5.0", | ||
"nyc": "^13.0.0", | ||
"sinon": "^6.0.0", | ||
"sinon": "^7.0.0", | ||
"source-map-support": "^0.5.6", | ||
"ts-mockito": "^2.2.5", | ||
"typescript": "~3.1.0" | ||
"typescript": "~3.1.4" | ||
}, | ||
@@ -72,0 +72,0 @@ "files": [ |
@@ -140,5 +140,5 @@ # Google Cloud Profiler | ||
```js | ||
var profiler = require('@google-cloud/profiler').start(); | ||
``` | ||
```js | ||
var profiler = require('@google-cloud/profiler').start(); | ||
``` | ||
@@ -145,0 +145,0 @@ You can specify which version of Node.js you're using by adding a snippet like |
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 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
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
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
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
1173582
36
22597
+ Added@google-cloud/common@0.26.2(transitive)
+ Addedgcp-metadata@0.9.3(transitive)
+ Addedthrough2@3.0.2(transitive)
- Removed@google-cloud/common@0.25.3(transitive)
- Removedgcp-metadata@0.8.0(transitive)
- Removedis@3.3.0(transitive)
- Removedthrough2@2.0.5(transitive)
- Removedxtend@4.0.2(transitive)
Updated@google-cloud/common@^0.26.0
Updatedgcp-metadata@^0.9.0
Updatednan@^2.11.1