Skip to content

Commit

Permalink
Merge branch 'develop' into cg/fetch-spans
Browse files Browse the repository at this point in the history
  • Loading branch information
chargome authored Jul 10, 2024
2 parents 8040638 + ed3d12f commit 5672ffe
Show file tree
Hide file tree
Showing 61 changed files with 544 additions and 383 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -995,6 +995,7 @@ jobs:
'angular-17',
'angular-18',
'aws-lambda-layer-cjs',
'aws-serverless-esm',
'node-express',
'create-react-app',
'create-next-app',
Expand Down
1 change: 1 addition & 0 deletions .secret_scan_ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
packages\/google-cloud-serverless\/test\/integrations\/private\.pem
44 changes: 43 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

- "You miss 100 percent of the chances you don't take. — Wayne Gretzky" — Michael Scott

## 8.16.0

### Important Changes

- **feat(nextjs): Use spans generated by Next.js for App Router (#12729)**
Expand All @@ -22,13 +24,53 @@ server component spans being descendants of that transaction. This means you wil
accurate. Note that this does not apply to the Edge runtime. For the Edge runtime, the SDK will emit transactions as it
has before.

Generally speaking, this change means that you will see less _transactions_ and more _spans_ in Sentry. Your will no
Generally speaking, this change means that you will see less _transactions_ and more _spans_ in Sentry. You will no
longer receive server component transactions like `Page Server Component (/path/to/route)` (unless using the Edge
runtime), and you will instead receive transactions for your App Router SSR requests that look like
`GET /path/to/route`.

If you are on Sentry SaaS, this may have an effect on your quota consumption: Less transactions, more spans.

- **- feat(nestjs): Add nest cron monitoring support (#12781)**

The `@sentry/nestjs` SDK now includes a `@SentryCron` decorator that can be used to augment the native NestJS `@Cron`
decorator to send check-ins to Sentry before and after each cron job run:

```typescript
import { Cron } from '@nestjs/schedule';
import { SentryCron, MonitorConfig } from '@sentry/nestjs';
import type { MonitorConfig } from '@sentry/types';

const monitorConfig: MonitorConfig = {
schedule: {
type: 'crontab',
value: '* * * * *',
},
checkinMargin: 2, // In minutes. Optional.
maxRuntime: 10, // In minutes. Optional.
timezone: 'America/Los_Angeles', // Optional.
};

export class MyCronService {
@Cron('* * * * *')
@SentryCron('my-monitor-slug', monitorConfig)
handleCron() {
// Your cron job logic here
}
}
```

### Other Changes

- feat(node): Allow to pass instrumentation config to `httpIntegration` (#12761)
- feat(nuxt): Add server error hook (#12796)
- feat(nuxt): Inject sentry config with Nuxt `addPluginTemplate` (#12760)
- fix: Apply stack frame metadata before event processors (#12799)
- fix(feedback): Add missing `h` import in `ScreenshotEditor` (#12784)
- fix(node): Ensure `autoSessionTracking` is enabled by default (#12790)
- ref(feedback): Let CropCorner inherit the existing h prop (#12814)
- ref(otel): Ensure we never swallow args for ContextManager (#12798)

## 8.15.0

- feat(core): allow unregistering callback through `on` (#11710)
Expand Down
4 changes: 2 additions & 2 deletions dev-packages/browser-integration-tests/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sentry-internal/browser-integration-tests",
"version": "8.15.0",
"version": "8.16.0",
"main": "index.js",
"license": "MIT",
"engines": {
Expand Down Expand Up @@ -43,7 +43,7 @@
"@babel/preset-typescript": "^7.16.7",
"@playwright/test": "^1.44.1",
"@sentry-internal/rrweb": "2.11.0",
"@sentry/browser": "8.15.0",
"@sentry/browser": "8.16.0",
"axios": "1.6.7",
"babel-loader": "^8.2.2",
"html-webpack-plugin": "^5.5.0",
Expand Down
2 changes: 1 addition & 1 deletion dev-packages/bundle-analyzer-scenarios/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sentry-internal/bundle-analyzer-scenarios",
"version": "8.15.0",
"version": "8.16.0",
"description": "Scenarios to test bundle analysis with",
"repository": "git://github.com/getsentry/sentry-javascript.git",
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/dev-packages/bundle-analyzer-scenarios",
Expand Down
5 changes: 3 additions & 2 deletions dev-packages/e2e-tests/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sentry-internal/e2e-tests",
"version": "8.15.0",
"version": "8.16.0",
"license": "MIT",
"private": true,
"scripts": {
Expand All @@ -23,7 +23,8 @@
"esbuild": "0.20.0",
"glob": "8.0.3",
"ts-node": "10.9.1",
"yaml": "2.2.2"
"yaml": "2.2.2",
"rimraf": "^5.0.0"
},
"volta": {
"extends": "../../package.json",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@sentry:registry=http://127.0.0.1:4873
@sentry-internal:registry=http://127.0.0.1:4873
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "node-express-app",
"version": "1.0.0",
"private": true,
"scripts": {
"start": "node src/run.mjs",
"test": "playwright test",
"clean": "npx rimraf node_modules pnpm-lock.yaml",
"test:build": "pnpm install",
"test:assert": "pnpm test"
},
"dependencies": {
"@sentry/aws-serverless": "* || latest"
},
"devDependencies": {
"@sentry-internal/test-utils": "link:../../../test-utils",
"@playwright/test": "^1.41.1",
"wait-port": "1.0.4"
},
"volta": {
"extends": "../../package.json"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { getPlaywrightConfig } from '@sentry-internal/test-utils';

// Fix urls not resolving to localhost on Node v17+
// See: https://github.com/axios/axios/issues/3821#issuecomment-1413727575
import { setDefaultResultOrder } from 'dns';
setDefaultResultOrder('ipv4first');

const eventProxyPort = 3031;

/**
* See https://playwright.dev/docs/test-configuration.
*/
const config = getPlaywrightConfig(
{ startCommand: '' },
{
/* Run your local dev server before starting the tests */
webServer: [
{
command: `node start-event-proxy.mjs && pnpm wait-port ${eventProxyPort}`,
port: eventProxyPort,
stdout: 'pipe',
},
],
},
);

export default config;
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import * as http from 'node:http';
import * as Sentry from '@sentry/aws-serverless';

const handler = Sentry.wrapHandler(async () => {
await new Promise(resolve => {
const req = http.request(
{
host: 'example.com',
},
res => {
res.on('data', d => {
process.stdout.write(d);
});

res.on('end', () => {
resolve();
});
},
);
req.end();
});

Sentry.startSpan({ name: 'manual-span', op: 'manual' }, () => {});
});

export { handler };
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"//": "This is a mock package.json file which is usually created by AWS when deploying the lambda. OTEL instrumentation tries to read this file to get the lambda version",
"name": "lambda",
"version": "1.0.0"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { handler } from './lambda-function.mjs';

// Simulate minimal event and context objects being passed to the handler by the AWS runtime
const event = {};
const context = {
invokedFunctionArn: 'arn:aws:lambda:us-east-1:123453789012:function:my-lambda',
functionName: 'my-lambda',
};

await handler(event, context);
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import child_process from 'child_process';

child_process.execSync('node ./src/run-lambda.mjs', {
stdio: 'inherit',
env: {
...process.env,
// On AWS, LAMBDA_TASK_ROOT is usually /var/task but for testing, we set it to the CWD to correctly apply our handler
LAMBDA_TASK_ROOT: process.cwd(),
_HANDLER: 'src/lambda-function.handler',

NODE_OPTIONS: '--import @sentry/aws-serverless/awslambda-auto',
SENTRY_DSN: 'http://public@localhost:3031/1337',
SENTRY_TRACES_SAMPLE_RATE: '1.0',
},
cwd: process.cwd(),
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { startEventProxyServer } from '@sentry-internal/test-utils';

startEventProxyServer({
port: 3031,
proxyServerName: 'aws-serverless-esm',
forwardToSentry: false,
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import * as child_process from 'child_process';
import { expect, test } from '@playwright/test';
import { waitForTransaction } from '@sentry-internal/test-utils';

test('AWS Serverless SDK sends events in ESM mode', async ({ request }) => {
const transactionEventPromise = waitForTransaction('aws-serverless-esm', transactionEvent => {
return transactionEvent?.transaction === 'my-lambda';
});

// Waiting for 1s here because attaching the listener for events in `waitForTransaction` is not synchronous
// Since in this test, we don't start a browser via playwright, we don't have the usual delays (page.goto, etc)
// which are usually enough for us to never have noticed this race condition before.
// This is a workaround but probably sufficient as long as we only experience it in this test.
await new Promise<void>(resolve =>
setTimeout(() => {
resolve();
}, 1000),
);

child_process.execSync('pnpm start', {
stdio: 'ignore',
});

const transactionEvent = await transactionEventPromise;

// shows the SDK sent a transaction
expect(transactionEvent.transaction).toEqual('my-lambda'); // name should be the function name
expect(transactionEvent.contexts?.trace).toEqual({
data: {
'sentry.sample_rate': 1,
'sentry.source': 'component',
'sentry.origin': 'auto.function.serverless',
'sentry.op': 'function.aws.lambda',
'otel.kind': 'INTERNAL',
},
op: 'function.aws.lambda',
origin: 'auto.function.serverless',
span_id: expect.any(String),
status: 'ok',
trace_id: expect.any(String),
});

expect(transactionEvent.spans).toHaveLength(2);

// shows that the Otel Http instrumentation is working
expect(transactionEvent.spans).toContainEqual(
expect.objectContaining({
data: expect.objectContaining({
'sentry.op': 'http.client',
'sentry.origin': 'auto.http.otel.http',
url: 'http://example.com/',
}),
description: 'GET http://example.com/',
op: 'http.client',
}),
);

// shows that the manual span creation is working
expect(transactionEvent.spans).toContainEqual(
expect.objectContaining({
data: expect.objectContaining({
'sentry.op': 'manual',
'sentry.origin': 'manual',
}),
description: 'manual-span',
op: 'manual',
}),
);
});
2 changes: 1 addition & 1 deletion dev-packages/external-contributor-gh-action/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@sentry-internal/external-contributor-gh-action",
"description": "An internal Github Action to add external contributors to the CHANGELOG.md file.",
"version": "8.15.0",
"version": "8.16.0",
"license": "MIT",
"engines": {
"node": ">=18"
Expand Down
6 changes: 3 additions & 3 deletions dev-packages/node-integration-tests/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sentry-internal/node-integration-tests",
"version": "8.15.0",
"version": "8.16.0",
"license": "MIT",
"engines": {
"node": ">=14.18"
Expand Down Expand Up @@ -31,8 +31,8 @@
"@nestjs/core": "^10.3.3",
"@nestjs/platform-express": "^10.3.3",
"@prisma/client": "5.9.1",
"@sentry/node": "8.15.0",
"@sentry/types": "8.15.0",
"@sentry/node": "8.16.0",
"@sentry/types": "8.16.0",
"@types/mongodb": "^3.6.20",
"@types/mysql": "^2.15.21",
"@types/pg": "^8.6.5",
Expand Down
2 changes: 1 addition & 1 deletion dev-packages/overhead-metrics/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"private": true,
"version": "8.15.0",
"version": "8.16.0",
"name": "@sentry-internal/overhead-metrics",
"main": "index.js",
"author": "Sentry",
Expand Down
2 changes: 1 addition & 1 deletion dev-packages/rollup-utils/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sentry-internal/rollup-utils",
"version": "8.15.0",
"version": "8.16.0",
"description": "Rollup utilities used at Sentry for the Sentry JavaScript SDK",
"repository": "git://github.com/getsentry/sentry-javascript.git",
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/rollup-utils",
Expand Down
2 changes: 1 addition & 1 deletion dev-packages/size-limit-gh-action/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@sentry-internal/size-limit-gh-action",
"description": "An internal Github Action to compare the current size of a PR against the one on develop.",
"version": "8.15.0",
"version": "8.16.0",
"license": "MIT",
"engines": {
"node": ">=18"
Expand Down
6 changes: 3 additions & 3 deletions dev-packages/test-utils/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"private": true,
"version": "8.15.0",
"version": "8.16.0",
"name": "@sentry-internal/test-utils",
"author": "Sentry",
"license": "MIT",
Expand Down Expand Up @@ -45,8 +45,8 @@
},
"devDependencies": {
"@playwright/test": "^1.44.1",
"@sentry/types": "8.15.0",
"@sentry/utils": "8.15.0"
"@sentry/types": "8.16.0",
"@sentry/utils": "8.16.0"
},
"volta": {
"extends": "../../package.json"
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
"version": "8.15.0",
"version": "8.16.0",
"npmClient": "yarn"
}
Loading

0 comments on commit 5672ffe

Please sign in to comment.