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(profiling): js self profiling #7273

Merged
merged 28 commits into from
Mar 2, 2023
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
2e1d6ef
feat(profiling): add boilerplate
JonasBa Feb 17, 2023
1db7355
feat(profiling): add files and remove isDebugBuild in favor of __DEBU…
JonasBa Feb 17, 2023
38a0def
ref(lint): fix linter errors on most files
JonasBa Feb 17, 2023
9c5b80e
ref(profile): convert half the profile
JonasBa Feb 17, 2023
e38c5a1
deps(sentry): start profiler
JonasBa Feb 22, 2023
98e39b1
ref(profiling): cleanup warnings and add os/device info
JonasBa Feb 23, 2023
b552688
rollback yarn change
JonasBa Feb 23, 2023
9e3bd71
feat(hub): move start transaction
JonasBa Feb 23, 2023
e134125
Remove span.start for profiler.stop so that we don't have idletimeout…
k-fish Feb 23, 2023
9b8ddd1
feat(build): build esm/cjs and types
JonasBa Feb 24, 2023
a3be009
ref(profiling): update txn to txn|undefined type
JonasBa Feb 24, 2023
360c1b8
test(profiling): add utils and tests for browser profiling integration
JonasBa Feb 27, 2023
0b2ab3d
test(tracing): assert onStartRouteTransaction is called by route inst…
JonasBa Feb 27, 2023
c7ba372
fix(verdaccio): add pkg to verdaccio config
JonasBa Feb 27, 2023
3ec2c90
eslint: run --fix
JonasBa Feb 27, 2023
3f9220c
fix(profile): change platform to javascript
JonasBa Mar 1, 2023
d62e3aa
ref(profiling): move profiling under browser package
JonasBa Mar 1, 2023
f3ce17e
ref(profiling): remove undefined from txn type union in wrapStartTran…
JonasBa Mar 1, 2023
b3583e3
fix(profiling): fix test
JonasBa Mar 1, 2023
70550a4
ref(profiling): rename profile and move it under types
JonasBa Mar 1, 2023
bb12550
chore(profiling): run linters
JonasBa Mar 1, 2023
979862d
ref(profiling): split sendProfile to avoid a circular ref
JonasBa Mar 1, 2023
060424f
ref(profiling): split cache
JonasBa Mar 1, 2023
b1f1158
chore(profiling): sort imports
JonasBa Mar 1, 2023
c23936d
Update packages/browser/src/profiling/hubextensions.ts
JonasBa Mar 2, 2023
3863f34
Update packages/browser/src/profiling/integration.ts
JonasBa Mar 2, 2023
58c7828
Update packages/browser/src/profiling/integration.ts
lforst Mar 2, 2023
f3048df
lint
lforst Mar 2, 2023
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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"packages/node",
"packages/node-integration-tests",
"packages/opentelemetry-node",
"packages/profiling-browser",
"packages/react",
"packages/remix",
"packages/replay",
Expand Down
6 changes: 6 additions & 0 deletions packages/e2e-tests/verdaccio-config/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ packages:
unpublish: $all
# proxy: npmjs # Don't proxy for E2E tests!

'@sentry/profiling-browser':
access: $all
publish: $all
unpublish: $all
# proxy: npmjs # Don't proxy for E2E tests!

'@sentry/react':
access: $all
publish: $all
Expand Down
6 changes: 6 additions & 0 deletions packages/profiling-browser/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
env: {
browser: true,
},
extends: ['../../.eslintrc.js'],
};
14 changes: 14 additions & 0 deletions packages/profiling-browser/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Copyright (c) 2023 Sentry (https://sentry.io) and individual contributors. All rights reserved.

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 the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
44 changes: 44 additions & 0 deletions packages/profiling-browser/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<p align="center">
<a href="https://sentry.io/?utm_source=github&utm_medium=logo" target="_blank">
<img src="https://sentry-brand.storage.googleapis.com/sentry-wordmark-dark-280x84.png" alt="Sentry" width="280" height="84">
</a>
</p>

# Official Sentry Profiling SDK for Browser Profiling (internal proof of concept not intended for production use)
This package is not intended for production use and should be treated as experimental/unstable.

[![npm version](https://img.shields.io/npm/v/@sentry/profiling-browser.svg)](https://www.npmjs.com/package/@sentry/profiling-browser)
[![npm dm](https://img.shields.io/npm/dm/@sentry/profiling-browser.svg)](https://www.npmjs.com/package/@sentry/profiling-browser)
[![npm dt](https://img.shields.io/npm/dt/@sentry/profiling-browser.svg)](https://www.npmjs.com/package/@sentry/profiling-browser)

## Usage 🔥
@TODO explaind the required 'Document-Policy': 'js-profiling' header

```javascript
import * as Sentry from "@sentry/browser";
import { BrowserTracing } from "@sentry/tracing";
import { ProfilingIntegration } from '@sentry/profiling-browser';

Sentry.init({
dsn: 'https://[email protected]/6625302',
tracesSampleRate: 1,
profilesSampleRate: 1, // Set profilesSampleRate
integrations: [
new BrowserTracing(),
new ProfilingIntegration() // Add profiling integration
]
});
```

Sentry SDK will now automatically profile all transactions, even the ones which may be started as a result of using an automatic instrumentation integration.

```javascript
const transaction = Sentry.startTransaction({ name: 'I will do some work' });

// The code between startTransaction and transaction.finish will be profiled

transaction.finish();
```

## FAQ 💭
@TODO
3 changes: 3 additions & 0 deletions packages/profiling-browser/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const baseConfig = require('../../jest/jest.config.js');

module.exports = baseConfig;
56 changes: 56 additions & 0 deletions packages/profiling-browser/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"name": "@sentry/profiling-browser",
"version": "7.38.0",
"description": "Official Sentry SDK for browser profiling",
"repository": "git://github.com/getsentry/sentry-javascript.git",
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/profiling-browser",
"author": "Sentry",
"license": "MIT",
"engines": {
"node": ">=8"
},
"sideEffects": [
"./build/cjs/index.js",
"./build/esm/index.js"
],
"main": "build/cjs/index.js",
"module": "build/esm/index.js",
"types": "build/types/index.d.ts",
"publishConfig": {
"access": "public"
JonasBa marked this conversation as resolved.
Show resolved Hide resolved
},
"dependencies": {
"lru_map": "^0.4.1"
},
"peerDependencies": {
"@sentry/browser": "7.38.0",
"@sentry/core": "^7.38.0",
"@sentry/types": "7.38.0",
"@sentry/utils": "7.38.0"
JonasBa marked this conversation as resolved.
Show resolved Hide resolved
},
"devDependencies": {},
"scripts": {
"build": "run-p build:transpile build:types",
"build:dev": "yarn build",
"build:transpile": "rollup -c rollup.npm.config.js",
"build:types": "tsc -p tsconfig.types.json",
"build:watch": "run-p build:transpile:watch build:types:watch",
"build:dev:watch": "yarn build:watch",
"build:transpile:watch": "rollup -c rollup.npm.config.js --watch",
"build:types:watch": "tsc -p tsconfig.types.json --watch",
"build:tarball": "ts-node ../../scripts/prepack.ts && npm pack ./build",
"circularDepCheck": "madge --circular src/index.ts",
"clean": "rimraf build coverage sentry-svelte-*.tgz",
"fix": "run-s fix:eslint fix:prettier",
"fix:eslint": "eslint . --format stylish --fix",
"fix:prettier": "prettier --write \"{src,test,scripts}/**/**.ts\"",
"lint": "run-s lint:prettier lint:eslint",
"lint:eslint": "eslint . --format stylish",
"lint:prettier": "prettier --check \"{src,test,scripts}/**/**.ts\"",
"test": "jest",
"test:watch": "jest --watch"
},
"volta": {
"extends": "../../package.json"
}
}
3 changes: 3 additions & 0 deletions packages/profiling-browser/rollup.npm.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { makeBaseNPMConfig, makeNPMConfigVariants } from '../../rollup/index.js';

export default makeNPMConfigVariants(makeBaseNPMConfig());
Loading