Skip to content

Commit

Permalink
Merge branch 'develop' into fn/replay-unwrapped-setTimeout-billy
Browse files Browse the repository at this point in the history
  • Loading branch information
billyvg committed May 21, 2024
2 parents f7a60d5 + abe31ba commit e9de4b7
Show file tree
Hide file tree
Showing 84 changed files with 1,099 additions and 496 deletions.
26 changes: 26 additions & 0 deletions .size-limit.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,19 @@ module.exports = [
'node:http',
'node:https',
'node:diagnostics_channel',
'node:perf_hooks',
'node:worker_threads',
'node:inspector',
'node:path',
'node:fs',
'node:stream',
'node:os',
'node:net',
'node:zlib',
'node:child_process',
'node:tls',
'node:async_hooks',
'node:util',
'async_hooks',
'child_process',
'fs',
Expand All @@ -220,6 +233,19 @@ module.exports = [
'node:http',
'node:https',
'node:diagnostics_channel',
'node:perf_hooks',
'node:worker_threads',
'node:inspector',
'node:path',
'node:fs',
'node:stream',
'node:os',
'node:net',
'node:zlib',
'node:child_process',
'node:tls',
'node:async_hooks',
'node:util',
'async_hooks',
'child_process',
'perf_hooks',
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2024 Functional Software, Inc. dba Sentry
Copyright (c) 2012-2024 Functional Software, Inc. dba Sentry

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import type { PlaywrightTestConfig } from '@playwright/test';
import { devices } from '@playwright/test';

const connectPort = 3030;
Expand All @@ -7,7 +6,7 @@ const eventProxyPort = 3031;
/**
* See https://playwright.dev/docs/test-configuration.
*/
const config: PlaywrightTestConfig = {
const config = {
testDir: './tests',
/* Maximum time one test can run for. */
timeout: 150_000,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,20 +72,22 @@ test('Sends an API route transaction', async ({ baseURL }) => {
},
{
data: {
'sentry.origin': 'manual',
'sentry.origin': 'auto.http.otel.connect',
'sentry.op': 'request_handler.connect',
'http.route': '/test-transaction',
'connect.type': 'request_handler',
'connect.name': '/test-transaction',
'otel.kind': 'INTERNAL',
},
description: 'request handler - /test-transaction',
op: 'request_handler.connect',
description: '/test-transaction',
parent_span_id: expect.any(String),
span_id: expect.any(String),
start_timestamp: expect.any(Number),
status: 'ok',
timestamp: expect.any(Number),
trace_id: expect.any(String),
origin: 'manual',
origin: 'auto.http.otel.connect',
},
],
transaction: 'GET /test-transaction',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
"strict": true,
"noEmit": true
},
"include": ["*.ts"]
"include": ["src/*.ts"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,10 @@ test('Should record a transaction for route with parameters', async ({ request }
'http.route': '/',
'otel.kind': 'INTERNAL',
'sentry.origin': 'auto.http.otel.express',
'sentry.op': 'middleware.express',
},
description: 'middleware - query',
op: 'middleware.express',
description: 'query',
origin: 'auto.http.otel.express',
parent_span_id: expect.any(String),
span_id: expect.any(String),
Expand All @@ -86,8 +88,10 @@ test('Should record a transaction for route with parameters', async ({ request }
'http.route': '/',
'otel.kind': 'INTERNAL',
'sentry.origin': 'auto.http.otel.express',
'sentry.op': 'middleware.express',
},
description: 'middleware - expressInit',
op: 'middleware.express',
description: 'expressInit',
origin: 'auto.http.otel.express',
parent_span_id: expect.any(String),
span_id: expect.any(String),
Expand All @@ -104,8 +108,10 @@ test('Should record a transaction for route with parameters', async ({ request }
'http.route': '/test-transaction/:param',
'otel.kind': 'INTERNAL',
'sentry.origin': 'auto.http.otel.express',
'sentry.op': 'request_handler.express',
},
description: 'request handler - /test-transaction/:param',
op: 'request_handler.express',
description: '/test-transaction/:param',
origin: 'auto.http.otel.express',
parent_span_id: expect.any(String),
span_id: expect.any(String),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"@types/node": "18.15.1",
"express": "4.19.2",
"typescript": "4.9.5",
"zod": "^3.22.4"
"zod": "~3.22.4"
},
"devDependencies": {
"@sentry-internal/event-proxy-server": "link:../../../event-proxy-server",
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
import { expect, test } from '@playwright/test';
import { waitForTransaction } from '@sentry-internal/event-proxy-server';
import axios, { AxiosError } from 'axios';

const authToken = process.env.E2E_TEST_AUTH_TOKEN;
const sentryTestOrgSlug = process.env.E2E_TEST_SENTRY_ORG_SLUG;
const sentryTestProject = process.env.E2E_TEST_SENTRY_TEST_PROJECT;
const EVENT_POLLING_TIMEOUT = 90_000;

test('Sends an API route transaction', async ({ baseURL }) => {
const pageloadTransactionEventPromise = waitForTransaction('node-express', transactionEvent => {
return (
transactionEvent?.contexts?.trace?.op === 'http.server' &&
transactionEvent?.transaction === 'GET /test-transaction'
);
});

await axios.get(`${baseURL}/test-transaction`);

const transactionEvent = await pageloadTransactionEventPromise;
const transactionEventId = transactionEvent.event_id;

expect(transactionEvent.contexts?.trace).toEqual({
data: {
'sentry.source': 'route',
'sentry.origin': 'auto.http.otel.http',
'sentry.op': 'http.server',
'sentry.sample_rate': 1,
url: 'http://localhost:3030/test-transaction',
'otel.kind': 'SERVER',
'http.response.status_code': 200,
'http.url': 'http://localhost:3030/test-transaction',
'http.host': 'localhost:3030',
'net.host.name': 'localhost',
'http.method': 'GET',
'http.scheme': 'http',
'http.target': '/test-transaction',
'http.user_agent': 'axios/1.6.7',
'http.flavor': '1.1',
'net.transport': 'ip_tcp',
'net.host.ip': expect.any(String),
'net.host.port': expect.any(Number),
'net.peer.ip': expect.any(String),
'net.peer.port': expect.any(Number),
'http.status_code': 200,
'http.status_text': 'OK',
'http.route': '/test-transaction',
},
op: 'http.server',
span_id: expect.any(String),
status: 'ok',
trace_id: expect.any(String),
origin: 'auto.http.otel.http',
});

expect(transactionEvent).toEqual(
expect.objectContaining({
transaction: 'GET /test-transaction',
type: 'transaction',
transaction_info: {
source: 'route',
},
}),
);

const spans = transactionEvent.spans || [];

expect(spans).toContainEqual({
data: {
'sentry.origin': 'auto.http.otel.express',
'sentry.op': 'middleware.express',
'http.route': '/',
'express.name': 'query',
'express.type': 'middleware',
'otel.kind': 'INTERNAL',
},
description: 'query',
op: 'middleware.express',
origin: 'auto.http.otel.express',
parent_span_id: expect.any(String),
span_id: expect.any(String),
start_timestamp: expect.any(Number),
status: 'ok',
timestamp: expect.any(Number),
trace_id: expect.any(String),
});

expect(spans).toContainEqual({
data: {
'sentry.origin': 'auto.http.otel.express',
'sentry.op': 'middleware.express',
'http.route': '/',
'express.name': 'expressInit',
'express.type': 'middleware',
'otel.kind': 'INTERNAL',
},
description: 'expressInit',
op: 'middleware.express',
origin: 'auto.http.otel.express',
parent_span_id: expect.any(String),
span_id: expect.any(String),
start_timestamp: expect.any(Number),
status: 'ok',
timestamp: expect.any(Number),
trace_id: expect.any(String),
});

expect(spans).toContainEqual({
data: {
'sentry.origin': 'auto.http.otel.express',
'sentry.op': 'request_handler.express',
'http.route': '/test-transaction',
'express.name': '/test-transaction',
'express.type': 'request_handler',
'otel.kind': 'INTERNAL',
},
description: '/test-transaction',
op: 'request_handler.express',
origin: 'auto.http.otel.express',
parent_span_id: expect.any(String),
span_id: expect.any(String),
start_timestamp: expect.any(Number),
status: 'ok',
timestamp: expect.any(Number),
trace_id: expect.any(String),
});

await expect
.poll(
async () => {
try {
const response = await axios.get(
`https://sentry.io/api/0/projects/${sentryTestOrgSlug}/${sentryTestProject}/events/${transactionEventId}/`,
{ headers: { Authorization: `Bearer ${authToken}` } },
);

return response.status;
} catch (e) {
if (e instanceof AxiosError && e.response) {
if (e.response.status !== 404) {
throw e;
} else {
return e.response.status;
}
} else {
throw e;
}
}
},
{
timeout: EVENT_POLLING_TIMEOUT,
},
)
.toBe(200);
});
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,30 @@ test('Sends successful transaction', async ({ baseURL }) => {
},
}),
);

const spans = transactionEvent.spans || [];

expect(spans).toEqual([
{
data: {
'hapi.type': 'router',
'http.method': 'GET',
'http.route': '/test-success',
'otel.kind': 'INTERNAL',
'sentry.op': 'router.hapi',
'sentry.origin': 'auto.http.otel.hapi',
},
description: 'GET /test-success',
op: 'router.hapi',
origin: 'auto.http.otel.hapi',
parent_span_id: expect.any(String),
span_id: expect.any(String),
start_timestamp: expect.any(Number),
status: 'ok',
timestamp: expect.any(Number),
trace_id: expect.any(String),
},
]);
});

test('Sends parameterized transactions to Sentry', async ({ baseURL }) => {
Expand Down
Loading

0 comments on commit e9de4b7

Please sign in to comment.