Skip to content

Commit

Permalink
#8: x-ray instrumentation
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianfeduniak committed Dec 1, 2017
1 parent de64b98 commit 0d81d34
Show file tree
Hide file tree
Showing 6 changed files with 121 additions and 4 deletions.
107 changes: 107 additions & 0 deletions cat-rekognition/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions cat-rekognition/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@
"description": "Detecting cat in a picture",
"main": "src/handler.js",
"dependencies": {
"aws-xray-sdk": "1.1.6",
"serverless": "1.24.0",
"serverless-s3-remover": "0.4.0"
},
"devDependencies": {
"chai": "3.5.0",
"mocha": "3.2.0",
"serverless-plugin-tracing": "2.0.0",
"sinon": "4.1.2"
},
"scripts": {
Expand Down
7 changes: 6 additions & 1 deletion cat-rekognition/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ provider:
region: eu-west-1
profile: appliscale-dev
runtime: nodejs6.10
tracing: true
iamRoleStatements:
- Effect: Allow
Action:
Expand All @@ -23,6 +24,10 @@ provider:
- dynamodb:UpdateItem
- dynamodb:DeleteItem
Resource: "*"
- Effect: Allow
Action:
- xray:*
Resource: "*"

functions:
uploadcatpicture:
Expand Down Expand Up @@ -69,7 +74,6 @@ resources:
SourceArn: "arn:aws:s3:::serverless-cat-detector-img-repo"
CatStatusDbTable:
Type: 'AWS::DynamoDB::Table'
DeletionPolicy: Retain
Properties:
AttributeDefinitions:
-
Expand All @@ -86,6 +90,7 @@ resources:

plugins:
- serverless-s3-remover
- serverless-plugin-tracing

custom:
remover:
Expand Down
3 changes: 2 additions & 1 deletion cat-rekognition/src/persistence.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

const STATUS_TABLE_NAME = 'ServerlessCatDetectorStatus';

const AWS = require('aws-sdk');
const AWSXRay = require('aws-xray-sdk');
const AWS = AWSXRay.captureAWS(require('aws-sdk'));
const dynamoDb = new AWS.DynamoDB.DocumentClient();

module.exports.dbItem = (fileName, scanned, scanningStatus) => {
Expand Down
3 changes: 2 additions & 1 deletion cat-rekognition/src/recognition.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

const AWS = require('aws-sdk');
const AWSXRay = require('aws-xray-sdk');
const AWS = AWSXRay.captureAWS(require('aws-sdk'));
const rekognition = new AWS.Rekognition();

module.exports.check = (fileName) => {
Expand Down
3 changes: 2 additions & 1 deletion cat-rekognition/src/upload.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

const AWS = require('aws-sdk');
const AWSXRay = require('aws-xray-sdk');
const AWS = AWSXRay.captureAWS(require('aws-sdk'));
const s3 = new AWS.S3();

const CORS_HEADERS = { 'Access-Control-Allow-Origin': '*' };
Expand Down

0 comments on commit 0d81d34

Please sign in to comment.