-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
feat(deno): redis diagnostics channel based integration for deno #21087
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
Open
isaacs
wants to merge
2
commits into
develop
Choose a base branch
from
isaacs/deno-redis-dc
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
7 changes: 7 additions & 0 deletions
7
dev-packages/e2e-tests/test-applications/deno-redis/deno.json
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "imports": { | ||
| "@sentry/deno": "npm:@sentry/deno", | ||
| "redis": "npm:redis@^5.12.0" | ||
| }, | ||
| "nodeModulesDir": "manual" | ||
| } |
12 changes: 12 additions & 0 deletions
12
dev-packages/e2e-tests/test-applications/deno-redis/docker-compose.yml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| services: | ||
| redis: | ||
| image: redis:8 | ||
| restart: always | ||
| container_name: e2e-tests-deno-redis | ||
| ports: | ||
| - '6379:6379' | ||
| healthcheck: | ||
| test: ['CMD', 'redis-cli', 'ping'] | ||
| interval: 1s | ||
| timeout: 3s | ||
| retries: 30 |
14 changes: 14 additions & 0 deletions
14
dev-packages/e2e-tests/test-applications/deno-redis/global-setup.mjs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| import { execSync } from 'child_process'; | ||
| import { dirname } from 'path'; | ||
| import { fileURLToPath } from 'url'; | ||
|
|
||
| const __dirname = dirname(fileURLToPath(import.meta.url)); | ||
|
|
||
| export default async function globalSetup() { | ||
| // Start Redis via Docker Compose. `--wait` blocks until the healthcheck | ||
| // in docker-compose.yml passes, so the Deno app can connect immediately. | ||
| execSync('docker compose up -d --wait', { | ||
| cwd: __dirname, | ||
| stdio: 'inherit', | ||
| }); | ||
| } |
12 changes: 12 additions & 0 deletions
12
dev-packages/e2e-tests/test-applications/deno-redis/global-teardown.mjs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import { execSync } from 'child_process'; | ||
| import { dirname } from 'path'; | ||
| import { fileURLToPath } from 'url'; | ||
|
|
||
| const __dirname = dirname(fileURLToPath(import.meta.url)); | ||
|
|
||
| export default async function globalTeardown() { | ||
| execSync('docker compose down --volumes', { | ||
| cwd: __dirname, | ||
| stdio: 'inherit', | ||
| }); | ||
| } |
22 changes: 22 additions & 0 deletions
22
dev-packages/e2e-tests/test-applications/deno-redis/package.json
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| { | ||
| "name": "deno-redis", | ||
| "version": "1.0.0", | ||
| "private": true, | ||
| "scripts": { | ||
| "start": "deno run --allow-net --allow-env --allow-read --allow-sys --allow-write src/app.ts", | ||
| "test": "playwright test", | ||
| "clean": "npx rimraf node_modules pnpm-lock.yaml", | ||
| "test:build": "pnpm install", | ||
| "test:assert": "pnpm test" | ||
| }, | ||
| "dependencies": { | ||
| "@sentry/deno": "file:../../packed/sentry-deno-packed.tgz" | ||
| }, | ||
| "devDependencies": { | ||
| "@playwright/test": "~1.56.0", | ||
| "@sentry-internal/test-utils": "link:../../../test-utils" | ||
| }, | ||
| "volta": { | ||
| "extends": "../../package.json" | ||
| } | ||
| } |
12 changes: 12 additions & 0 deletions
12
dev-packages/e2e-tests/test-applications/deno-redis/playwright.config.mjs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import { getPlaywrightConfig } from '@sentry-internal/test-utils'; | ||
|
|
||
| const config = getPlaywrightConfig({ | ||
| startCommand: `pnpm start`, | ||
| port: 3030, | ||
| }); | ||
|
|
||
| export default { | ||
| ...config, | ||
| globalSetup: './global-setup.mjs', | ||
| globalTeardown: './global-teardown.mjs', | ||
| }; |
54 changes: 54 additions & 0 deletions
54
dev-packages/e2e-tests/test-applications/deno-redis/src/app.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| import * as Sentry from '@sentry/deno'; | ||
| import { createClient } from 'redis'; | ||
|
|
||
| Sentry.init({ | ||
| environment: 'qa', | ||
| dsn: Deno.env.get('E2E_TEST_DSN'), | ||
| debug: !!Deno.env.get('DEBUG'), | ||
| tunnel: 'http://localhost:3031/', | ||
| tracesSampleRate: 1, | ||
| }); | ||
|
|
||
| // One shared client per process. node-redis publishes to the | ||
| // `node-redis:command` / `:batch` / `:connect` diagnostics channels for every | ||
| // operation on this client; denoRedisIntegration is already subscribed to | ||
| // those (it's part of the default integrations on Deno 2.7.13+). | ||
| const redis = createClient({ | ||
| url: Deno.env.get('REDIS_URL') ?? 'redis://127.0.0.1:6379', | ||
| }); | ||
| redis.on('error', err => { | ||
| // eslint-disable-next-line no-console | ||
| console.error('redis client error', err); | ||
| }); | ||
| await redis.connect(); | ||
|
|
||
| const port = 3030; | ||
|
|
||
| Deno.serve({ port, hostname: '0.0.0.0' }, async (req: Request) => { | ||
| const url = new URL(req.url); | ||
|
|
||
| // GET — exercises the command channel, success path. | ||
| if (url.pathname === '/redis-get') { | ||
| const key = url.searchParams.get('key') ?? 'cache:key'; | ||
| const value = await redis.get(key); | ||
| return Response.json({ key, value }); | ||
| } | ||
|
|
||
| // SET then GET — exercises two commands inside a single transaction so we | ||
| // can assert the parent has two db.redis children. | ||
| if (url.pathname === '/redis-set-get') { | ||
| const key = url.searchParams.get('key') ?? 'cache:key'; | ||
| const value = url.searchParams.get('value') ?? 'hello'; | ||
| await redis.set(key, value); | ||
| const echoed = await redis.get(key); | ||
| return Response.json({ key, value: echoed }); | ||
| } | ||
|
|
||
| // MULTI — exercises the batch channel. | ||
| if (url.pathname === '/redis-multi') { | ||
| const result = await redis.multi().set('multi:a', '1').set('multi:b', '2').get('multi:a').exec(); | ||
| return Response.json({ result }); | ||
| } | ||
|
|
||
| return new Response('Not found', { status: 404 }); | ||
| }); |
6 changes: 6 additions & 0 deletions
6
dev-packages/e2e-tests/test-applications/deno-redis/start-event-proxy.mjs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| import { startEventProxyServer } from '@sentry-internal/test-utils'; | ||
|
|
||
| startEventProxyServer({ | ||
| port: 3031, | ||
| proxyServerName: 'deno-redis', | ||
| }); |
69 changes: 69 additions & 0 deletions
69
dev-packages/e2e-tests/test-applications/deno-redis/tests/redis.test.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| import { expect, test } from '@playwright/test'; | ||
| import { waitForTransaction } from '@sentry-internal/test-utils'; | ||
|
|
||
| test('GET command emits an http.server transaction containing a db.redis child span', async ({ baseURL }) => { | ||
| // Each incoming request gets a Sentry http.server transaction (via the | ||
| // default denoServeIntegration); the redis command runs inside it, so the | ||
| // child span attaches to that transaction. | ||
| const transactionPromise = waitForTransaction('deno-redis', event => { | ||
| return ( | ||
| event?.contexts?.trace?.op === 'http.server' && | ||
| (event.request?.url ?? '').includes('/redis-get') && | ||
| (event.spans?.some(span => span.op === 'db.redis') ?? false) | ||
| ); | ||
| }); | ||
|
|
||
| const res = await fetch(`${baseURL}/redis-get?key=cache:user:42`); | ||
| expect(res.status).toBe(200); | ||
| await res.json(); | ||
|
|
||
| const transaction = await transactionPromise; | ||
| const redisSpan = transaction.spans!.find(span => span.op === 'db.redis'); | ||
| expect(redisSpan).toBeDefined(); | ||
| expect(redisSpan!.description).toBe('redis-GET'); | ||
| expect(redisSpan!.data?.['db.system']).toBe('redis'); | ||
| // Statement omits the value; for GET the only allowed arg is the key. | ||
| expect(redisSpan!.data?.['db.statement']).toBe('GET cache:user:42'); | ||
| expect(redisSpan!.data?.['net.peer.port']).toBe(6379); | ||
| }); | ||
|
|
||
| test('SET then GET emit two db.redis child spans on the same transaction', async ({ baseURL }) => { | ||
| const transactionPromise = waitForTransaction('deno-redis', event => { | ||
| return ( | ||
| event?.contexts?.trace?.op === 'http.server' && | ||
| (event.request?.url ?? '').includes('/redis-set-get') && | ||
| (event.spans?.filter(span => span.op === 'db.redis').length ?? 0) >= 2 | ||
| ); | ||
| }); | ||
|
|
||
| const res = await fetch(`${baseURL}/redis-set-get?key=cache:greeting&value=hello`); | ||
| expect(res.status).toBe(200); | ||
| await res.json(); | ||
|
|
||
| const transaction = await transactionPromise; | ||
| const redisSpans = transaction.spans!.filter(span => span.op === 'db.redis'); | ||
| expect(redisSpans.length).toBeGreaterThanOrEqual(2); | ||
| const ops = redisSpans.map(s => s.description); | ||
| expect(ops).toContain('redis-SET'); | ||
| expect(ops).toContain('redis-GET'); | ||
| }); | ||
|
|
||
| test('MULTI batch emits a PIPELINE/MULTI batch span', async ({ baseURL }) => { | ||
| const transactionPromise = waitForTransaction('deno-redis', event => { | ||
| return ( | ||
| event?.contexts?.trace?.op === 'http.server' && | ||
| (event.request?.url ?? '').includes('/redis-multi') && | ||
| (event.spans?.some(span => span.description === 'MULTI' || span.description === 'PIPELINE') ?? false) | ||
| ); | ||
| }); | ||
|
|
||
| const res = await fetch(`${baseURL}/redis-multi`); | ||
| expect(res.status).toBe(200); | ||
| await res.json(); | ||
|
|
||
| const transaction = await transactionPromise; | ||
| const batchSpan = transaction.spans!.find(span => span.description === 'MULTI' || span.description === 'PIPELINE'); | ||
| expect(batchSpan).toBeDefined(); | ||
| expect(batchSpan!.op).toBe('db.redis'); | ||
| expect(batchSpan!.data?.['db.system']).toBe('redis'); | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
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.
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.
E2E CI uses outdated Deno version for deno-redis
High Severity
The E2E test job sets
deno-version: v2.1.5fordeno-redis, but thedenoRedisIntegrationand the test app explicitly require Deno 2.7.13+ (as stated in the app comment at line 15 ofapp.ts). The unit test job was correctly updated tov2.7.14at line 530, but the E2E test job was not. Thedeno-redisE2E tests will likely fail or produce incorrect results running on a Deno version that is too old.Additional Locations (1)
.github/workflows/build.yml#L988-L991Reviewed by Cursor Bugbot for commit 72be1fa. Configure here.