-
Notifications
You must be signed in to change notification settings - Fork 19
[TRAIN-3456] Add healthchecks. Add functionality to Makefile. #122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
briannadelvalle-datadog
wants to merge
41
commits into
main
Choose a base branch
from
TRAIN-3546-Update-Storedog
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+2,021
−719
Draft
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 e4134a8
Enhance Makefile with prepare-release target and improve help documen…
briannadelvalle-datadog a6b1bf3
add healthchecks to docker compose.dev
briannadelvalle-datadog f6a8fde
Update Dockerfile to change command for starting Rails server to use …
briannadelvalle-datadog d4b6dea
Add .gradle/ and settings.json to .gitignore
briannadelvalle-datadog 09e31a5
Refine regex pattern for service build replacement and add cleanup fu…
briannadelvalle-datadog 39affb1
Update docker-compose.yml
briannadelvalle-datadog 5db6be7
Use dev and prod Dockerfiles for frontend service, use standalone out…
briannadelvalle-datadog f27ce66
Add basic dev env template for faster setup
briannadelvalle-datadog 5d779b7
Update frontend dependencies
briannadelvalle-datadog ea08f34
rename frontend Dockerfile
briannadelvalle-datadog 7828c9c
Update frontend README with info about different Dockerfiles
briannadelvalle-datadog 5c37db8
Use build targets instead for frontend
briannadelvalle-datadog a25a20b
Add frontend build target to env template for development testing of …
briannadelvalle-datadog 1757a79
Enhance frontend service configuration by adding dockerfile, build ta…
briannadelvalle-datadog 5d171ff
Add Dockerfile for frontend service with multi-stage builds for devel…
briannadelvalle-datadog 154cd1a
Refactor Makefile to streamline environment handling by introducing a…
briannadelvalle-datadog 1aa9648
Update docker-compose files to include build target and environment v…
briannadelvalle-datadog 9d74142
Merge remote-tracking branch 'origin' into TRAIN-3546-Update-Storedog
briannadelvalle-datadog 77ca5d3
Update default values of development stage variables
briannadelvalle-datadog c4bd25d
Clarify some comments in env.template
briannadelvalle-datadog 6225944
Add or update readmes for services
briannadelvalle-datadog 923bf2f
Update env templates
briannadelvalle-datadog 666d8c7
Update docker-compose.dev.yml to replace RUM environment variables wi…
briannadelvalle-datadog 6935f1a
Move features info to separate .md file
briannadelvalle-datadog 3dc049e
Update Makefile to support no-cache builds and change default environ…
briannadelvalle-datadog 54d38b2
Update readme. Move service specific stuff to service readmes, move e…
briannadelvalle-datadog 3c610bd
Update README to include a blank line for improved readability
briannadelvalle-datadog 795cca3
Remove some console.logs
briannadelvalle-datadog 40e275e
Refactor Dockerfile to replace RUM environment variables with NEXT_PU…
briannadelvalle-datadog c4d6664
Update test_transform_compose.py to replace RUM environment variables…
briannadelvalle-datadog 124d848
Adjust frontend Dockerfile to match vercel example
briannadelvalle-datadog 0c37cee
Frontend command var made obsolete by build targets and multistage Do…
briannadelvalle-datadog 68e2984
Add unit tests for frontend and compose transformation scripts
briannadelvalle-datadog 1fe98d0
Improve makefile
briannadelvalle-datadog 7d4aca1
Update dockerfiles
briannadelvalle-datadog 5e305e9
Update .gitignore
briannadelvalle-datadog 14961cd
Update some documentation
briannadelvalle-datadog 74a4c26
Remove variable that's no longer needed
briannadelvalle-datadog 7768d16
Align frontend variables, don't use args in docker compose
briannadelvalle-datadog e62336c
Refactor environment variable handling in Docker Compose files to use…
briannadelvalle-datadog File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,3 +52,11 @@ yarn-debug.log* | |
.env.test.local | ||
.env.production.local | ||
.env.local | ||
|
||
|
||
.gradle/ | ||
Gemfile.lock | ||
|
||
settings.json | ||
|
||
docker-compose.dev.frontend-prod.yml | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Was this last one left here on purpose? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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`. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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
, andGemfile.lock