Skip to content

Commit

Permalink
feat(node-experimental): MVP for POTEL
Browse files Browse the repository at this point in the history
  • Loading branch information
mydea committed Jul 21, 2023
1 parent df7bb25 commit 0da5946
Show file tree
Hide file tree
Showing 43 changed files with 1,751 additions and 98 deletions.
57 changes: 30 additions & 27 deletions .craft.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,101 +6,104 @@ targets:
## 1. Base Packages, node or browser SDKs depend on
## 1.1 Types
- name: npm
id: "@sentry/types"
id: '@sentry/types'
includeNames: /^sentry-types-\d.*\.tgz$/
## 1.2 Utils
- name: npm
id: "@sentry/utils"
id: '@sentry/utils'
includeNames: /^sentry-utils-\d.*\.tgz$/
## 1.3 Core SDK
- name: npm
id: "@sentry/core"
id: '@sentry/core'
includeNames: /^sentry-core-\d.*\.tgz$/
## 1.4 Tracing package
- name: npm
id: "@sentry-internal/tracing"
id: '@sentry-internal/tracing'
includeNames: /^sentry-internal-tracing-\d.*\.tgz$/
## 1.5 Replay package (browser only)
- name: npm
id: "@sentry/replay"
id: '@sentry/replay'
includeNames: /^sentry-replay-\d.*\.tgz$/

## 2. Browser & Node SDKs
- name: npm
id: "@sentry/browser"
id: '@sentry/browser'
includeNames: /^sentry-browser-\d.*\.tgz$/
- name: npm
id: "@sentry/node"
id: '@sentry/node'
includeNames: /^sentry-node-\d.*\.tgz$/

## 3 Browser-based Packages
- name: npm
id: "@sentry/angular-ivy"
id: '@sentry/angular-ivy'
includeNames: /^sentry-angular-ivy-\d.*\.tgz$/
- name: npm
id: "@sentry/angular"
id: '@sentry/angular'
includeNames: /^sentry-angular-\d.*\.tgz$/
- name: npm
id: "@sentry/ember"
id: '@sentry/ember'
includeNames: /^sentry-ember-\d.*\.tgz$/
- name: npm
id: "@sentry/react"
id: '@sentry/react'
includeNames: /^sentry-react-\d.*\.tgz$/
- name: npm
id: "@sentry/svelte"
id: '@sentry/svelte'
includeNames: /^sentry-svelte-\d.*\.tgz$/
- name: npm
id: "@sentry/vue"
id: '@sentry/vue'
includeNames: /^sentry-vue-\d.*\.tgz$/
- name: npm
id: "@sentry/wasm"
id: '@sentry/wasm'
includeNames: /^sentry-wasm-\d.*\.tgz$/
- name: npm
id: "@sentry/integrations"
id: '@sentry/integrations'
includeNames: /^sentry-integrations-\d.*\.tgz$/

## 4. Node-based Packages
- name: npm
id: "@sentry/serverless"
id: '@sentry/serverless'
includeNames: /^sentry-serverless-\d.*\.tgz$/
- name: npm
id: "@sentry/opentelemetry-node"
id: '@sentry/opentelemetry-node'
includeNames: /^sentry-opentelemetry-node-\d.*\.tgz$/

## 5. Fullstack/Meta Frameworks (depending on Node and Browser or Framework SDKs)
- name: npm
id: "@sentry/nextjs"
id: '@sentry/nextjs'
includeNames: /^sentry-nextjs-\d.*\.tgz$/
- name: npm
id: "@sentry/remix"
id: '@sentry/remix'
includeNames: /^sentry-remix-\d.*\.tgz$/
- name: npm
id: "@sentry/sveltekit"
id: '@sentry/sveltekit'
includeNames: /^sentry-sveltekit-\d.*\.tgz$/
- name: npm
id: "@sentry/gatsby"
id: '@sentry/gatsby'
includeNames: /^sentry-gatsby-\d.*\.tgz$/

## 6. Other Packages
## 6.1
- name: npm
id: "@sentry-internal/typescript"
id: '@sentry-internal/typescript'
includeNames: /^sentry-internal-typescript-\d.*\.tgz$/
- name: npm
id: "@sentry-internal/eslint-plugin-sdk"
id: '@sentry-internal/eslint-plugin-sdk'
includeNames: /^sentry-internal-eslint-plugin-sdk-\d.*\.tgz$/
## 6.2
- name: npm
id: "@sentry-internal/eslint-config-sdk"
id: '@sentry-internal/eslint-config-sdk'
includeNames: /^sentry-internal-eslint-config-sdk-\d.*\.tgz$/

## 7. Deprecated packages we still release (but no packages depend on them anymore)
- name: npm
id: "@sentry/hub"
id: '@sentry/hub'
includeNames: /^sentry-hub-\d.*\.tgz$/
- name: npm
id: "@sentry/tracing"
id: '@sentry/tracing'
includeNames: /^sentry-tracing-\d.*\.tgz$/
- name: npm
id: '@sentry/node-experimental'
includeNames: /^sentry-node-experimental-\d.*\.tgz$/

# AWS Lambda Layer target
- name: aws-lambda-layer
Expand All @@ -118,7 +121,7 @@ targets:

# CDN Bundle Target
- name: gcs
id: "browser-cdn-bundles"
id: 'browser-cdn-bundles'
includeNames: /.*\.js.*$/
bucket: sentry-js-sdk
paths:
Expand Down
2 changes: 1 addition & 1 deletion docs/new-sdk-release-checklist.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ When you’re ready to make the first release, there are a couple of steps that
- [ ] 3) Add an `npm` target in `craft.yml` for the new package. Make sure to insert it in the right place, after all the Sentry dependencies of your package but before packages that depend on your new package (if applicable).
```yml
- name: npm
id: npm:@sentry/[yourPackage]
id: '@sentry/[yourPackage]'
includeNames: /^sentry-[yourPackage]-\d.*\.tgz$/
```
- [ ] 4) Cut a new release (as usual, see [Publishing Release](https://github.com/getsentry/sentry-javascript/blob/develop/docs/publishing-a-release.md))
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"packages/nextjs",
"packages/node",
"packages/node-integration-tests",
"packages/node-experimental",
"packages/opentelemetry-node",
"packages/react",
"packages/remix",
Expand Down
9 changes: 9 additions & 0 deletions packages/node-experimental/.eslintrc.js
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',
},
};
14 changes: 14 additions & 0 deletions packages/node-experimental/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Copyright (c) 2022 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.
66 changes: 66 additions & 0 deletions packages/node-experimental/README.md
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 (Preview)

[![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/)
1 change: 1 addition & 0 deletions packages/node-experimental/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('../../jest/jest.config.js');
76 changes: 76 additions & 0 deletions packages/node-experimental/package.json
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
}
3 changes: 3 additions & 0 deletions packages/node-experimental/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());
13 changes: 13 additions & 0 deletions packages/node-experimental/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Integrations as CoreIntegrations } from '@sentry/core';

import * as NodePreviewIntegrations from './integrations';

const INTEGRATIONS = {
...CoreIntegrations,
...NodePreviewIntegrations,
};

export { init } from './sdk/init';
export { INTEGRATIONS as Integrations };
export { getAutoPerformanceIntegrations } from './integrations/getAutoPerformanceIntegrations';
export * as Handlers from './sdk/handlers';
27 changes: 27 additions & 0 deletions packages/node-experimental/src/integrations/express.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import type { Instrumentation } from '@opentelemetry/instrumentation';
import { ExpressInstrumentation } from '@opentelemetry/instrumentation-express';
import type { Integration } from '@sentry/types';

import { NodePerformanceIntegration } from './lazy';

/**
* Express integration
*
* Capture tracing data for express.
*/
export class Express extends NodePerformanceIntegration<void> implements Integration {
/**
* @inheritDoc
*/
public static id: string = 'Express';

/**
* @inheritDoc
*/
public name: string = Express.id;

/** @inheritDoc */
public setupInstrumentation(): void | Instrumentation[] {
return [new ExpressInstrumentation()];
}
}
Loading

0 comments on commit 0da5946

Please sign in to comment.