Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
4bf5895
Remove wait-for-it, add healthchecks. Add functionality to Makefile.
briannadelvalle-datadog Oct 6, 2025
e4134a8
Enhance Makefile with prepare-release target and improve help documen…
briannadelvalle-datadog Oct 16, 2025
a6b1bf3
add healthchecks to docker compose.dev
briannadelvalle-datadog Oct 16, 2025
f6a8fde
Update Dockerfile to change command for starting Rails server to use …
briannadelvalle-datadog Oct 16, 2025
d4b6dea
Add .gradle/ and settings.json to .gitignore
briannadelvalle-datadog Oct 16, 2025
09e31a5
Refine regex pattern for service build replacement and add cleanup fu…
briannadelvalle-datadog Oct 16, 2025
39affb1
Update docker-compose.yml
briannadelvalle-datadog Oct 16, 2025
5db6be7
Use dev and prod Dockerfiles for frontend service, use standalone out…
briannadelvalle-datadog Oct 20, 2025
f27ce66
Add basic dev env template for faster setup
briannadelvalle-datadog Oct 20, 2025
5d779b7
Update frontend dependencies
briannadelvalle-datadog Oct 20, 2025
ea08f34
rename frontend Dockerfile
briannadelvalle-datadog Oct 20, 2025
7828c9c
Update frontend README with info about different Dockerfiles
briannadelvalle-datadog Oct 20, 2025
5c37db8
Use build targets instead for frontend
briannadelvalle-datadog Oct 20, 2025
a25a20b
Add frontend build target to env template for development testing of …
briannadelvalle-datadog Oct 20, 2025
1757a79
Enhance frontend service configuration by adding dockerfile, build ta…
briannadelvalle-datadog Oct 20, 2025
5d171ff
Add Dockerfile for frontend service with multi-stage builds for devel…
briannadelvalle-datadog Oct 20, 2025
154cd1a
Refactor Makefile to streamline environment handling by introducing a…
briannadelvalle-datadog Oct 20, 2025
1aa9648
Update docker-compose files to include build target and environment v…
briannadelvalle-datadog Oct 20, 2025
9d74142
Merge remote-tracking branch 'origin' into TRAIN-3546-Update-Storedog
briannadelvalle-datadog Oct 20, 2025
77ca5d3
Update default values of development stage variables
briannadelvalle-datadog Oct 20, 2025
c4bd25d
Clarify some comments in env.template
briannadelvalle-datadog Oct 20, 2025
6225944
Add or update readmes for services
briannadelvalle-datadog Oct 20, 2025
923bf2f
Update env templates
briannadelvalle-datadog Oct 20, 2025
666d8c7
Update docker-compose.dev.yml to replace RUM environment variables wi…
briannadelvalle-datadog Oct 20, 2025
6935f1a
Move features info to separate .md file
briannadelvalle-datadog Oct 20, 2025
3dc049e
Update Makefile to support no-cache builds and change default environ…
briannadelvalle-datadog Oct 20, 2025
54d38b2
Update readme. Move service specific stuff to service readmes, move e…
briannadelvalle-datadog Oct 20, 2025
3c610bd
Update README to include a blank line for improved readability
briannadelvalle-datadog Oct 20, 2025
795cca3
Remove some console.logs
briannadelvalle-datadog Oct 20, 2025
40e275e
Refactor Dockerfile to replace RUM environment variables with NEXT_PU…
briannadelvalle-datadog Oct 20, 2025
c4d6664
Update test_transform_compose.py to replace RUM environment variables…
briannadelvalle-datadog Oct 20, 2025
124d848
Adjust frontend Dockerfile to match vercel example
briannadelvalle-datadog Oct 21, 2025
0c37cee
Frontend command var made obsolete by build targets and multistage Do…
briannadelvalle-datadog Oct 21, 2025
68e2984
Add unit tests for frontend and compose transformation scripts
briannadelvalle-datadog Oct 21, 2025
1fe98d0
Improve makefile
briannadelvalle-datadog Oct 21, 2025
7d4aca1
Update dockerfiles
briannadelvalle-datadog Oct 21, 2025
5e305e9
Update .gitignore
briannadelvalle-datadog Oct 21, 2025
14961cd
Update some documentation
briannadelvalle-datadog Oct 21, 2025
74a4c26
Remove variable that's no longer needed
briannadelvalle-datadog Oct 21, 2025
7768d16
Align frontend variables, don't use args in docker compose
briannadelvalle-datadog Oct 21, 2025
e62336c
Refactor environment variable handling in Docker Compose files to use…
briannadelvalle-datadog Oct 21, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .env.development.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# For local development, set these manually using a trial or dogfood account

DD_API_KEY=
DD_APP_KEY=
NEXT_PUBLIC_DD_APPLICATION_ID= # Only needed if using RUM
NEXT_PUBLIC_CLIENT_TOKEN= # Only needed if using RUM
37 changes: 29 additions & 8 deletions .env.template
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,23 @@ NEXT_PUBLIC_DD_CLIENT_TOKEN= # Required for RUM in frontend service
# =============================================
DD_ENV=development # usually set to some form of identifier of what the course/lab is (such as `dd101-sre`)
DD_HOSTNAME=development-host # usually set to the DD_ENV with `-host` appended
NEXT_PUBLIC_DD_ENV=development # Required for RUM in frontend service
NEXT_PUBLIC_DD_SITE=datadoghq.com # Required for RUM in frontend service

DD_LOGS_INJECTION=true #Enable log injection into traces. Some languages' trace libraries turn this on by default, but we turn it on explicitly to prevent confusion.
DD_PROFILING_ENABLED=true #Enable the Continuous Profiler
DD_RUNTIME_METRICS_ENABLED=true #Enable runtime metrics

# =============================================
# Service Versions
# Follow Storedog releases except Redis (https://github.com/DataDog/storedog/releases)
# The Agent uses these values to set the `version:` tag for each service.
# The postgres and redis services come from the actual postgres/redis version.
# =============================================
#
# If you're re-deploying a service in a lab, it may be helpful for you/the learner to update the version number.

NEXT_PUBLIC_DD_VERSION_FRONTEND=1.0.0 # use NEXT_PUBLIC_* to expose var to store frontend
DD_VERSION_BACKEND=1.0.0 # Use for worker service as well, since they use the same Docker image
DD_VERSION_DBM=1.0.0
DD_VERSION_ADS=1.0.0
DD_VERSION_ADS_PYTHON=1.0.0
DD_VERSION_DISCOUNTS=1.0.0
DD_VERSION_POSTGRES=15.0
DD_VERSION_NGINX=1.28.0
Expand All @@ -40,22 +45,35 @@ DB_POOL=25 # Database connection pool size set in backend service (default: 25)
MAX_THREADS=5 # Maximum number of concurrent threads set in backend service (default: 5)

# =============================================
# Nginx/Service Proxy Configuration
# A/B testing Ads services
# =============================================

# ads-python service

DD_VERSION_ADS_PYTHON=1.0.0

# Nginx/Service Proxy Configuration

ADS_A_UPSTREAM=ads:3030
ADS_B_UPSTREAM=ads-python:3030
ADS_B_PERCENT=0 # Set < 0 > 100 to split traffic between ads services

# =============================================
# Frontend Service Configuration
# =============================================
FRONTEND_COMMAND='npm run dev' # Command to run the frontend service (default: 'npm run dev', use 'npm run prod' for production)
NEXT_PUBLIC_DD_SERVICE_FRONTEND=store-frontend # Service name for frontend service in Datadog

NEXT_PUBLIC_DD_SERVICE_FRONTEND=store-frontend # RUM SDK uses this to set the `service:` tag for RUM data
NEXT_PUBLIC_DD_SITE=datadoghq.com # Datadog site. Used in RUM SDK init()
NEXT_PUBLIC_DD_ENV=development # Required for RUM SDK

NEXT_PUBLIC_FRONTEND_API_ROUTE=http://service-proxy:80 # base url for next.js API routes (default: 'http://service-proxy:80')
NEXT_PUBLIC_SPREE_API_HOST=http://service-proxy/services/backend # base url for backend service (default: 'http://service-proxy/services/backend')

# The values without the `http://service-proxy` prefix are used in the frontend service's `fetch` calls, which are made from the browser and are caught by the nginx service, because it intercepts calls to Next.js API routes and routes them to the appropriate service.

NEXT_PUBLIC_SPREE_CLIENT_HOST=/services/backend # base url for backend service (default: '/services/backend')
NEXT_PUBLIC_SPREE_IMAGE_HOST=/services/backend # base url for backend service (default: '/services/backend')
NEXT_PUBLIC_SPREE_ALLOWED_IMAGE_DOMAIN=service-proxy # allowed image domain for backend service (default: 'service-proxy')
NEXT_PUBLIC_SPREE_ALLOWED_IMAGE_DOMAIN=service-proxy # allowed image domain (default: 'service-proxy')
NEXT_PUBLIC_ADS_ROUTE=/services/ads # base url for ads service (default: '/services/ads')
NEXT_PUBLIC_DISCOUNTS_ROUTE=/services/discounts # base url for discounts service (default: '/services/discounts')
NEXT_PUBLIC_DBM_ROUTE=/services/dbm # base url for dbm service (default: '/services/dbm')
Expand All @@ -71,6 +89,9 @@ DISABLE_SPRING=1
# Puppeteer Configuration
# =============================================
STOREDOG_URL=http://service-proxy:80 # base url for storedog service (default: 'http://service-proxy:80')

# In a lab environment, use the lab host's URL instead of service-proxy. See a template course for an example.

PUPPETEER_TIMEOUT=30000 # timeout for puppeteer (default: 30000)

SKIP_SESSION_CLOSE= # skip session close for puppeteer (default: ''). Note that the current puppeteer script doesn't make use of this environment variable but can easily be updated to do so
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,11 @@ yarn-debug.log*
.env.test.local
.env.production.local
.env.local


.gradle/
Gemfile.lock
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You remove Gemfile.lock but since it's already been checked-in, it won't retroactively ignore it. Need to either delete the file (this is fine, because the docker image sets it up anyway) or reset the git cache so the .gitignore gets adhered to.

Also, I think to avoid this in the future, we should probably create/update a .dockerignore file that has node_modules, .git, and Gemfile.lock


settings.json

docker-compose.dev.frontend-prod.yml
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this last one left here on purpose?

168 changes: 168 additions & 0 deletions FEATURES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@

# Optional Features

This doc covers the different features you can enable in Storedog.

Click on a feature below to learn more.

- [A/B Testing Ads services](#ab-testing-ads-services)
- [With Docker Compose](#with-docker-compose)
- [With Kubernetes](#with-kubernetes)
- [Feature flags](#feature-flags)
- [DBM](#dbm)
- [Error Tracking](#error-tracking)
- [Random frontend API errors](#random-frontend-api-errors)
- [Frustration Signals in RUM](#frustration-signals-in-rum)

## A/B Testing Ads services

Run two Ads services and split traffic between them. The amount of traffic sent to each service is set with a percent value.

This requires running a second Ads service in addition to the default Java Ads service and setting environment variables in the `service-proxy` service. The Python Ads service is typically used as the secondary service.

### With Docker Compose

1. Set the following environment variables:

- `DD_VERSION_ADS_PYTHON`: The version number that the Datadog Agent uses to tag the `ads-python` service.
- `ADS_A_UPSTREAM`: Host and port for the primary (A) ads service (default: `ads:3030`)
- `ADS_B_UPSTREAM`: Host and port for the secondary (B) ads service (default: `ads-python:3030`)
- `ADS_B_PERCENT`: Percentage of traffic to route to the B (Python) ads service (default: `0`). The remainder goes to the A ads (Java) service.
- Set a value between `0` and `100` to control the split.

> [!IMPORTANT]
>
> When `ADS_B_PERCENT` is greater than zero, the `ADS_B_UPSTREAM` endpoint must be reachable. Otherwise, the `service-proxy` will crash and restart.

1. Add a second Ads service to the `docker-compose.yml` or `docker-compose.dev.yml`.

```yaml
ads-python:
image: ghcr.io/datadog/storedog/ads-python:${STOREDOG_IMAGE_VERSION:-latest}
build: # Only used if building from source in development
context: ./services/ads/python
depends_on:
- postgres
- dd-agent
environment:
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-postgres}
- POSTGRES_USER=${POSTGRES_USER:-postgres}
- POSTGRES_HOST=postgres
- DD_AGENT_HOST=dd-agent
- DD_ENV=${DD_ENV:-production}
- DD_SERVICE=store-ads-python
- DD_VERSION=${DD_VERSION_ADS_PYTHON:-1.0.0}
- DD_PROFILING_ENABLED=true
- DD_PROFILING_TIMELINE_ENABLED=true
- DD_PROFILING_ALLOCATION_ENABLED=true
volumes: # Only used in development
- ./services/ads/python:/app
networks:
- storedog-network
labels:
com.datadoghq.ad.logs: '[{"source": "python"}]'
```

1. Add these environment variables to the `service-proxy` service in the `docker-compose.yml` (or `docker-compose.dev.yml`) file:

```yaml
environment:
- ADS_A_UPSTREAM=${ADS_A_UPSTREAM:-ads:3030}
- ADS_B_UPSTREAM=${ADS_B_UPSTREAM:-ads-python:3030}
- ADS_B_PERCENT=${ADS_B_PERCENT:-0}
```

1. Start the app via `make dev` or `make prod`.

### With Kubernetes

A Kubernetes manifest for the Python Ads service is available in the `services/ads/k8s-manifests/` directory.

1. Add the `ads-python.yaml` file to the `k8s-manifests/storedog-app/deployments/` directory.

1. Add the following environment variables to the `nginx.yaml` file and adjust as needed:

```yaml
# A/B testing ads services
- name: ADS_A_UPSTREAM
value: "ads:3030"
- name: ADS_B_UPSTREAM
value: "ads-python:3030"
- name: ADS_B_PERCENT
value: "50"
```

1. Follow the instructions in the [Kubernetes README](./k8s-manifests/README.md) to run Storedog in Kubernetes.

1. If the Storedog is already running, apply the manifests to the cluster:

```bash
envsubst < k8s-manifests/storedog-app/deployments/ads-python.yaml | kubectl apply -n storedog -f -
envsubst < k8s-manifests/storedog-app/deployments/nginx.yaml | kubectl apply -n storedog -f -
```

> [!IMPORTANT]
> Be sure to set the `DD_VERSION_ADS_PYTHON` environment variable so that it will be applied to the file by `envsubst`.

## Feature flags

Some capabilities are hidden behind feature flags, which can be controlled via `services/frontend/site/featureFlags.config.json`.

> [!NOTE]
> Feature flags are available by default when running the application in development mode. If running in production, you'll need update the file and mount it into the frontend service container in the `docker-compose.yml` file.
>
> ```yaml
> volumes:
> - ./services/frontend/site/featureFlags.config.json:/app/featureFlags.config.json
> ```

### DBM

The `dbm` feature flag enables a product ticker on the homepage with a long-running query to demonstrate DBM.

**How to use**:

1. First, set up the DBM service as described in the [DBM README](./services/dbm/README.md)
1. Start the app via `docker compose up`
1. Set the `dbm` feature flag to true
1. Visit http://localhost and reload the home page a few times
1. The ticker will appear after 5 seconds and will subsequently update every 5 seconds with a new product and amount ordered

You can modify the ticker functionality in `services/frontend/components/common/NavBar.tsx`.

### Error Tracking

The `error-tracking` feature flag demonstrates Error Tracking. When enabled, the `ads` service experiences exceptions due to unexpected header values.

**How to use**:

1. Start the app via `docker compose up`
1. Set the `error-tracking` feature flag to `true`
1. Visit `http://localhost` and reload the home page a few times
1. 500 errors are generated in the logs, and banner ads don't load on the homepage

Modify this functionality in `services/frontend/components/common/Ad/Ad.tsx` and respective Ads service being used.

### Random frontend API errors

The `api-errors` feature flag introduces random errors that occur in the frontend service's `/api` routes.

**How to use**:

1. Start the app via `docker compose up`
1. Set the `api-errors` feature flag to `true`
1. Visit `http://localhost` and reload the home page a few times, footer links will randomly return 400s and 500s.

Modify this functionality in `services/frontend/pages/api/*`.

### Frustration Signals in RUM

The `product-card-frustration` feature flag swaps out the product card component with a version that doesn't have the thumbnails linked to the product page. When paired with the Puppeteer service, this can be used to demonstrate Frustration Signals in RUM.

**How to use**:

1. Start the app via `docker compose up`
1. Set the `product-card-frustration` feature flag to `true`
1. Visit `http://localhost/products` and try clicking on the product thumbnails to see the frustration signal in action.

Modify this functionality in `services/frontend/components/Product/ProductCard.tsx` and `services/frontend/components/Product/ProductCard-v2.tsx`.
Loading