Skip to content

Commit

Permalink
Handle promises correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandr Murashkin authored and Alexandr Murashkin committed May 19, 2017
1 parent 6af399a commit 60d3155
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ module.exports = class TracingConfigPlugin {
const service = this.serverless.service;
const stage = this.options.stage;
const providerLevelTracingEnabled = (service.provider.tracing === true);
Object.keys(service.functions).forEach(functionName => {
this.toggleTracing(`${service.service}-${stage}-${functionName}`,
return Promise.all(Object.keys(service.functions).map(functionName => {
return this.toggleTracing(`${service.service}-${stage}-${functionName}`,
(service.functions[functionName].tracing === true)
|| (providerLevelTracingEnabled && service.functions[functionName].tracing !== false)
);
});
}));
}

toggleTracing(functionName, isEnabled) {
this.serverless.cli.log(`Tracing ${isEnabled ? 'ENABLED' : 'DISABLED'} for function "${functionName}"`);
this.aws.request('Lambda', 'updateFunctionConfiguration', {
return this.aws.request('Lambda', 'updateFunctionConfiguration', {
FunctionName: functionName,
TracingConfig: {
Mode: isEnabled === true ? 'Active' : 'PassThrough'
Expand Down

0 comments on commit 60d3155

Please sign in to comment.