|
| 1 | +import { expect, test } from '@playwright/test'; |
| 2 | +import { waitForTransaction } from '@sentry-internal/test-utils'; |
| 3 | + |
| 4 | +test('@callable() methods work correctly with Sentry instrumentDurableObjectWithSentry', async ({ page, baseURL }) => { |
| 5 | + const transactionPromise = waitForTransaction('cloudflare-agent', transactionEvent => { |
| 6 | + return ( |
| 7 | + transactionEvent.transaction === 'GET /agents/my-agent/user-123' && |
| 8 | + transactionEvent.contexts?.trace?.parent_span_id !== undefined |
| 9 | + ); |
| 10 | + }); |
| 11 | + |
| 12 | + await page.goto(baseURL!); |
| 13 | + |
| 14 | + await expect(page.getByText('Connected')).toBeVisible(); |
| 15 | + await page.getByRole('button', { name: 'Call Agent' }).click(); |
| 16 | + await expect(page.getByText('Hello, World!')).toBeVisible(); |
| 17 | + |
| 18 | + const transaction = await transactionPromise; |
| 19 | + |
| 20 | + expect(transaction).toEqual({ |
| 21 | + contexts: { |
| 22 | + trace: { |
| 23 | + parent_span_id: expect.stringMatching(/[a-f0-9]{16}/), |
| 24 | + span_id: expect.stringMatching(/[a-f0-9]{16}/), |
| 25 | + trace_id: expect.stringMatching(/[a-f0-9]{32}/), |
| 26 | + data: expect.any(Object), |
| 27 | + op: 'http.server', |
| 28 | + status: 'ok', |
| 29 | + origin: 'auto.http.cloudflare', |
| 30 | + }, |
| 31 | + cloud_resource: { 'cloud.provider': 'cloudflare' }, |
| 32 | + culture: { timezone: expect.any(String) }, |
| 33 | + runtime: { name: 'cloudflare' }, |
| 34 | + }, |
| 35 | + spans: expect.arrayContaining([ |
| 36 | + expect.objectContaining({ |
| 37 | + op: 'db', |
| 38 | + description: 'durable_object_storage_get', |
| 39 | + }), |
| 40 | + ]), |
| 41 | + start_timestamp: expect.any(Number), |
| 42 | + timestamp: expect.any(Number), |
| 43 | + transaction: 'GET /agents/my-agent/user-123', |
| 44 | + type: 'transaction', |
| 45 | + request: { |
| 46 | + headers: expect.any(Object), |
| 47 | + method: 'GET', |
| 48 | + url: expect.stringContaining('/agents/my-agent/user-123'), |
| 49 | + query_string: expect.any(String), |
| 50 | + }, |
| 51 | + transaction_info: { source: 'url' }, |
| 52 | + platform: 'javascript', |
| 53 | + event_id: expect.stringMatching(/[a-f0-9]{32}/), |
| 54 | + environment: expect.any(String), |
| 55 | + release: expect.any(String), |
| 56 | + sdk: { |
| 57 | + integrations: expect.any(Array), |
| 58 | + name: 'sentry.javascript.cloudflare', |
| 59 | + version: expect.any(String), |
| 60 | + packages: expect.any(Array), |
| 61 | + }, |
| 62 | + }); |
| 63 | +}); |
0 commit comments