Skip to content

Commit 78a6a6b

Browse files
committed
instrument lambda function
1 parent 3a712bc commit 78a6a6b

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

_lambda/random-name/index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
1-
var AWS = require('aws-sdk');
1+
var AWSXRay = require('aws-xray-sdk-core');
2+
var AWS = AWSXRay.captureAWS(require('aws-sdk'));
3+
24
AWS.config.update({region: process.env.REGION});
35
var Chance = require('chance');
46

57
var myFunction = function(event, context, callback) {
68
var sns = new AWS.SNS();
79
var chance = new Chance();
10+
var segment = AWSXRay.getSegment();
811
var userid = event.userid;
12+
segment.addAnnotation('User ID', userid);
913

1014
var name = chance.first();
15+
segment.addAnnotation('Name', name);
1116

1217
// Nofity
1318
var params = {

_lambda/random-name/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@
1414
"license": "Apache-2.0",
1515
"dependencies": {
1616
"chance": "^1.0.4",
17-
"aws-xray-sdk": "1.1.0"
17+
"aws-xray-sdk-core": "1.1.0"
1818
}
1919
}

src/main/java/scorekeep/GameHistoryController.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import org.springframework.web.bind.annotation.RequestMethod;
66
import org.springframework.web.bind.annotation.RestController;
77
import scorekeep.dao.gamehistory.GameHistory;
8+
import scorekeep.dao.gamehistory.GameHistory;
89

910
import java.io.IOException;
1011
import java.util.List;
@@ -31,8 +32,9 @@ public GameHistory create() throws IOException, RdsNotConfiguredException {
3132
throw new RdsNotConfiguredException();
3233
}
3334

34-
String winner = userFactory.randomName();
35-
String loser = userFactory.randomName();
35+
String category = "American names";
36+
String winner = userFactory.randomNameLambda("1235ABCD", category);
37+
String loser = userFactory.randomNameLambda("ABCD1235", category);
3638

3739
return model.create(winner, loser);
3840
}

0 commit comments

Comments
 (0)