Skip to content

Conversation

@reakaleek
Copy link
Member

@reakaleek reakaleek commented Oct 28, 2025

Context

Preparing for the hybrid Lambda architecture to support streaming LLM responses. This PR adds OpenTelemetry tracing to AskAI operations and updates the Lambda deployment workflow and runtime configuration to support dual deployment (streaming-optimized + API Gateway-optimized).

Changes

OpenTelemetry Tracing:

  • Added activity tracing to AskAiUsecase with GenAI semantic conventions
  • Track conversation IDs, token counts, prompts, and agent metadata
  • Extended IStreamTransformer with AgentId and AgentProvider properties
  • Added streaming pipeline activities in StreamTransformerBase
  • Configured OTel sources: Elastic.Documentation.Api.AskAi and StreamTransformer

Lambda Runtime Configuration:

  • Support dual mode: Lambda Web Adapter (response streaming) and API Gateway HTTP API
  • Switch from RestApi to HttpApi event source (HTTP API v2 payload format)
  • Conditional Kestrel configuration based on AWS_LWA_INVOKE_MODE env var
  • Added Amazon.Lambda.APIGatewayEvents package dependency

Deployment Workflow:

  • Upload artifact to S3 once at ${ENVIRONMENT}/${GITHUB_SHA}/api-lambda.zip
  • Deploy to both lambda-stream-optimized and lambda-api-gateway-optimized functions
  • Tag Lambda versions with git SHA in description for traceability
  • Enhanced deployment logs showing versions and commit for both functions

@reakaleek reakaleek requested a review from a team as a code owner October 28, 2025 16:40
@reakaleek reakaleek requested a review from Mpdreamz October 28, 2025 16:40
@reakaleek reakaleek changed the title Add edot activities in AskAI feature Add otel activities in AskAI feature Oct 29, 2025
@reakaleek reakaleek changed the title Add otel activities in AskAI feature Add support for hybrid lambda architecture for both buffered and streaming responses Oct 30, 2025
@reakaleek reakaleek requested a review from Mpdreamz October 30, 2025 10:34
@reakaleek reakaleek merged commit 9da5f69 into main Oct 30, 2025
22 checks passed
@reakaleek reakaleek deleted the feature/otel-activities branch October 30, 2025 12:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants