Instrument Gemini streaming (streamGenerateContent) calls#55
Open
Matt Perpick (clutchski) wants to merge 2 commits intomainfrom
Open
Instrument Gemini streaming (streamGenerateContent) calls#55Matt Perpick (clutchski) wants to merge 2 commits intomainfrom
Matt Perpick (clutchski) wants to merge 2 commits intomainfrom
Conversation
The genai integration was not tracing streaming API calls at all. The URL router could not match streamGenerateContent endpoints, and the response parser only handled single-JSON responses. This adds full streaming support: SSE chunk parsing, response aggregation, time_to_first_token metrics, and proper URL routing for both streaming and non-streaming Gemini endpoints. Also adds time_to_first_token to non-streaming responses. Fixes #50 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Shows that both non-streaming and streaming Gemini calls now produce complete spans with output, token metrics, and time_to_first_token. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
streamGenerateContentendpoints (previously onlygenerateContentwas matched)time_to_first_tokenmetric for both streaming and non-streaming responsesgemini-2.0-flash(replacing deprecatedgemini-2.0-flash-exp) and fix missingotel.SetTracerProvidercallFixes #50
Test plan
TestContainsGenerateContent— verifies URL routing matches both streaming and non-streaming pathsTestExtractModelFromPath— verifies model extraction from streaming pathsTestIsStreamingPath— verifies streaming endpoint detectionTestStreamingGenerateContent— full integration test with VCR cassette verifying span creation, metadata, output aggregation, token metrics, andtime_to_first_tokentime_to_first_tokenassertion toTestBasicGenerateContentfor non-streamingmake cipasses (lint + test + build)🤖 Generated with Claude Code