@iopipe/profiler
Advanced tools
Comparing version 2.1.1 to 2.1.2
@@ -17,4 +17,2 @@ 'use strict'; | ||
var _core = require('@iopipe/core'); | ||
var _simpleGet = require('simple-get'); | ||
@@ -73,2 +71,4 @@ | ||
this.coreUtil = null; | ||
return this; | ||
@@ -120,39 +120,49 @@ } | ||
getFileUploadMeta() { | ||
// returns a promise here | ||
let { invokedFunctionArn: arn } = this.invocationInstance.context; | ||
var _this = this; | ||
const { | ||
awsRequestId: requestId, | ||
functionName | ||
} = this.invocationInstance.context; | ||
return _asyncToGenerator(function* () { | ||
// patch for potential circular dependency with core | ||
if (!_this.coreUtil) { | ||
const core = yield require('@iopipe/core'); | ||
_this.coreUtil = core.util; | ||
} | ||
if (arn === undefined || process.env.AWS_SAM_LOCAL) { | ||
arn = `arn:aws:lambda:local:0:function:${functionName}`; | ||
} | ||
// returns a promise here | ||
let { invokedFunctionArn: arn } = _this.invocationInstance.context; | ||
return _core.util.getFileUploadMeta({ | ||
auth: this.token, | ||
networkTimeout: this.config.networkTimeout, | ||
arn, | ||
requestId, | ||
functionName | ||
}); | ||
const { | ||
awsRequestId: requestId, | ||
functionName | ||
} = _this.invocationInstance.context; | ||
if (arn === undefined || process.env.AWS_SAM_LOCAL) { | ||
arn = `arn:aws:lambda:local:0:function:${functionName}`; | ||
} | ||
return _this.coreUtil.getFileUploadMeta({ | ||
auth: _this.token, | ||
networkTimeout: _this.config.networkTimeout, | ||
arn, | ||
requestId, | ||
functionName | ||
}); | ||
})(); | ||
} | ||
postInvoke() { | ||
var _this = this; | ||
var _this2 = this; | ||
return _asyncToGenerator(function* () { | ||
if (!_this.enabled) return false; | ||
if (!_this2.enabled) return false; | ||
try { | ||
const [fileUploadMeta = {}] = yield _this.pluginReadyPromise; | ||
const [fileUploadMeta = {}] = yield _this2.pluginReadyPromise; | ||
if (fileUploadMeta.jwtAccess) { | ||
_this.uploads.push(fileUploadMeta.jwtAccess); | ||
_this.signedRequestUrl = fileUploadMeta.signedRequest; | ||
_this2.uploads.push(fileUploadMeta.jwtAccess); | ||
_this2.signedRequestUrl = fileUploadMeta.signedRequest; | ||
} else { | ||
return _this.log(`S3 signer service error. Response: ${JSON.stringify(fileUploadMeta)}`); | ||
return _this2.log(`S3 signer service error. Response: ${JSON.stringify(fileUploadMeta)}`); | ||
} | ||
} catch (err) { | ||
_this.log(err); | ||
_this2.log(err); | ||
// if there is an error setting things up, bail early | ||
@@ -182,3 +192,3 @@ return false; | ||
yield request({ | ||
url: _this.signedRequestUrl, | ||
url: _this2.signedRequestUrl, | ||
method: 'PUT', | ||
@@ -192,3 +202,3 @@ body: Buffer.concat(archiveBuffer) | ||
// We will use this number to know when we should finish up all the work | ||
const totalWantedFiles = [_this.profilerEnabled, _this.heapEnabled].filter(Boolean).length; | ||
const totalWantedFiles = [_this2.profilerEnabled, _this2.heapEnabled].filter(Boolean).length; | ||
@@ -199,4 +209,4 @@ let filesSeen = 0; | ||
if (filesSeen === totalWantedFiles) { | ||
if (typeof _this.invocationInstance.context.iopipe.label === 'function') { | ||
_this.invocationInstance.context.iopipe.label('@iopipe/plugin-profiler'); | ||
if (typeof _this2.invocationInstance.context.iopipe.label === 'function') { | ||
_this2.invocationInstance.context.iopipe.label('@iopipe/plugin-profiler'); | ||
} | ||
@@ -207,4 +217,4 @@ archive.finalize(); | ||
if (_this.profilerEnabled) { | ||
_this.sessionPost('Profiler.stop').then(function ({ profile }) { | ||
if (_this2.profilerEnabled) { | ||
_this2.sessionPost('Profiler.stop').then(function ({ profile }) { | ||
archive.append(JSON.stringify(profile), { | ||
@@ -216,8 +226,8 @@ name: 'profile.cpuprofile' | ||
if (_this.heapEnabled) { | ||
_this.session.on('HeapProfiler.addHeapSnapshotChunk', function (obj) { | ||
if (_this2.heapEnabled) { | ||
_this2.session.on('HeapProfiler.addHeapSnapshotChunk', function (obj) { | ||
return heapSnapshotBufferArr.push(obj && obj.params && obj.params.chunk && Buffer.from(obj.params.chunk)); | ||
}); | ||
_this.sessionPost('HeapProfiler.takeHeapSnapshot').then(function () { | ||
_this2.sessionPost('HeapProfiler.takeHeapSnapshot').then(function () { | ||
archive.append(Buffer.concat(heapSnapshotBufferArr.filter(Boolean)), { | ||
@@ -229,3 +239,3 @@ name: 'profile.heapsnapshot' | ||
} catch (e) { | ||
_this.log(`Error in upload: ${e}`); | ||
_this2.log(`Error in upload: ${e}`); | ||
resolve(); | ||
@@ -232,0 +242,0 @@ } |
{ | ||
"name": "@iopipe/profiler", | ||
"version": "2.1.1", | ||
"version": "2.1.2", | ||
"description": "IOpipe plugin for running the v8 profiler on your functions", | ||
@@ -41,6 +41,6 @@ "main": "dist/index.js", | ||
"nock": "^9.4.1", | ||
"pre-commit": "^1.2.2" | ||
"pre-commit": "^1.2.2", | ||
"@iopipe/core": "^1.19.1" | ||
}, | ||
"dependencies": { | ||
"@iopipe/core": "^1.19.1", | ||
"archiver": "^2.1.1", | ||
@@ -47,0 +47,0 @@ "lodash.get": "^4.4.2", |
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
23588
3
221
6
- Removed@iopipe/core@^1.19.1
- Removed@iopipe/core@1.19.5(transitive)
- Removedargparse@1.0.10(transitive)
- Removedcosmiconfig@4.0.0(transitive)
- Removederror-ex@1.3.2(transitive)
- Removedesprima@4.0.1(transitive)
- Removedis-arrayish@0.2.1(transitive)
- Removedis-directory@0.3.1(transitive)
- Removedjs-yaml@3.14.1(transitive)
- Removedjson-parse-better-errors@1.0.2(transitive)
- Removedlodash.uniqby@4.7.0(transitive)
- Removedparse-json@4.0.0(transitive)
- Removedrequire-from-string@2.0.2(transitive)
- Removedsprintf-js@1.0.3(transitive)