-
Notifications
You must be signed in to change notification settings - Fork 32
Clean up OTel instrumentation for AskAi #2144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
dd76e31 to
ea4a4c5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors the OpenTelemetry instrumentation for the AskAI streaming API to align with GenAI semantic conventions, consolidates telemetry configuration, and renames event types for clarity. The changes simplify telemetry collection while improving observability standards compliance.
- Renamed
ChunkandChunkCompleteevents toMessageChunkandMessageCompletefor consistency with semantic conventions - Refactored OpenTelemetry configuration into a centralized
OpenTelemetryExtensionsclass with proper AOT compatibility - Simplified streaming telemetry by removing granular per-token activities and focusing on conversation-level metrics
Reviewed Changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/tooling/docs-builder/docs-builder.csproj | Added OpenTelemetry package references for the docs-builder CLI tool |
| src/tooling/docs-builder/Http/DocumentationWebHost.cs | Minor formatting change adding empty line |
| src/api/Elastic.Documentation.Api.Lambda/Program.cs | Replaced inline EDOT configuration with centralized extension method call |
| src/api/Elastic.Documentation.Api.Infrastructure/OpenTelemetryExtensions.cs | New extension method consolidating OpenTelemetry configuration with AOT support |
| src/api/Elastic.Documentation.Api.Infrastructure/Elastic.Documentation.Api.Infrastructure.csproj | Added OpenTelemetry package dependencies |
| src/api/Elastic.Documentation.Api.Infrastructure/Adapters/AskAi/StreamTransformerBase.cs | Refactored telemetry to align with GenAI semantic conventions and simplified activity tracking |
| src/api/Elastic.Documentation.Api.Infrastructure/Adapters/AskAi/LlmGatewayStreamTransformer.cs | Updated event names and added error event parsing for LLM Gateway |
| src/api/Elastic.Documentation.Api.Infrastructure/Adapters/AskAi/AgentBuilderStreamTransformer.cs | Updated event names, made helper methods static, and removed duplicate error logging |
| src/api/Elastic.Documentation.Api.Core/SerializationContext.cs | Added telemetry types for OpenTelemetry message serialization |
| src/api/Elastic.Documentation.Api.Core/AskAi/AskAiUsecase.cs | Simplified telemetry setup using GenAI semantic conventions |
| src/api/Elastic.Documentation.Api.Core/AskAi/AskAiEvent.cs | Renamed Chunk to MessageChunk and ChunkComplete to MessageComplete |
| src/Elastic.Documentation.Site/Assets/web-components/SearchOrAskAi/AskAi/StreamingAiMessage.tsx | Updated TypeScript to reference renamed event types |
| src/Elastic.Documentation.Site/Assets/web-components/SearchOrAskAi/AskAi/ChatMessage.tsx | Updated TypeScript to reference renamed event types |
| src/Elastic.Documentation.Site/Assets/web-components/SearchOrAskAi/AskAi/AskAiEvent.ts | Updated TypeScript event type constants and schemas |
| Directory.Packages.props | Updated OpenTelemetry package versions to 1.13.x |
src/api/Elastic.Documentation.Api.Infrastructure/Adapters/AskAi/StreamTransformerBase.cs
Outdated
Show resolved
Hide resolved
src/api/Elastic.Documentation.Api.Infrastructure/Adapters/AskAi/StreamTransformerBase.cs
Outdated
Show resolved
Hide resolved
|
Sorry, I'm merging this. I need it to continue. |
PR Summary
OpenTelemetry Cleanup and Code Simplification
This PR consolidates OpenTelemetry instrumentation and simplifies the codebase by removing verbose logging and streamlining the streaming architecture.
Key Changes:
Centralized OpenTelemetry Configuration: Extracted OTel setup into a reusable extension method (
OpenTelemetryExtensions.cs), enabling consistent instrumentation across Lambda and web hosting scenarios. Configuration only activates when theOTEL_EXPORTER_OTLP_ENDPOINTenvironment variable is set.Lambda Startup Cleanup: Removed verbose process memory logging that was cluttering Lambda initialization logs. Startup code reduced from ~50 lines to ~12 lines while maintaining the same functionality.
Streaming Architecture Refactor: Moved
StreamTransformerBasefrom Infrastructure to Core package, making shared streaming logic available across the API layer. This consolidates common SSE parsing and event transformation logic.Naming Consistency: Renamed
threadIdtoconversationIdthroughout the codebase (both frontend TypeScript and backend C#) for clearer terminology. Updated event types fromCHUNK/CHUNK_COMPLETEtoMESSAGE_CHUNK/MESSAGE_COMPLETE.Frontend Improvements: Simplified streaming message component logic and added better error logging with detailed context for debugging SSE event parsing failures.