Skip to content

Commit 612a258

Browse files
committed
Merge branch 'main' of github.com:newrelic/relibank into ftr/chaos-mesh
2 parents d236516 + 8627d91 commit 612a258

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+2257
-434
lines changed

.env-example

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
OPENAI_LOG=info
2+
OPENAI_API_KEY=key
3+
BASE_URL=openai_url
4+
NEW_RELIC_API_KEY=NEW_RELIC_USER_API_KEY
5+
NEW_RELIC_ACCOUNT_ID=NEW_RELIC_ACCOUNT_ID
6+
NEW_RELIC_LICENSE_KEY=NEW_RELIC_LICENSE_KEY
7+
APP_NAME=your_name

.gitignore

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,15 @@ act-secrets.env
55
**/.DS_Store
66
**/keys.txt
77
**/*.log*
8-
*.env
8+
__pycache__/
9+
*.pyc
10+
.venv/
11+
env/
12+
venv/
13+
.env
14+
*.tar
15+
*.log
16+
.vscode/
17+
*.cache
18+
model/
19+
todos.md

README.md

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,27 @@
22

33
A microservices banking application built for chaos engineering and resilience testing.
44

5-
## TODOs
5+
---
66

7-
DB interface python with endpoints for auth service
8-
DONE placeholder for posts/puts, so we can implement adding new accounts later
7+
### ⚙️ Test connection to New Relic
98

10-
DONE In Transactions, add a DB table that stores outstanding balance on a loan/credit account, amount on a checking/savings account
11-
Add Transaction types:
12-
shopping | credit_card | loan | entertainment | utilities | groceries | gas | etc
9+
1. Connect to the service's container, docker example `docker exec -it bill-pay /bin/sh`
1310

14-
DONE In Bill Pay, add from/to account
15-
DONE Enforce uniqueness on BillIDs
16-
Check that to/fromaccount is valid, check balance on each before initiating payment or cancel if it's impossible
11+
2. newrelic-admin validate-config LOCATION_OF_NEWRELIC.INI
1712

18-
In Accounts, add an account for Relibank that will handle all loan payments. Build out loan payments in the code
13+
3. If needed, add a logfile to newrelic.ini
14+
```[newrelic]
15+
log_file = /app/newrelic.log
16+
log_level = info
17+
```
18+
19+
4. Validate logs with ```docker exec -it bill-pay cat newrelic-agent.log```
20+
21+
---
22+
23+
### ⚙️ Formatting
1924

20-
Convert logging.info calls to json instead of flat logs
25+
1. ```ruff format``` https://docs.astral.sh/ruff/formatter/#ruff-format
2126

2227
## What is this?
2328

accounts_service/Dockerfile

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,34 @@ FROM python:3.12-slim
44
# Set the working directory in the container
55
WORKDIR /app
66

7+
ARG NEW_RELIC_APP_NAME="${APP_NAME} - Accounts Service"
8+
ENV NEW_RELIC_APP_NAME=$NEW_RELIC_APP_NAME
9+
10+
ARG NEW_RELIC_USER_API_KEY
11+
ENV NEW_RELIC_API_KEY=$NEW_RELIC_USER_API_KEY
12+
13+
ARG NEW_RELIC_ACCOUNT_ID
14+
ENV NEW_RELIC_ACCOUNT_ID=$NEW_RELIC_ACCOUNT_ID
15+
16+
ARG NEW_RELIC_LICENSE_KEY
17+
ENV NEW_RELIC_LICENSE_KEY=$NEW_RELIC_LICENSE_KEY
18+
19+
ENV NEW_RELIC_DISTRIBUTED_TRACING_ENABLED=true
20+
721
# Install build dependencies required for psycopg2-binary
822
RUN apt-get update && apt-get install -y --no-install-recommends \
923
libpq-dev \
1024
gcc
1125

12-
# Copy the requirements file into the container
13-
COPY requirements.txt .
26+
# Copy the application code file
27+
COPY . .
1428

1529
# Install Python dependencies
16-
RUN pip install --no-cache-dir -r requirements.txt
17-
18-
# Copy the application code file
19-
COPY accounts_service.py .
30+
# RUN pip install --no-cache-dir -r requirements.txt
31+
RUN pip install uv && uv sync
2032

2133
# Expose the port the FastAPI app will run on
2234
EXPOSE 5000
2335

2436
# Command to run the application using Uvicorn
25-
CMD ["uvicorn", "accounts_service:app", "--host", "0.0.0.0", "--port", "5000", "--workers", "1"]
37+
CMD ["uv", "run", "newrelic-admin", "run-program", "uvicorn", "accounts_service:app", "--host", "0.0.0.0", "--port", "5000", "--workers", "1", "--log-config", "logging.conf"]

0 commit comments

Comments
 (0)