Environment Variables Setup for Observability
This document outlines the environment variables that need to be configured in each environment (development, staging, production) for the observability implementation to work correctly.
Overview
Section titled “Overview”The observability implementation requires configuration for:
- OpenTelemetry OTLP Exporter - For sending traces to Better Stack
- Dagster OpenTelemetry - For Dagster pipeline observability
- Webapp / Temporal → Dagster Integration (optional) - For programmatic Dagster job triggering
Required Variables by Service
Section titled “Required Variables by Service”1. Shared OpenTelemetry Configuration (All Services)
Section titled “1. Shared OpenTelemetry Configuration (All Services)”These variables should be set in the root .env file or in docker-compose.yml:
# OpenTelemetry OTLP Configuration (Better Stack)OTEL_EXPORTER_OTLP_ENDPOINT=https://in-otel.betterstack.comOTEL_EXPORTER_OTLP_HEADERS=Authorization=Bearer YOUR_BETTER_STACK_TOKENOTEL_EXPORTER_OTLP_TRACES_ENDPOINT=https://in-otel.betterstack.comOTEL_EXPORTER_OTLP_LOGS_ENDPOINT=https://in-otel.betterstack.com/v1/logsOTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf
# Service Identification (per-service)OTEL_SERVICE_NAME=webapp # or temporal-worker, dagster, pdf-api, pdf-worker, email-apiOTEL_SERVICE_VERSION=1.0.0OTEL_DEPLOYMENT_ENVIRONMENT=development # or staging, productionNote: These are already configured if you’re using the existing observability setup. Verify they’re present in your environment.
2. Dagster-Specific Configuration
Section titled “2. Dagster-Specific Configuration”Dagster needs these variables to send traces to Better Stack. Add them to apps/dagster/.env or your Dagster deployment environment:
# OpenTelemetry for DagsterOTEL_EXPORTER_OTLP_ENDPOINT=https://in-otel.betterstack.comOTEL_EXPORTER_OTLP_HEADERS=api-key=YOUR_BETTER_STACK_TOKEN# OR (Better Stack format)OTEL_EXPORTER_OTLP_HEADERS=Authorization=Bearer YOUR_BETTER_STACK_TOKEN
# Optional: Service identificationOTEL_SERVICE_NAME=dagsterOTEL_SERVICE_VERSION=1.0.0Important:
- Dagster’s
observability.pyreadsOTEL_EXPORTER_OTLP_ENDPOINTandOTEL_EXPORTER_OTLP_HEADERS - If
OTEL_EXPORTER_OTLP_HEADERScontainsapi-key=, it extracts just the token - Otherwise, it uses the entire value as the API key
- If these variables are not set, Dagster will skip OpenTelemetry initialization (graceful degradation)
3. Webapp / Temporal → Dagster Integration (Optional)
Section titled “3. Webapp / Temporal → Dagster Integration (Optional)”If you want to trigger Dagster jobs programmatically from the webapp or Temporal worker, add these to the relevant service environment:
# Dagster Cloud API (for programmatic job triggering)DAGSTER_CLOUD_URL=https://your-org.dagster.cloudDAGSTER_CLOUD_API_TOKEN=your_dagster_api_tokenENABLE_DAGSTER_SYNC=trueNote: This is optional. Correlation ID propagation still works even without direct Dagster job triggering.
Environment-Specific Configuration
Section titled “Environment-Specific Configuration”Development
Section titled “Development”# Root .env or docker-compose.ymlOTEL_EXPORTER_OTLP_ENDPOINT=https://in-otel.betterstack.comOTEL_EXPORTER_OTLP_HEADERS=Authorization=Bearer YOUR_DEV_TOKENOTEL_EXPORTER_OTLP_TRACES_ENDPOINT=https://in-otel.betterstack.comOTEL_EXPORTER_OTLP_LOGS_ENDPOINT=https://in-otel.betterstack.com/v1/logsOTEL_EXPORTER_OTLP_PROTOCOL=http/protobufOTEL_DEPLOYMENT_ENVIRONMENT=development
# Per-service (in docker-compose.yml or service .env)# WebappOTEL_SERVICE_NAME=webappOTEL_SERVICE_VERSION=1.0.0
# DagsterOTEL_SERVICE_NAME=dagsterOTEL_SERVICE_VERSION=1.0.0OTEL_EXPORTER_OTLP_ENDPOINT=https://in-otel.betterstack.comOTEL_EXPORTER_OTLP_HEADERS=Authorization=Bearer YOUR_DEV_TOKENStaging
Section titled “Staging”# Same as development but with staging tokenOTEL_EXPORTER_OTLP_HEADERS=Authorization=Bearer YOUR_STAGING_TOKENOTEL_DEPLOYMENT_ENVIRONMENT=stagingProduction
Section titled “Production”# Same structure but with production tokenOTEL_EXPORTER_OTLP_HEADERS=Authorization=Bearer YOUR_PRODUCTION_TOKENOTEL_DEPLOYMENT_ENVIRONMENT=productionDocker Compose Configuration
Section titled “Docker Compose Configuration”Development (docker-compose.yml)
Section titled “Development (docker-compose.yml)”Dagster already has OTEL variables configured (lines 250-254), but they default to empty if not set in .env:
dagster: environment: # OpenTelemetry (optional) - OTEL_SERVICE_NAME=dagster - OTEL_SERVICE_VERSION=1.0.0 - OTEL_DEPLOYMENT_ENVIRONMENT=development - OTEL_EXPORTER_OTLP_ENDPOINT=${OTEL_EXPORTER_OTLP_ENDPOINT:-} - OTEL_EXPORTER_OTLP_HEADERS=${OTEL_EXPORTER_OTLP_HEADERS:-}Action Required: Ensure these variables are set in your root .env file:
OTEL_EXPORTER_OTLP_ENDPOINT=https://in-otel.betterstack.comOTEL_EXPORTER_OTLP_HEADERS=Authorization=Bearer YOUR_BETTER_STACK_TOKENProduction (docker-compose.prod.yml)
Section titled “Production (docker-compose.prod.yml)”Status: Both dagster-web and dagster-code-server already have OTEL variables configured:
dagster-web(lines 380-384)dagster-code-server(lines 293-296)
Action Required:
Ensure OTEL_EXPORTER_OTLP_ENDPOINT and OTEL_EXPORTER_OTLP_HEADERS are set in your production .env file:
OTEL_EXPORTER_OTLP_ENDPOINT=https://in-otel.betterstack.comOTEL_EXPORTER_OTLP_HEADERS=Authorization=Bearer YOUR_PRODUCTION_TOKENThe docker-compose files already reference these variables, they just need values.
Verification
Section titled “Verification”Check if Dagster OTEL is configured:
Section titled “Check if Dagster OTEL is configured:”# Start Dagster and look for this message:# ✅ OpenTelemetry initialized for Dagster
# If you see this instead, OTEL is not configured:# ℹ️ OpenTelemetry not configured (OTEL_EXPORTER_OTLP_ENDPOINT not set)Check if correlation IDs are working:
Section titled “Check if correlation IDs are working:”- Make a request to the webapp
- Check the response headers for
x-correlation-id - In Better Stack, search for traces with:
correlation.id = "your-correlation-id" - You should see spans from webapp → Temporal and/or Dagster (if triggered)
Check Temporal / Dagster jobs:
Section titled “Check Temporal / Dagster jobs:”- Trigger a workflow or Dagster job from the webapp
- Check temporal-worker logs or Dagster logs for correlation ID attributes
- Verify the correlation ID is passed through the workflow/activity or Dagster job tags
Troubleshooting
Section titled “Troubleshooting”Dagster not sending traces
Section titled “Dagster not sending traces”-
Check environment variables are set:
Terminal window # In Dagster container/environmentecho $OTEL_EXPORTER_OTLP_ENDPOINTecho $OTEL_EXPORTER_OTLP_HEADERS -
Check Dagster startup logs:
- Should see:
✅ OpenTelemetry initialized for Dagster - If not, check that variables are set correctly
- Should see:
-
Verify Better Stack token:
- Token should have format:
Bearer YOUR_TOKENorapi-key=YOUR_TOKEN - Check token has “Send traces” permission in Better Stack
- Token should have format:
Correlation IDs not propagating
Section titled “Correlation IDs not propagating”-
Check webapp middleware:
- Verify
x-correlation-idheader is in response - Check middleware logs for correlation ID generation
- Verify
-
Check Temporal workflows / Dagster jobs:
- Verify the correlation ID is present in workflow inputs, activity logs, or Dagster tags
- Check that the service initiating the job forwards the correlation context
-
Check Dagster assets:
- Verify
set_correlation_id_attribute()is called in assets - Check that
correlation_idtag is set when triggering Dagster jobs
- Verify
Quick Setup Checklist
Section titled “Quick Setup Checklist”✅ Already Configured
Section titled “✅ Already Configured”- docker-compose.yml: Dagster has OTEL variables (lines 250-254)
- docker-compose.prod.yml:
dagster-webhas OTEL variables (lines 380-384) - Webapp, Temporal worker, PDF-API, PDF-Worker: Already have OTEL config
⚠️ Action Required
Section titled “⚠️ Action Required”-
Root
.envfile (ALL environments) - Ensure these are set:Terminal window OTEL_EXPORTER_OTLP_ENDPOINT=https://in-otel.betterstack.comOTEL_EXPORTER_OTLP_HEADERS=Authorization=Bearer YOUR_BETTER_STACK_TOKENNote: Use different tokens for dev/staging/production in Better Stack.
-
Service env (optional) - For Dagster Cloud integration:
Terminal window DAGSTER_CLOUD_URL=https://your-org.dagster.cloudDAGSTER_CLOUD_API_TOKEN=your_dagster_api_tokenNote: This is only needed if you want to trigger Dagster jobs programmatically from the webapp or Temporal worker.
Testing
Section titled “Testing”-
Start services and check Dagster logs:
Terminal window docker-compose up dagster# Look for: "✅ OpenTelemetry initialized for Dagster" -
Test correlation ID propagation:
- Make a request to webapp
- Check response header:
x-correlation-id - Search in Better Stack:
correlation.id = "your-correlation-id"