@@ -9,6 +9,18 @@ echo "This script demonstrates the complete observability"
99echo " and monitoring capabilities of the DispatchAI system."
1010echo " "
1111
12+ # Detect environment (dev or production)
13+ if docker ps --format " {{.Names}}" | grep -q " dispatchai-ingress-prod" ; then
14+ ENV=" prod"
15+ CONTAINER_SUFFIX=" -prod"
16+ echo " 🔍 Detected: Production environment"
17+ else
18+ ENV=" dev"
19+ CONTAINER_SUFFIX=" "
20+ echo " 🔍 Detected: Development environment"
21+ fi
22+ echo " "
23+
1224echo " Step 1: Verify all services are running..."
1325echo " ==========================================="
1426make check-containers
8092)
8193
8294echo " Sending webhook to http://localhost:8000/webhook/github..."
95+
96+ # Generate HMAC signature if in production (signature verification enabled)
97+ if [ " $ENV " = " prod" ]; then
98+ # In production, we need a valid signature
99+ # For demo purposes, we'll note that signature verification would need the secret
100+ echo " ⚠️ Note: Production requires valid GitHub webhook signature"
101+ echo " For demo purposes, sending without signature (will be rejected by security)"
102+ echo " "
103+ fi
104+
83105RESPONSE=$( curl -s -X POST http://localhost:8000/webhook/github \
84106 -H " Content-Type: application/json" \
85107 -H " X-GitHub-Event: issues" \
108+ -H " X-Hub-Signature-256: sha256=demo" \
86109 -d " $WEBHOOK_PAYLOAD " )
87110
88111echo " $RESPONSE " | python3 -m json.tool 2> /dev/null || echo " $RESPONSE "
89- CORRELATION_ID=$( echo " $RESPONSE " | python3 -c " import sys, json; print(json.load(sys.stdin).get('correlation_id', 'N/A'))" 2> /dev/null || echo " N/A" )
112+
113+ # Check if we got an error response
114+ if echo " $RESPONSE " | grep -q " Invalid signature" ; then
115+ echo " "
116+ echo " ⚠️ Webhook rejected: Invalid signature (expected in production)"
117+ echo " 📝 In production, webhooks must come from GitHub with valid signatures"
118+ echo " 📝 For testing, you can temporarily disable signature verification or use the actual webhook endpoint"
119+ CORRELATION_ID=" N/A"
120+ else
121+ CORRELATION_ID=$( echo " $RESPONSE " | python3 -c " import sys, json; print(json.load(sys.stdin).get('correlation_id', 'N/A'))" 2> /dev/null || echo " N/A" )
122+ fi
123+
90124echo " "
91- echo " ✅ Webhook sent with correlation_id: $CORRELATION_ID "
125+ echo " Webhook result: correlation_id= $CORRELATION_ID "
92126echo " "
93127sleep 2
94128
@@ -113,23 +147,18 @@ echo "Step 7: Trace the issue through all services using correlation ID..."
113147echo " ===================================================================="
114148echo " "
115149echo " This demonstrates E2E distributed tracing capability."
116- echo " Searching logs for correlation_id: $CORRELATION_ID "
117150echo " "
118151
119152if [ " $CORRELATION_ID " != " N/A" ]; then
120- echo " --- Ingress Service Logs ---"
121- docker logs dispatchai-ingress 2>&1 | grep " $CORRELATION_ID " | tail -5 || echo " No logs found"
153+ echo " Using make trace-id to trace correlation_id: $CORRELATION_ID "
122154 echo " "
123-
124- echo " --- Classifier Service Logs --- "
125- docker logs dispatchai-classifier 2>&1 | grep " $CORRELATION_ID " | tail -5 || echo " Processing may still be in progress or logs not yet available "
155+ make trace-id ID= " $CORRELATION_ID "
156+ else
157+ echo " ⚠️ Could not extract correlation ID from test webhook "
126158 echo " "
127-
128- echo " --- Gateway Service Logs ---"
129- docker logs dispatchai-gateway 2>&1 | grep " $CORRELATION_ID " | tail -5 || echo " Processing may still be in progress or logs not yet available"
159+ echo " 💡 Demonstrating with a recent real webhook instead:"
130160 echo " "
131- else
132- echo " ⚠️ Could not extract correlation ID from response"
161+ make trace-recent
133162fi
134163
135164sleep 2
@@ -138,14 +167,33 @@ echo "======================================"
138167echo " ✅ Demo Complete!"
139168echo " ======================================"
140169echo " "
170+ echo " Environment: $ENV "
171+ echo " "
141172echo " Key Takeaways:"
142173echo " -------------"
143174echo " 1. ✅ All services expose /health endpoints with dependency verification"
144175echo " 2. ✅ All services expose /metrics endpoints with p50/p95/p99 latencies"
145- echo " 3. ✅ Correlation IDs enable E2E tracing in <1 minute"
176+ if [ " $CORRELATION_ID " != " N/A" ]; then
177+ echo " 3. ✅ Correlation IDs enable E2E tracing in <1 minute"
178+ else
179+ echo " 3. ⚠️ Correlation ID tracing (blocked by signature verification in production)"
180+ fi
146181echo " 4. ✅ System processes webhooks in 3-5 seconds end-to-end"
147182echo " 5. ✅ Consumer lag monitoring shows classifier keeping up with load"
148183echo " "
184+
185+ if [ " $ENV " = " prod" ]; then
186+ echo " 🔒 Production Security Note:"
187+ echo " ----------------------------"
188+ echo " Webhook signature verification is enabled (as it should be!)"
189+ echo " Test webhooks are rejected, but real GitHub webhooks work perfectly."
190+ echo " "
191+ echo " To trace real production webhooks:"
192+ echo " make trace-recent # View recent correlation IDs"
193+ echo " make trace-id ID=<id> # Trace a specific request"
194+ echo " "
195+ fi
196+
149197echo " Available Commands:"
150198echo " ------------------"
151199echo " make health - View all service health checks"
@@ -154,6 +202,10 @@ echo " make metrics-summary - View quick metrics summary"
154202echo " make system-status - View complete system status"
155203echo " make watch-metrics - Watch metrics in real-time"
156204echo " "
205+ echo " Correlation ID Tracing:"
206+ echo " make trace-recent - Show recent correlation IDs"
207+ echo " make trace-id ID=<id> - Trace specific request E2E"
208+ echo " "
157209echo " For detailed analysis:"
158210echo " make health-ingress - Ingress service health only"
159211echo " make metrics-classifier - Classifier service metrics only"
0 commit comments