Skip to content

Conversation

ajeetraina
Copy link
Owner

Enhanced Jaeger Tracing Implementation (Updated)

This PR adds comprehensive Jaeger tracing support to the GenAI application, providing detailed insights into request handling and model inference.

Note: This PR has been updated to be compatible with the build fixes in PR #14. Please merge PR #14 first.

Key Changes

  1. Enhanced Tracing Package:

    • Improved error handling and span management
    • Added support for child spans, events, and detailed attributes
    • Fixed issues with the existing AddAttribute function
  2. New Tracing Middleware:

    • Added HTTP middleware to automatically trace all requests
    • Captures HTTP method, URL, status code, and other request details
    • Properly propagates trace context through the application
  3. Model Inference Tracing:

    • Added a TracedModelInference struct to track model performance
    • Detailed spans for each phase of model inference
    • Records metrics like Time To First Token (TTFT)
    • Creates events for significant milestones (first token, completion)
  4. Metrics Middleware:

    • Refactored metrics collection into a middleware
    • Ensures consistent metrics for all requests
  5. Fixed Package Structure:

    • Moved responseWriterWrapper to a dedicated file
    • Removed duplicate type definitions

Usage

The tracing is automatically enabled when the TRACING_ENABLED environment variable is set to true and uses the Jaeger endpoint specified in OTLP_ENDPOINT (defaults to jaeger:4318).

Benefits

  • Detailed Performance Insights: Identify bottlenecks in model loading, inference, and response handling
  • Error Tracing: Quickly pinpoint where errors occur in the request processing pipeline
  • End-to-End Visibility: Track a request from frontend to model and back
  • Token Metrics: See token generation rates and timing information

This implementation follows OpenTelemetry best practices and is designed to work seamlessly with Jaeger UI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant