Skip to content

feat: @google/genai Gemini AI LLM instrumentation #3119

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

Merged
merged 34 commits into from
Jun 4, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
e2eaf2d
google-genai Gemini skeleton
amychisholm03 May 22, 2025
c463a9c
generateContent segment
amychisholm03 May 22, 2025
bd23fcc
generateContentStream and embedContent
amychisholm03 May 22, 2025
733982f
wip: generateContentStreamInternal
amychisholm03 May 22, 2025
7b5bc64
wip: tests
amychisholm03 May 23, 2025
a908467
wip: tests
amychisholm03 May 23, 2025
644a06e
summary test passing
amychisholm03 May 27, 2025
1fd8c60
message test passing
amychisholm03 May 27, 2025
02484b2
tokenCB working
amychisholm03 May 27, 2025
dfe4687
embedding tests passing
amychisholm03 May 27, 2025
9d8ec07
wip: generateContentStreamInternal
amychisholm03 May 27, 2025
c774805
instrumentStream working
amychisholm03 May 27, 2025
721d706
cleanup
amychisholm03 May 27, 2025
5323cdb
concat stream response together
amychisholm03 May 28, 2025
c2217be
no response.headers available
amychisholm03 May 28, 2025
4e1844c
genai.test.js tweak
amychisholm03 May 28, 2025
36914db
comment style
amychisholm03 May 28, 2025
78908ab
wip: test/versioned/google-genai
amychisholm03 May 28, 2025
a8942c2
wip: test/versioned/google-genai
amychisholm03 May 28, 2025
89512c8
unit test fix
amychisholm03 May 28, 2025
d711cb1
cleanup unit tests
amychisholm03 May 29, 2025
f3021c6
fix test client
amychisholm03 May 29, 2025
fb7ed81
wip: test/versioned/google-genai
amychisholm03 May 29, 2025
01ec03a
wip: test/versioned/google-genai
amychisholm03 May 29, 2025
5259671
all versioned tests ok except for streaming
amychisholm03 May 29, 2025
fb21e93
all versioned tests pass
amychisholm03 May 30, 2025
ca16887
get rid of redundant streaming.enabled check
amychisholm03 May 30, 2025
f94ec71
typo
amychisholm03 Jun 2, 2025
e32b9ab
added test for unique google-genai errors
amychisholm03 Jun 2, 2025
b355dfe
tweaks
amychisholm03 Jun 3, 2025
cc97eca
add segment name check
amychisholm03 Jun 3, 2025
2710035
Merge https://github.com/amychisholm03/node-newrelic into NR-2890/gem…
amychisholm03 Jun 3, 2025
e1c33fc
bad json error test
amychisholm03 Jun 3, 2025
eaa4c4c
test names
amychisholm03 Jun 3, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
unit test fix
  • Loading branch information
amychisholm03 committed May 28, 2025
commit 89512c8d671c95d67b89100568580e0e0ebb54de
3 changes: 1 addition & 2 deletions lib/instrumentation/@google/genai.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,7 @@ function instrumentStream ({ agent, shim, request, response, segment, transactio
candidates: [
{ content, finishReason }
],
modelVersion,
text: entireMessage
modelVersion
}
recordChatCompletionMessages({
agent: shim.agent,
Expand Down
3 changes: 2 additions & 1 deletion lib/llm-events/google-genai/chat-completion-message.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ module.exports = class LlmChatCompletionMessage extends LlmEvent {
this.role = message?.role ?? 'user' // Role is only defined if it is 'model'
this.sequence = index
this.completion_id = completionId
this.is_response = response?.text === message?.parts?.[0]?.text
const responseText = response?.text ?? response?.candidates?.[0]?.content?.parts?.[0]?.text
this.is_response = responseText === message?.parts?.[0]?.text

if (agent.config.ai_monitoring.record_content.enabled === true) {
this.content = this.is_response ? message?.parts?.[0]?.text : message
Expand Down
Loading