A Python project for evaluation results processing with OpenTelemetry tracing and Azure OpenAI integration.
For production:
pip install -r requirements.txtCreate a .env file in the evaluation_result/ directory with your Azure OpenAI credentials:
MODEL_DEPLOYMENT_NAME=gpt-4o
AZURE_OPENAI_ENDPOINT=https://your-endpoint.openai.azure.com/
AZURE_OPENAI_API_KEY=your-api-key
AZURE_OPENAI_API_VERSION=2025-03-01-preview
APPLICATION_INSIGHTS_CONNECTION_STRING=your-connection-string
PROJECT_ENDPOINT=https://your-project-endpointThis project demonstrates OpenTelemetry tracing with Azure OpenAI and evaluation workflows.
First, run the trace generation script to create sample trace data:
python evaluation_result/generate_trace.pyThis will:
- Create OpenAI chat completion requests
- Generate traces that are sent to both console and Azure Monitor
- Provide trace IDs for evaluation linking
{
"name": "chat gpt-4o",
"context": {
"trace_id": "0xeb0fdf5670975fea194b2eef13e789c6",
"span_id": "0x63e929946253cf52",
"trace_state": "[]"
},
"kind": "SpanKind.CLIENT",
"parent_id": null,
"start_time": "2025-08-04T23:45:55.959766Z",
"end_time": "2025-08-04T23:45:57.512342Z",
"status": {
"status_code": "UNSET"
},
"attributes": {
"gen_ai.operation.name": "chat",
"gen_ai.system": "openai",
"gen_ai.request.model": "gpt-4o",
"server.address": "anksing1rpeastus2.openai.azure.com",
"_MS.sampleRate": 100.0,
"gen_ai.response.model": "gpt-4o-2024-11-20",
"gen_ai.response.finish_reasons": [
"stop"
],
"gen_ai.response.id": "chatcmpl-C0zAK9AqI5MpwVScha6p1Dm5BgO7R",
"gen_ai.usage.input_tokens": 15,
"gen_ai.usage.output_tokens": 114
},
"events": [],
"links": [],
"resource": {
"attributes": {
"telemetry.sdk.language": "python",
"telemetry.sdk.name": "opentelemetry",
"telemetry.sdk.version": "1.36.0",
"service.name": "unknown_service"
},
"schema_url": ""
}
}After generating traces, run the evaluation script after substituing the trace_id and span_id from Step 1. Generate Trace Data
python evaluation_result/evaluation.pyThis will:
- Create evaluation event linked to the generated traces