Skip to content
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

feat(node): Add genericPool integration using opentelemetry instrumentation #13356

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
1adaaac
feat(node): add genericPool integration using opentelemetry instrumen…
Zen-cronic Aug 13, 2024
11b6ffe
Merge branch 'develop' into feat/genericPoolIntegration-node
Zen-cronic Aug 13, 2024
69f52db
feat(node): Add genericPool integration using opentelemetry instrumen…
Zen-cronic Aug 13, 2024
0c06d16
fix(nestjs): Exception filters in main app module are not being execu…
nicohrubec Aug 13, 2024
c0239b1
feat(deps): bump @prisma/instrumentation from 5.17.0 to 5.18.0 (#13327)
dependabot[bot] Aug 14, 2024
22878c7
ci: Streamline some caching (#13355)
mydea Aug 14, 2024
6d5c5c6
meta: Update Changelog for 8.26.0
Lms24 Aug 13, 2024
c1a775b
release: 8.26.0
getsentry-bot Aug 13, 2024
3db3ba0
ci: Streamline browser & node unit tests (#13307)
mydea Aug 14, 2024
94ad46a
fix(solidstart): Make back navigation test less flaky (#13374)
andreiborza Aug 14, 2024
5e26092
ci: Only store playwright cache on develop (#13358)
mydea Aug 14, 2024
d4c7a09
feat: Add options for passing nonces to feedback integration (#13347)
chargome Aug 14, 2024
fa93e11
ci: Improve size-limit CI action (#13348)
mydea Aug 14, 2024
e4129bc
test: Ensure browser-integration-tests cannot conflict due to build (…
mydea Aug 14, 2024
601a6bf
Revert "build: Bump node to 22.5.1" (#13367)
AbhiPrasad Aug 14, 2024
46988f3
fix(deno): Don't rely on `Deno.permissions.querySync` (#13378)
lforst Aug 14, 2024
7c6d97f
test(e2e): Fix flake in default browser e2e test (#13379)
Lms24 Aug 14, 2024
6dbffe8
test(e2e): Add Astro 4 E2E test app (#13375)
Lms24 Aug 14, 2024
2f11b7e
docs: Fix v7 changelog format and link (#13395)
charpeni Aug 16, 2024
a7aa35c
ci: Fix crypto not being available (#13385)
lforst Aug 16, 2024
ba9a704
ref: Add external contributor to CHANGELOG.md (#13400)
github-actions[bot] Aug 16, 2024
0d3d2a1
docs(cloudflare): Fix spacing in README snippet (#13368)
AbhiPrasad Aug 26, 2024
fba8cc7
feat(feedback): Improve error message for 403 errors (#13441)
c298lee Aug 26, 2024
f1182d3
feat(node): add genericPool integration using opentelemetry instrumen…
Zen-cronic Aug 13, 2024
43c40f8
feat(node): Add genericPool integration using opentelemetry instrumen…
Zen-cronic Aug 13, 2024
37cc42e
test(node): Add tests for genericPoolIntegration
Zen-cronic Aug 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/actions/install-dependencies/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: "Install yarn dependencies"
description: "Installs yarn dependencies and caches them."

outputs:
cache_key:
description: "The dependency cache key"
value: ${{ steps.compute_lockfile_hash.outputs.hash }}

runs:
using: "composite"
steps:
# we use a hash of yarn.lock as our cache key, because if it hasn't changed, our dependencies haven't changed,
# so no need to reinstall them
- name: Compute dependency cache key
id: compute_lockfile_hash
run: echo "hash=dependencies-${{ hashFiles('yarn.lock', 'packages/*/package.json', 'dev-packages/*/package.json') }}" >> "$GITHUB_OUTPUT"
shell: bash

- name: Check dependency cache
uses: actions/cache@v4
id: cache_dependencies
with:
path: ${{ env.CACHED_DEPENDENCY_PATHS }}
key: ${{ steps.compute_lockfile_hash.outputs.hash }}

- name: Install dependencies
if: steps.cache_dependencies.outputs.cache-hit != 'true'
run: yarn install --ignore-engines --frozen-lockfile
shell: bash
13 changes: 11 additions & 2 deletions .github/actions/install-playwright/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,23 @@ runs:
run: echo "version=$(node -p "require('@playwright/test/package.json').version")" >> $GITHUB_OUTPUT
shell: bash

- name: Cache playwright binaries
uses: actions/cache@v4
- name: Restore cached playwright binaries
uses: actions/cache/restore@v4
id: playwright-cache
with:
path: |
~/.cache/ms-playwright
key: playwright-${{ runner.os }}-${{ steps.playwright-version.outputs.version }}

# Only store cache on develop branch
- name: Store cached playwright binaries
uses: actions/cache/save@v4
if: github.event_name == 'push' && github.ref == 'refs/heads/develop'
with:
path: |
~/.cache/ms-playwright
key: playwright-${{ runner.os }}-${{ steps.playwright-version.outputs.version }}

# We always install all browsers, if uncached
- name: Install Playwright dependencies (uncached)
run: npx playwright install chromium webkit firefox --with-deps
Expand Down
41 changes: 8 additions & 33 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,22 +146,9 @@ jobs:
with:
node-version-file: 'package.json'

# we use a hash of yarn.lock as our cache key, because if it hasn't changed, our dependencies haven't changed,
# so no need to reinstall them
- name: Compute dependency cache key
id: compute_lockfile_hash
run: echo "hash=${{ hashFiles('yarn.lock', '**/package.json') }}" >> "$GITHUB_OUTPUT"

- name: Check dependency cache
uses: actions/cache@v4
id: cache_dependencies
with:
path: ${{ env.CACHED_DEPENDENCY_PATHS }}
key: ${{ steps.compute_lockfile_hash.outputs.hash }}

- name: Install dependencies
if: steps.cache_dependencies.outputs.cache-hit != 'true'
run: yarn install --ignore-engines --frozen-lockfile
- name: Install Dependencies
uses: ./.github/actions/install-dependencies
id: install_dependencies

- name: Check for Affected Nx Projects
uses: dkhunt27/[email protected]
Expand Down Expand Up @@ -200,7 +187,7 @@ jobs:
run: yarn build

outputs:
dependency_cache_key: ${{ steps.compute_lockfile_hash.outputs.hash }}
dependency_cache_key: ${{ steps.install_dependencies.outputs.cache_key }}
changed_node_integration: ${{ needs.job_get_metadata.outputs.changed_ci == 'true' || contains(steps.checkForAffected.outputs.affected, '@sentry-internal/node-integration-tests') }}
changed_remix: ${{ needs.job_get_metadata.outputs.changed_ci == 'true' || contains(steps.checkForAffected.outputs.affected, '@sentry/remix') }}
changed_node: ${{ needs.job_get_metadata.outputs.changed_ci == 'true' || contains(steps.checkForAffected.outputs.affected, '@sentry/node') }}
Expand Down Expand Up @@ -293,22 +280,9 @@ jobs:
with:
node-version-file: 'package.json'

# we use a hash of yarn.lock as our cache key, because if it hasn't changed, our dependencies haven't changed,
# so no need to reinstall them
- name: Compute dependency cache key
id: compute_lockfile_hash
run: echo "hash=${{ hashFiles('yarn.lock', '**/package.json') }}" >> "$GITHUB_OUTPUT"

- name: Check dependency cache
uses: actions/cache@v4
id: cache_dependencies
with:
path: ${{ env.CACHED_DEPENDENCY_PATHS }}
key: ${{ steps.compute_lockfile_hash.outputs.hash }}

- name: Install dependencies
if: steps.cache_dependencies.outputs.cache-hit != 'true'
run: yarn install --ignore-engines --frozen-lockfile
- name: Install Dependencies
uses: ./.github/actions/install-dependencies
id: install_dependencies

- name: Check file formatting
run: yarn lint:prettier && yarn lint:biome
Expand Down Expand Up @@ -873,6 +847,7 @@ jobs:
[
'angular-17',
'angular-18',
'astro-4',
'aws-lambda-layer-cjs',
'aws-serverless-esm',
'node-express',
Expand Down
54 changes: 54 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,60 @@

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

Work in this release was contributed by @charpeni. Thank you for your contribution!

## 8.26.0

### Important Changes

- **feat(node): Add `fsInstrumentation` (#13291)**

This release adds `fsIntegration`, an integration that instruments the `fs` API to the Sentry Node SDK. The
integration creates spans with naming patterns of `fs.readFile`, `fs.unlink`, and so on.

This integration is not enabled by default and needs to be registered in your `Sentry.init` call. You can configure
via options whether to include path arguments or error messages as span attributes when an fs call fails:

```js
Sentry.init({
integrations: [
Sentry.fsIntegration({
recordFilePaths: true,
recordErrorMessagesAsSpanAttributes: true,
}),
],
});
```

**WARNING:** This integration may add significant overhead to your application. Especially in scenarios with a lot of
file I/O, like for example when running a framework dev server, including this integration can massively slow down
your application.

### Other Changes

- feat(browser): Add spotlightBrowser integration (#13263)
- feat(browser): Allow sentry in safari extension background page (#13209)
- feat(browser): Send CLS as standalone span (experimental) (#13056)
- feat(core): Add OpenTelemetry-specific `getTraceData` implementation (#13281)
- feat(nextjs): Always add `browserTracingIntegration` (#13324)
- feat(nextjs): Always transmit trace data to the client (#13337)
- feat(nextjs): export SentryBuildOptions (#13296)
- feat(nextjs): Update `experimental_captureRequestError` to reflect `RequestInfo.path` change in Next.js canary
(#13344)

- feat(nuxt): Always add tracing meta tags (#13273)
- feat(nuxt): Set transaction name for server error (#13292)
- feat(replay): Add a replay-specific logger (#13256)
- feat(sveltekit): Add bundle size optimizations to plugin options (#13318)
- feat(sveltekit): Always add browserTracingIntegration (#13322)
- feat(tracing): Make long animation frames opt-out (#13255)
- fix(astro): Correctly extract request data (#13315)
- fix(astro): Only track access request headers in dynamic page requests (#13306)
- fix(nuxt): Add import line for disabled `autoImport` (#13342)
- fix(nuxt): Add vue to excludeEsmLoaderHooks array (#13346)
- fix(opentelemetry): Do not overwrite http span name if kind is internal (#13282)
- fix(remix): Ensure `origin` is correctly set for remix server spans (#13305)

Work in this release was contributed by @MonstraG, @undead-voron and @Zen-cronic. Thank you for your contributions!

## 8.25.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import fs from 'fs';
import path from 'path';
import * as fs from 'fs';
import * as path from 'path';
import { expect } from '@playwright/test';

import { TEST_HOST, sentryTest } from '../../../../utils/fixtures';
Expand Down Expand Up @@ -28,19 +28,22 @@ sentryTest('it does not download the SDK if the SDK was loaded in the meanwhile'
});
});

const tmpDir = await getLocalTestUrl({ testDir: __dirname, skipRouteHandler: true });

await page.route(`${TEST_HOST}/*.*`, route => {
const file = route.request().url().split('/').pop();

if (file === 'cdn.bundle.js') {
cdnLoadedCount++;
}

const filePath = path.resolve(__dirname, `./dist/${file}`);
const filePath = path.resolve(tmpDir, `./${file}`);

return fs.existsSync(filePath) ? route.fulfill({ path: filePath }) : route.continue();
});

const url = await getLocalTestUrl({ testDir: __dirname, skipRouteHandler: true });
const url = `${TEST_HOST}/index.html`;

const req = await waitForErrorRequestOnUrl(page, url);

const eventData = envelopeRequestParser(req);
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.25.0",
"version": "8.26.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.25.0",
"@sentry/browser": "8.26.0",
"axios": "1.6.7",
"babel-loader": "^8.2.2",
"html-webpack-plugin": "^5.5.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const config: PlaywrightTestConfig = {
],

globalSetup: require.resolve('./playwright.setup.ts'),
globalTeardown: require.resolve('./playwright.teardown.ts'),
};

export default config;
5 changes: 5 additions & 0 deletions dev-packages/browser-integration-tests/playwright.teardown.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import * as childProcess from 'child_process';

export default function globalTeardown(): void {
childProcess.execSync('yarn clean', { stdio: 'inherit', cwd: process.cwd() });
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import * as Sentry from '@sentry/browser';
// Import this separately so that generatePlugin can handle it for CDN scenarios
import { feedbackIntegration } from '@sentry/browser';

window.Sentry = Sentry;

Sentry.init({
dsn: 'https://[email protected]/1337',
integrations: [
feedbackIntegration({ tags: { from: 'integration init' }, styleNonce: 'foo1234', scriptNonce: 'foo1234' }),
],
});

document.addEventListener('securitypolicyviolation', () => {
const container = document.querySelector('#csp-violation');
if (container) {
container.innerText = 'CSP Violation';
}
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<meta
http-equiv="Content-Security-Policy"
content="style-src 'nonce-foo1234'; script-src sentry-test.io 'nonce-foo1234';"
/>
</head>
<body>
<div id="csp-violation" />
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import { expect } from '@playwright/test';

import { TEST_HOST, sentryTest } from '../../../utils/fixtures';
import { envelopeRequestParser, getEnvelopeType, shouldSkipFeedbackTest } from '../../../utils/helpers';

sentryTest('should capture feedback', async ({ getLocalTestUrl, page }) => {
if (shouldSkipFeedbackTest()) {
sentryTest.skip();
}

const feedbackRequestPromise = page.waitForResponse(res => {
const req = res.request();

const postData = req.postData();
if (!postData) {
return false;
}

try {
return getEnvelopeType(req) === 'feedback';
} catch (err) {
return false;
}
});

await page.route('https://dsn.ingest.sentry.io/**/*', route => {
return route.fulfill({
status: 200,
contentType: 'application/json',
body: JSON.stringify({ id: 'test-id' }),
});
});

const url = await getLocalTestUrl({ testDir: __dirname });

await page.goto(url);
await page.getByText('Report a Bug').click();
expect(await page.locator(':visible:text-is("Report a Bug")').count()).toEqual(1);
await page.locator('[name="name"]').fill('Jane Doe');
await page.locator('[name="email"]').fill('[email protected]');
await page.locator('[name="message"]').fill('my example feedback');
await page.locator('[data-sentry-feedback] .btn--primary').click();

const feedbackEvent = envelopeRequestParser((await feedbackRequestPromise).request());
expect(feedbackEvent).toEqual({
type: 'feedback',
breadcrumbs: expect.any(Array),
contexts: {
feedback: {
contact_email: '[email protected]',
message: 'my example feedback',
name: 'Jane Doe',
source: 'widget',
url: `${TEST_HOST}/index.html`,
},
trace: {
trace_id: expect.stringMatching(/\w{32}/),
span_id: expect.stringMatching(/\w{16}/),
},
},
level: 'info',
tags: {
from: 'integration init',
},
timestamp: expect.any(Number),
event_id: expect.stringMatching(/\w{32}/),
environment: 'production',
sdk: {
integrations: expect.arrayContaining(['Feedback']),
version: expect.any(String),
name: 'sentry.javascript.browser',
packages: expect.anything(),
},
request: {
url: `${TEST_HOST}/index.html`,
headers: {
'User-Agent': expect.stringContaining(''),
},
},
platform: 'javascript',
});
const cspContainer = await page.locator('#csp-violation');
expect(cspContainer).not.toContainText('CSP Violation');
});
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
fetch('http://localhost:7654/foo').then(() => {
fetch('http://sentry-test.io/foo').then(() => {
Sentry.captureException('test error');
});
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ sentryTest('captures Breadcrumb for basic GET request', async ({ getLocalTestUrl
data: {
method: 'GET',
status_code: 200,
url: 'http://localhost:7654/foo',
url: 'http://sentry-test.io/foo',
},
});
});
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
fetch(new Request('http://localhost:7654/foo')).then(() => {
fetch(new Request('http://sentry-test.io/foo')).then(() => {
Sentry.captureException('test error');
});
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ sentryTest('captures Breadcrumb for basic GET request that uses request object',
data: {
method: 'GET',
status_code: 200,
url: 'http://localhost:7654/foo',
url: 'http://sentry-test.io/foo',
},
});
});
Loading