Skip to content

Commit f9bcecb

Browse files
committed
config for staging/prod traces in langsmith
1 parent cbd0de1 commit f9bcecb

4 files changed

Lines changed: 18 additions & 3 deletions

File tree

.github/workflows/deploy.production.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ jobs:
109109
GOOGLE_CLOUD_LOCATION=${{vars.GOOGLE_CLOUD_LOCATION}}
110110
VERTEX_AI_DATASTORE=${{vars.VERTEX_AI_DATASTORE}}
111111
SHOW_MODEL_THINKING=false
112+
LANGSMITH_API_KEY=${{ secrets.LANGSMITH_API_KEY }}
113+
LANGSMITH_TRACING=true
114+
LANGCHAIN_TRACING_V2=true
115+
LANGSMITH_PROJECT=${{ vars.LANGSMITH_PROJECT }}
112116
GOOGLE_APPLICATION_CREDENTIALS=/etc/tenantfirstaid/google-service-account.json
113117
EOF
114118
chmod 640 /etc/tenantfirstaid/env

.github/workflows/deploy.staging.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ jobs:
107107
GOOGLE_CLOUD_LOCATION=${{vars.GOOGLE_CLOUD_LOCATION}}
108108
VERTEX_AI_DATASTORE=${{vars.VERTEX_AI_DATASTORE}}
109109
SHOW_MODEL_THINKING=${{vars.SHOW_MODEL_THINKING}}
110+
LANGSMITH_API_KEY=${{ secrets.LANGSMITH_API_KEY }}
111+
LANGSMITH_TRACING=true
112+
LANGCHAIN_TRACING_V2=true
113+
LANGSMITH_PROJECT=${{ vars.LANGSMITH_PROJECT }}
110114
GOOGLE_APPLICATION_CREDENTIALS=/etc/tenantfirstaid/google-service-account.json
111115
EOF
112116
chmod 640 /etc/tenantfirstaid/env

Deployment.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ Secrets exist in two places:
247247
| `DB_PASSWORD` | ⚠️ Database password — **not read by any current application code** | [deploy.production.yml](.github/workflows/deploy.production.yml) (env file only) |
248248
| `APP_PASSWORD` | SMTP app-specific password for sending feedback emails | [deploy.production.yml](.github/workflows/deploy.production.yml), [backend/tenantfirstaid/app.py](backend/tenantfirstaid/app.py) |
249249
| `SSH_USER` | SSH username on the droplet (staging environment only — stored as a secret there) | [deploy.staging.yml](.github/workflows/deploy.staging.yml) |
250+
| `LANGSMITH_API_KEY` | LangSmith API key for LLM trace collection (quality-control review of live conversations) | [deploy.production.yml](.github/workflows/deploy.production.yml), [deploy.staging.yml](.github/workflows/deploy.staging.yml) |
250251

251252
### GitHub Actions variables (non-sensitive)
252253

@@ -269,6 +270,7 @@ Secrets exist in two places:
269270
| `GOOGLE_CLOUD_LOCATION` | GCP region (e.g. `global`) | [deploy.production.yml](.github/workflows/deploy.production.yml), [backend/tenantfirstaid/constants.py](backend/tenantfirstaid/constants.py) |
270271
| `VERTEX_AI_DATASTORE` | Vertex AI RAG corpus identifier | [deploy.production.yml](.github/workflows/deploy.production.yml), [backend/tenantfirstaid/constants.py](backend/tenantfirstaid/constants.py) |
271272
| `SHOW_MODEL_THINKING` | Toggle Gemini reasoning display (staging only; hardcoded `false` in production) | [deploy.staging.yml](.github/workflows/deploy.staging.yml), [backend/tenantfirstaid/constants.py](backend/tenantfirstaid/constants.py) |
273+
| `LANGSMITH_PROJECT` | LangSmith project name that groups traces in the UI (e.g. `tenantfirstaid-prod`, `tenantfirstaid-staging`) | [deploy.production.yml](.github/workflows/deploy.production.yml), [deploy.staging.yml](.github/workflows/deploy.staging.yml) |
272274

273275
### Local development
274276

@@ -559,11 +561,15 @@ The production Gunicorn service is instrumented with DataDog for log collection
559561

560562
The DataDog agent and its API key are configured directly on the server by a server admin and are not stored in this repository or the CI pipeline.
561563

562-
### LangSmith (LLM traces — development / CI only)
564+
### LangSmith (LLM traces — production, staging, development)
563565

564-
[LangSmith](https://smith.langchain.com/) can optionally trace LLM calls for debugging and evaluation when a `LANGSMITH_API_KEY` is set. See `backend/.env.example` for the relevant variables. LangSmith tracing is **not** enabled in the production deployment.
566+
[LangSmith](https://smith.langchain.com/) traces every LLM call made by the live chatbot for ongoing quality-control review of user conversations. Tracing is enabled in **production and staging** as well as local development; the on/off switch is the presence of a `LANGSMITH_API_KEY` env var plus the `LANGSMITH_TRACING=true` / `LANGCHAIN_TRACING_V2=true` flags (see [`backend/.env.example`](backend/.env.example)).
565567

566-
For running evaluations, see [`backend/evaluate/EVALUATION.md`](backend/evaluate/EVALUATION.md).
568+
Traces are grouped in the LangSmith UI by the `LANGSMITH_PROJECT` variable — typically `tenantfirstaid-prod` vs `tenantfirstaid-staging` — so production and staging traffic are viewable separately.
569+
570+
> **Privacy note**: trace content includes user-submitted chat messages, which may contain sensitive housing/legal details. Access to the LangSmith project is therefore limited to maintainers with a documented quality-control need. See [Permissions](#permissions) for how to request access.
571+
572+
For running offline evaluations against a dataset, see [`backend/evaluate/EVALUATION.md`](backend/evaluate/EVALUATION.md).
567573

568574
### Future plans
569575

backend/.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ VERTEX_AI_DATASTORE=<DATASTORE_ID>
2222
LANGSMITH_API_KEY=lsv2_pt_some-example-key_XXXXXXXXXXXXXXXXXXXXXX
2323
LANGSMITH_TRACING=true
2424
LANGCHAIN_TRACING_V2=true # Enable detailed tracing
25+
LANGSMITH_PROJECT=tenantfirstaid-dev # Project name that groups traces in the LangSmith UI
2526

2627
# SMTP setup
2728
#MAIL_SERVER="smtp.service.com"

0 commit comments

Comments
 (0)