-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(node-experimental): Add
@sentry/node-experimental
package as M…
…VP for POTEL (#8609) This introduces a new package `@sentry/node-experimental`, which is an MVP implementation for Performance powered by OTEL (POTEL). This package provides a wrapper over `@sentry/node` (also using `@sentry/opentelemetry-node`) which uses opentelemetry for performance instrumentation under the hood. This is all abstracted away from the user, they only need to do: ```js import * as Sentry from '@sentry/node-experimental'; Sentry.init({ dsn: 'my-dsn', tracesSampleRate: 0.1 }); ``` And it will set up all the necessary integrations etc. for the user, including the default integrations + any applying performance integrations. For this, I added all performance integrations that exist for node, minus undici (which will take some more work to get going), plus some new stuff: mysql, fastify, nest. Also, mongoose is it's own integration now, not handled via mongo anymore. Note that I've only manually tested express & http so far. All others still need to be verified etc. But this is really a POC, which may go somewhere or not - by publishing this, it becomes super easy to try this in various scenarios. I have tweaked the Http integration to create more or less the same output as we're used to for Sentry. I also made small tweaks to `@sentry/opentelemetry-node` to allow us to communicate with this a bit better. There are two main use cases I've identified there: * Tell the span processor to drop a span (=not send it to Sentry). For this, I added dedicated hooks. * Add some specific data/context/tags/metadata to an otel span, that should be added to the resulting sentry span. For this, I added utils which keep a map of data to be added in `spanEnd`. --------- Co-authored-by: Lukas Stracke <lukas.stracke@sentry.io>
- Loading branch information
Showing
47 changed files
with
1,729 additions
and
107 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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,9 @@ | ||
module.exports = { | ||
env: { | ||
node: true, | ||
}, | ||
extends: ['../../.eslintrc.js'], | ||
rules: { | ||
'@sentry-internal/sdk/no-optional-chaining': 'off', | ||
}, | ||
}; |
This file contains 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 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,66 @@ | ||
<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 SDK for Node (EXPERIMENTAL) | ||
|
||
[![npm version](https://img.shields.io/npm/v/@sentry/node-experimental.svg)](https://www.npmjs.com/package/@sentry/node-experimental) | ||
[![npm dm](https://img.shields.io/npm/dm/@sentry/node-experimental.svg)](https://www.npmjs.com/package/@sentry/node-experimental) | ||
[![npm dt](https://img.shields.io/npm/dt/@sentry/node-experimental.svg)](https://www.npmjs.com/package/@sentry/node-experimental) | ||
|
||
This is a WIP, proof of concept implementation of a Node SDK that uses OpenTelemetry for performance instrumentation under the hood. | ||
|
||
THIS MAY/WILL BREAK IN MANY UNEXPECTED WAYS. We may remove, add, change any of the integrations, add/remove any exports, etc. | ||
This package is **NOT READY TO USE IN ANY FORM OF PRODUCTION ENVIRONMENT**! | ||
|
||
This SDK is **considered experimental and in an alpha state**. It may experience breaking changes, and may be discontinued at any time. Please reach out on | ||
[GitHub](https://github.com/getsentry/sentry-javascript/issues/new/choose) if you have any feedback/concerns. | ||
|
||
## Installation | ||
|
||
```bash | ||
npm install @sentry/node-experimental | ||
|
||
# Or yarn | ||
yarn add @sentry/node-experimental | ||
``` | ||
|
||
## Usage | ||
|
||
```js | ||
// ES5 Syntax | ||
const Sentry = require('@sentry/node-experimental'); | ||
// ES6 Syntax | ||
import * as Sentry from '@sentry/node-experimental'; | ||
|
||
Sentry.init({ | ||
dsn: '__DSN__', | ||
// ... | ||
}); | ||
``` | ||
|
||
Note that it is necessary to initialize Sentry **before you import any package that may be instrumented by us**. | ||
|
||
## Available (Performance) Integrations | ||
|
||
* Http | ||
* Express | ||
* Fastify | ||
* Nest | ||
* Mysql | ||
* Mysql2 | ||
* GraphQL | ||
* Mongo | ||
* Mongoose | ||
* Postgres | ||
* Prisma | ||
|
||
All of these are auto-discovered, you don't need to configure anything for performance. | ||
You still need to register middlewares etc. for error capturing. | ||
Other, non-performance integrations from `@sentry/node` are also available (except for Undici). | ||
|
||
## Links | ||
|
||
- [Official SDK Docs](https://docs.sentry.io/quickstart/) |
This file contains 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 @@ | ||
module.exports = require('../../jest/jest.config.js'); |
This file contains 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,76 @@ | ||
{ | ||
"name": "@sentry/node-experimental", | ||
"version": "7.60.0", | ||
"description": "Experimental version of a Node SDK using OpenTelemetry for performance instrumentation", | ||
"repository": "git://github.com/getsentry/sentry-javascript.git", | ||
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/node-experimental", | ||
"author": "Sentry", | ||
"license": "MIT", | ||
"engines": { | ||
"node": ">=14" | ||
}, | ||
"main": "build/cjs/index.js", | ||
"module": "build/esm/index.js", | ||
"types": "build/types/index.d.ts", | ||
"typesVersions": { | ||
"<4.9": { | ||
"build/types/index.d.ts": [ | ||
"build/types-ts3.8/index.d.ts" | ||
] | ||
} | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"dependencies": { | ||
"@opentelemetry/api": "~1.4.1", | ||
"@opentelemetry/instrumentation": "~0.41.0", | ||
"@opentelemetry/instrumentation-fastify": "~0.32.0", | ||
"@opentelemetry/instrumentation-http": "~0.41.0", | ||
"@opentelemetry/instrumentation-express": "~0.33.0", | ||
"@opentelemetry/instrumentation-graphql": "~0.35.0", | ||
"@opentelemetry/instrumentation-mongodb": "~0.36.0", | ||
"@opentelemetry/instrumentation-mongoose": "~0.33.0", | ||
"@opentelemetry/instrumentation-mysql": "~0.34.0", | ||
"@opentelemetry/instrumentation-mysql2": "~0.34.0", | ||
"@opentelemetry/instrumentation-pg": "~0.36.0", | ||
"@opentelemetry/instrumentation-nestjs-core": "~0.33.0", | ||
"@opentelemetry/semantic-conventions": "~1.15.0", | ||
"@opentelemetry/sdk-trace-node": "~1.15.0", | ||
"@prisma/instrumentation": "~5.0.0", | ||
"@sentry/core": "7.60.0", | ||
"@sentry/node": "7.60.0", | ||
"@sentry/opentelemetry-node": "7.60.0", | ||
"@sentry/types": "7.60.0", | ||
"@sentry/utils": "7.60.0" | ||
}, | ||
"scripts": { | ||
"build": "run-p build:transpile build:types", | ||
"build:dev": "yarn build", | ||
"build:transpile": "rollup -c rollup.npm.config.js", | ||
"build:types": "run-s build:types:core build:types:downlevel", | ||
"build:types:core": "tsc -p tsconfig.types.json", | ||
"build:types:downlevel": "yarn downlevel-dts build/types build/types-ts3.8 --to ts3.8", | ||
"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-node-experimental-*.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": "yarn test:jest", | ||
"test:jest": "jest", | ||
"test:watch": "jest --watch", | ||
"yalc:publish": "ts-node ../../scripts/prepack.ts && yalc publish build --push" | ||
}, | ||
"volta": { | ||
"extends": "../../package.json" | ||
}, | ||
"sideEffects": false | ||
} |
This file contains 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()); |
This file contains 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,13 @@ | ||
import { Integrations as CoreIntegrations } from '@sentry/core'; | ||
|
||
import * as NodeExperimentalIntegrations from './integrations'; | ||
|
||
const INTEGRATIONS = { | ||
...CoreIntegrations, | ||
...NodeExperimentalIntegrations, | ||
}; | ||
|
||
export { init } from './sdk/init'; | ||
export { INTEGRATIONS as Integrations }; | ||
export { getAutoPerformanceIntegrations } from './integrations/getAutoPerformanceIntegrations'; | ||
export * as Handlers from './sdk/handlers'; |
Oops, something went wrong.