1+ name : " Lab 08: Trace GenAI Application"
2+
3+ on :
4+ workflow_dispatch :
5+ inputs :
6+ environment :
7+ description : ' Environment to deploy to'
8+ required : true
9+ default : ' dev'
10+ type : choice
11+ options :
12+ - dev
13+ - staging
14+ - prod
15+ push :
16+ paths :
17+ - ' labs/08-tracing/**'
18+ - ' .github/workflows/lab-08-trace.yml'
19+ branches :
20+ - main
21+ - ' lab/08-*'
22+ pull_request :
23+ paths :
24+ - ' labs/08-tracing/**'
25+
26+ env :
27+ LAB_NAME : " 08-tracing"
28+ LAB_TITLE : " Trace GenAI Application"
29+
30+ jobs :
31+ trace-genai :
32+ runs-on : ubuntu-latest
33+ environment : ${{ github.event.inputs.environment || 'dev' }}
34+
35+ steps :
36+ - name : Checkout repository
37+ uses : actions/checkout@v4
38+
39+ - name : Set up Python 3.8+
40+ uses : actions/setup-python@v4
41+ with :
42+ python-version : ' 3.8'
43+
44+ - name : Install dependencies
45+ run : |
46+ python -m pip install --upgrade pip
47+ pip install azure-ai-projects azure-identity azure-monitor-opentelemetry azure-ai-inference python-dotenv
48+
49+ - name : Azure login
50+ uses : azure/login@v1
51+ with :
52+ creds : ${{ secrets.AZURE_CREDENTIALS }}
53+
54+ - name : Set up environment variables
55+ run : |
56+ echo "PROJECT_CONNECTION_STRING=${{ secrets.PROJECT_CONNECTION_STRING }}" >> $GITHUB_ENV
57+ echo "CI_MODE=true" >> $GITHUB_ENV
58+
59+ - name : Run Lab 08 - Trace GenAI Application
60+ working-directory : ./labs/08-tracing
61+ run : |
62+ echo "::group::Lab Execution"
63+ python trace_genai.py --ci-mode
64+ echo "::endgroup::"
65+
66+ - name : Upload lab results
67+ uses : actions/upload-artifact@v3
68+ if : always()
69+ with :
70+ name : lab-08-tracing-results-${{ github.run_id }}
71+ path : |
72+ labs/08-tracing/tracing_results.json
73+ retention-days : 30
74+
75+ - name : Comment on PR with results
76+ if : github.event_name == 'pull_request'
77+ uses : actions/github-script@v6
78+ with :
79+ script : |
80+ const fs = require('fs');
81+
82+ let resultsContent = 'Lab execution failed - no results file found';
83+ try {
84+ const results = JSON.parse(fs.readFileSync('labs/08-tracing/tracing_results.json', 'utf8'));
85+
86+ const summary = results.summary || {};
87+ resultsContent = `## 🔍 Lab 08: Trace GenAI Application Results
88+
89+ **Status:** ${results.status === 'success' ? '✅ Success' : '❌ Failed'}
90+ **Environment:** ${{ github.event.inputs.environment || 'dev' }}
91+ **Execution Time:** ${new Date().toISOString()}
92+
93+ ### 🔬 Tracing Results
94+ - **Tracing Enabled:** ${summary.tracing_enabled ? '✅' : '❌'}
95+ - **Content Recording:** ${summary.content_recording_enabled ? '✅' : '❌'}
96+ - **Workflows Executed:** ${summary.workflows_executed || 0}
97+ - **Spans Created:** ${summary.total_spans_created || 0}
98+ - **Workflow Success Rate:** ${summary.workflow_success_rate || '0%'}
99+ - **Error Scenarios Traced:** ${summary.error_scenarios_traced || 0}
100+
101+ ### 🏃♂️ Workflow Analysis
102+ - **Hiking Assistant Workflow:** Multi-step AI workflow with preferences, recommendations, and gear suggestions
103+ - **Error Scenario Tracing:** Demonstrated error handling and tracing capabilities
104+ - **Distributed Tracing:** Each step traced with detailed span information
105+
106+ ${results.status === 'failed' ? `
107+ ### ❌ Errors
108+ \`\`\`
109+ ${results.error || 'Unknown error occurred'}
110+ \`\`\`
111+ ` : ''}
112+
113+ ### 🔗 View Traces
114+ - **Azure AI Foundry:** Check the tracing dashboard in your AI Foundry project
115+ - **Application Insights:** View detailed distributed traces in Azure Portal
116+ - **Transaction Search:** Use Application Insights transaction search to find specific traces
117+ - [Download detailed results](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
118+
119+ ### 📚 Next Steps
120+ 1. Open your Azure AI Foundry project
121+ 2. Navigate to the **Tracing** section
122+ 3. Search for traces with your session IDs
123+ 4. Analyze the workflow execution paths
124+ 5. Review error scenarios and debugging information
125+ `;
126+ } catch (error) {
127+ console.error('Error reading results:', error);
128+ }
129+
130+ github.rest.issues.createComment({
131+ issue_number: context.issue.number,
132+ owner: context.repo.owner,
133+ repo: context.repo.repo,
134+ body: resultsContent
135+ });
136+
137+ - name : Final status check
138+ if : always()
139+ run : |
140+ if [ -f "labs/08-tracing/tracing_results.json" ]; then
141+ status=$(python -c "import json; print(json.load(open('labs/08-tracing/tracing_results.json')).get('status', 'failed'))")
142+ if [ "$status" = "success" ]; then
143+ echo "::notice title=Lab 08 Success::Tracing lab completed successfully! 🔍"
144+ exit 0
145+ else
146+ echo "::error title=Lab 08 Failed::Tracing lab failed. Check logs for details."
147+ exit 1
148+ fi
149+ else
150+ echo "::error title=Lab 08 Failed::No results file found."
151+ exit 1
152+ fi
0 commit comments