Skip to content

Commit

Permalink
Merge pull request #233 from DestinyItemManager/cloud-profile
Browse files Browse the repository at this point in the history
Install Google Cloud Profiler
  • Loading branch information
bhollis authored Oct 2, 2024
2 parents 4e7b48a + 7e57a66 commit 06ec7a6
Show file tree
Hide file tree
Showing 5 changed files with 806 additions and 43 deletions.
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
FROM node:20-alpine

# for node-gyp to install cloud profiler
RUN apk add python3 g++ make py-setuptools

ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
Expand Down
13 changes: 13 additions & 0 deletions api/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { createTerminus } from '@godaddy/terminus';
import profiler from '@google-cloud/profiler';
import * as Sentry from '@sentry/node';
import * as Tracing from '@sentry/tracing';
import express from 'express';
Expand Down Expand Up @@ -101,6 +102,18 @@ if (process.env.SENTRY_DSN) {
});
}

if (process.env.GCP_CREDENTIALS) {
await profiler.start({
projectId: 'statelycloud-prod',
serviceContext: {
service: 'dim',
version: process.env.COMMITHASH,
},
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
credentials: JSON.parse(process.env.GCP_CREDENTIALS),
});
}

const server = http.createServer(app);

function beforeShutdown() {
Expand Down
5 changes: 5 additions & 0 deletions kubernetes/dim-api-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ spec:
secretKeyRef:
name: dim-api-secret
key: stately_client_secret
- name: GCP_CREDENTIALS
valueFrom:
secretKeyRef:
name: gcp-credentials
key: gcp_credentials
envFrom:
- configMapRef:
name: dim-api-config
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
"dependencies": {
"@bufbuild/protobuf": "^2.1.0",
"@godaddy/terminus": "^4.12.1",
"@google-cloud/profiler": "^6.0.2",
"@sentry/node": "^7.119.0",
"@sentry/tracing": "^7.114.0",
"@stately-cloud/client": "^0.5.0",
Expand Down
Loading

0 comments on commit 06ec7a6

Please sign in to comment.