feat(deno): add google-genai integration#22469
Conversation
a3bda7b to
af2805c
Compare
fcdda49 to
6581776
Compare
af2805c to
46512ae
Compare
6581776 to
40c51ca
Compare
| Deno.test('google-genai instrumentation: orchestrion @google/genai:generate-content channel produces a nested gen_ai span', async () => { | ||
| resetGlobals(); | ||
| const sink = transactionSink(); | ||
| init({ |
There was a problem hiding this comment.
Bug: A module-level installedIntegrations array is not cleared between tests, causing subsequent init() calls to skip setup and leading to test failures.
Severity: MEDIUM
Suggested Fix
The installedIntegrations array should be cleared between tests. This can be done by exporting a reset function from @sentry/core that clears the array and then calling this new function within resetGlobals(). This will ensure each test runs in a clean state.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location:
dev-packages/deno-integration-tests/suites/orchestrion-google-genai/test.ts#L69-L72
Potential issue: A module-level array, `installedIntegrations`, is not cleared between
tests, even when `resetGlobals()` is called. When a second test in the same file calls
`init()`, the integration's `setupOnce()` function is skipped because the integration
name is already present in the array from the first test's execution. This prevents
diagnostic channel subscriptions from being set up for the second test. Consequently,
the test times out waiting for a transaction that is never created, causing a test
failure.
Also affects:
packages/core/src/integration.ts:10packages/core/src/integration.ts:117~119
Did we get this right? 👍 / 👎 to inform future reviews.
46512ae to
46e8ba9
Compare
40c51ca to
3e3e6d2
Compare
46e8ba9 to
a2edc7e
Compare
3e3e6d2 to
fd6c438
Compare
a2edc7e to
ac2a96d
Compare
fd6c438 to
126e75d
Compare
126e75d to
4c7f4ea
Compare
ac2a96d to
dd3e8b8
Compare
| Deno.test('google-genai instrumentation: orchestrion @google/genai:generate-content channel produces a nested gen_ai span', async () => { | ||
| resetGlobals(); | ||
| const sink = transactionSink(); | ||
| init({ | ||
| dsn: 'https://username@domain/123', | ||
| tracesSampleRate: 1, | ||
| beforeSendTransaction: sink.beforeSendTransaction, | ||
| }); | ||
|
|
There was a problem hiding this comment.
Bug: Module-level state in installedIntegrations is not reset between tests, causing subsequent calls to init() in the same process to skip the setupOnce() logic for integrations.
Severity: MEDIUM
Suggested Fix
To ensure test isolation, implement a mechanism to reset the module-level state between tests. Export a reset function from the SDK's core integration module that clears the installedIntegrations array. This function should be called in a beforeEach or afterEach hook within the test suite to guarantee each test starts with a clean state.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location:
dev-packages/deno-integration-tests/suites/orchestrion-google-genai/test.ts#L64-L72
Potential issue: The `installedIntegrations` array is a module-level variable that
persists for the lifetime of a process. When tests run in the same process, the first
test adds the 'Google_GenAI' integration name to this array. The second test calls
`init()` again, but because the integration name is already present in
`installedIntegrations`, the `setupOnce()` function is skipped. This prevents the
diagnostic channel subscription from being established in the second test, causing it to
fail when it asserts the existence of an expected span. This behavior could also occur
in production if `init()` is called multiple times in the same process, causing
instrumentation to silently fail.
size-limit report 📦
|
No description provided.