Skip to content

Commit b4f5690

Browse files
authored
Add AppSignal Monitoring (#99)
* Add AppSignal * Update TS * Activate AppSignal * Upgrade to node 14 * Add AppSignal middleware * Create child span * Add more logging * Fix logging data to appsignal * Fix wildcard paths * Revert the wildcard change * Fix appsignal * Activate it conditionally * Proper loggin * Better logging * Set right NODE_ENV * Fix cache locations * Update cache key * Add extra instrumentatin * Remove lerna-debug.log * Track API Calls * Move to withSpan
1 parent ed18250 commit b4f5690

File tree

17 files changed

+591
-321
lines changed

17 files changed

+591
-321
lines changed

.circleci/config.yml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,50 +6,53 @@ version: 2
66
jobs:
77
build-dependencies:
88
docker:
9-
- image: circleci/node:10
9+
- image: circleci/node:14
1010
working_directory: ~/codesandbox
1111
steps:
1212
- checkout
1313
- restore_cache:
1414
keys:
15-
- v1-dependencies-{{ checksum "yarn.lock" }}
15+
- v2-dependencies-{{ checksum "yarn.lock" }}
1616
# fallback to using the latest cache if no exact match is found
17-
- v1-dependencies-
17+
- v2-dependencies-
1818

1919
- run: yarn install
2020

2121
- save_cache:
2222
paths:
2323
- node_modules
2424
- packages/cli/node_modules
25-
- packages/git-extractors/node_modules
25+
- packages/git-extractor/node_modules
2626
- packages/import-utils/node_modules
27-
key: v1-dependencies-{{ checksum "yarn.lock" }}
27+
key: v2-dependencies-{{ checksum "yarn.lock" }}
2828

2929
# run tests!
3030
- run: yarn build
3131
- run: yarn test
3232

3333
- save_cache:
34-
key: v1-repo-{{ .Environment.CIRCLE_SHA1 }}
34+
key: v2-repo-{{ .Environment.CIRCLE_SHA1 }}
3535
paths:
3636
- ~/codesandbox
3737
create-docker-image:
3838
machine: true
3939
working_directory: ~/codesandbox
4040
steps:
4141
- restore_cache:
42-
key: v1-repo-{{ .Environment.CIRCLE_SHA1 }}
42+
key: v2-repo-{{ .Environment.CIRCLE_SHA1 }}
4343
- run:
4444
name: Docker Sign In
4545
command: "if [ -n $DOCKER_USER ]; then echo $DOCKER_PWD | docker login -u $DOCKER_USER --password-stdin; else exit 0; fi"
4646
- run:
4747
name: Create Dockerfile
4848
command: |
4949
cat > Dockerfile <<EOF
50-
FROM node:9.11.1
50+
FROM node:14.13.1
5151
WORKDIR /app
5252
COPY . /app
53+
54+
ENV NODE_ENV=production
55+
5356
CMD ["node", "./packages/git-extractor/dist/index.js"]
5457
EOF
5558
- run:

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,4 @@ temp
99
jest
1010
.aws
1111
dist
12-
13-
12+
lerna-debug.log

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM node:9.8
1+
FROM node:14.13.1
22
MAINTAINER Ives van Hoorne
33

44
RUN mkdir /usr/src/app

Dockerfile.dev

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM node:9.8
1+
FROM node:14.13.1
22
MAINTAINER Ives van Hoorne
33

44
ADD .git /workspace/.git

lerna-debug.log

Lines changed: 0 additions & 179 deletions
This file was deleted.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"lerna": "^2.4.0",
1818
"rimraf": "^2.6.2",
1919
"ts-jest": "^23.10.4",
20-
"typescript": "^3.5.3"
20+
"typescript": "^4.0.3"
2121
},
2222
"workspaces": [
2323
"packages/cli",

packages/cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
"@types/lodash": "^4.14.106",
5858
"@types/lz-string": "^1.3.32",
5959
"@types/ms": "^0.7.29",
60-
"@types/node": "^8.0.1",
60+
"@types/node": "^14",
6161
"@types/ora": "^0.3.31",
6262
"@types/shortid": "^0.0.29",
6363
"@types/update-notifier": "^1.0.1",

packages/cli/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
2525
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
2626
/* Strict Type-Checking Options */
27-
"strict": true /* Enable all strict type-checking options. */
27+
"strict": true, /* Enable all strict type-checking options. */
2828
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
2929
// "strictNullChecks": true, /* Enable strict null checks. */
3030
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
@@ -50,6 +50,7 @@
5050
/* Experimental Options */
5151
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
5252
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
53+
"skipLibCheck": true
5354
},
5455
"include": ["src/**/*.ts", "node_modules/**/*.ts", "typings/**/*.ts"],
5556
"exclude": ["__tests__", "build", "**/*.test.ts", "temp"]

packages/git-extractor/package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@
2525
"@types/jszip": "^3.4.1",
2626
"@types/koa": "^2.0.39",
2727
"@types/koa-bodyparser": "^3.0.25",
28-
"@types/koa-router": "^7.0.22",
28+
"@types/koa__router": "^8.0.3",
2929
"@types/lodash.pickby": "^4.6.2",
3030
"@types/lru-cache": "^4.1.0",
31-
"@types/node": "^8.0.50",
31+
"@types/node": "^14",
3232
"@types/node-fetch": "^1.6.7",
3333
"@types/redis": "^2.6.0",
3434
"@types/shortid": "^0.0.29",
@@ -44,6 +44,8 @@
4444
"ts-node": "^8.10.1"
4545
},
4646
"dependencies": {
47+
"@appsignal/nodejs": "^1.0.1",
48+
"@koa/router": "^9.4.0",
4749
"@sentry/node": "5.13.2",
4850
"acorn": "^5.1.2",
4951
"acorn-dynamic-import": "^2.0.2",
@@ -69,7 +71,6 @@
6971
"jszip": "^3.5.0",
7072
"koa": "^2.2.0",
7173
"koa-bodyparser": "^4.2.0",
72-
"koa-router": "^7.2.0",
7374
"lodash.pickby": "^4.6.0",
7475
"lru-cache": "^4.1.1",
7576
"node-fetch": "^1.7.3",

packages/git-extractor/src/index.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
import * as Sentry from "@sentry/node";
22
import * as Koa from "koa";
33
import * as bodyParser from "koa-bodyparser";
4-
import * as Router from "koa-router";
4+
import * as Router from "@koa/router";
55

66
import camelize from "./middleware/camelize";
77
import decamelize from "./middleware/decamelize";
88
import errorHandler from "./middleware/error-handler";
9+
import appSignalMiddleware from "./middleware/appsignal";
910
// MIDDLEWARE
1011
import logger from "./middleware/logger";
1112
import notFound from "./middleware/not-found";
1213
import * as define from "./routes/define";
1314
// ROUTES
1415
import * as github from "./routes/github";
16+
import { appsignal } from "./utils/appsignal";
1517
import log from "./utils/log";
1618

1719
Sentry.init({
@@ -28,6 +30,7 @@ app.use(bodyParser({ jsonLimit: "50mb" }));
2830
app.use(camelize);
2931
app.use(decamelize);
3032
app.use(notFound);
33+
app.use(appSignalMiddleware);
3134

3235
router
3336
.get(
@@ -55,7 +58,18 @@ app.use(router.routes()).use(router.allowedMethods());
5558
log(`Listening on ${DEFAULT_PORT}`);
5659
app.listen(DEFAULT_PORT);
5760

61+
console.log(
62+
JSON.stringify({
63+
message: `AppSignal ${appsignal.VERSION}, active: ${appsignal.isActive}`,
64+
})
65+
);
66+
5867
app.on("error", (err, ctx) => {
68+
const span = appsignal.tracer().currentSpan();
69+
if (span) {
70+
span.addError(err);
71+
}
72+
5973
Sentry.withScope(function (scope) {
6074
scope.addEventProcessor(function (event) {
6175
return Sentry.Handlers.parseRequest(event, ctx.request);

0 commit comments

Comments
 (0)