-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
feat(profiling): js self profiling #7273
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
Merged
Merged
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 1db7355
feat(profiling): add files and remove isDebugBuild in favor of __DEBU…
JonasBa 38a0def
ref(lint): fix linter errors on most files
JonasBa 9c5b80e
ref(profile): convert half the profile
JonasBa e38c5a1
deps(sentry): start profiler
JonasBa 98e39b1
ref(profiling): cleanup warnings and add os/device info
JonasBa b552688
rollback yarn change
JonasBa 9e3bd71
feat(hub): move start transaction
JonasBa e134125
Remove span.start for profiler.stop so that we don't have idletimeout…
k-fish 9b8ddd1
feat(build): build esm/cjs and types
JonasBa a3be009
ref(profiling): update txn to txn|undefined type
JonasBa 360c1b8
test(profiling): add utils and tests for browser profiling integration
JonasBa 0b2ab3d
test(tracing): assert onStartRouteTransaction is called by route inst…
JonasBa c7ba372
fix(verdaccio): add pkg to verdaccio config
JonasBa 3ec2c90
eslint: run --fix
JonasBa 3f9220c
fix(profile): change platform to javascript
JonasBa d62e3aa
ref(profiling): move profiling under browser package
JonasBa f3ce17e
ref(profiling): remove undefined from txn type union in wrapStartTran…
JonasBa b3583e3
fix(profiling): fix test
JonasBa 70550a4
ref(profiling): rename profile and move it under types
JonasBa bb12550
chore(profiling): run linters
JonasBa 979862d
ref(profiling): split sendProfile to avoid a circular ref
JonasBa 060424f
ref(profiling): split cache
JonasBa b1f1158
chore(profiling): sort imports
JonasBa c23936d
Update packages/browser/src/profiling/hubextensions.ts
JonasBa 3863f34
Update packages/browser/src/profiling/integration.ts
JonasBa 58c7828
Update packages/browser/src/profiling/integration.ts
f3048df
lint
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| module.exports = { | ||
| env: { | ||
| browser: true, | ||
| }, | ||
| extends: ['../../.eslintrc.js'], | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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. | ||
|
|
||
| [](https://www.npmjs.com/package/@sentry/profiling-browser) | ||
| [](https://www.npmjs.com/package/@sentry/profiling-browser) | ||
| [](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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| const baseConfig = require('../../jest/jest.config.js'); | ||
|
|
||
| module.exports = baseConfig; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" | ||
| }, | ||
| "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.
Outdated
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" | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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()); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.