Skip to content

Commit

Permalink
feat(profiling-node): [v7] Expose nodeProfilingIntegration (#10864)
Browse files Browse the repository at this point in the history
  • Loading branch information
mydea committed Feb 29, 2024
1 parent 3f5b962 commit beed7f6
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 44 deletions.
82 changes: 42 additions & 40 deletions MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,46 +157,48 @@ integrations from the `Integrations.XXX` hash, is deprecated in favor of using t

The following list shows how integrations should be migrated:

| Old | New | Packages |
| ---------------------------- | ----------------------------------- | ------------------------------------------------------------------------------------------------------- |
| `new BrowserTracing()` | `browserTracingIntegration()` | `@sentry/browser` |
| `new InboundFilters()` | `inboundFiltersIntegration()` | `@sentry/core`, `@sentry/browser`, `@sentry/node`, `@sentry/deno`, `@sentry/bun`, `@sentry/vercel-edge` |
| `new FunctionToString()` | `functionToStringIntegration()` | `@sentry/core`, `@sentry/browser`, `@sentry/node`, `@sentry/deno`, `@sentry/bun`, `@sentry/vercel-edge` |
| `new LinkedErrors()` | `linkedErrorsIntegration()` | `@sentry/core`, `@sentry/browser`, `@sentry/node`, `@sentry/deno`, `@sentry/bun`, `@sentry/vercel-edge` |
| `new ModuleMetadata()` | `moduleMetadataIntegration()` | `@sentry/core`, `@sentry/browser` |
| `new RequestData()` | `requestDataIntegration()` | `@sentry/core`, `@sentry/node`, `@sentry/deno`, `@sentry/bun`, `@sentry/vercel-edge` |
| `new Wasm() ` | `wasmIntegration()` | `@sentry/wasm` |
| `new Replay()` | `replayIntegration()` | `@sentry/browser` |
| `new ReplayCanvas()` | `replayCanvasIntegration()` | `@sentry/browser` |
| `new Feedback()` | `feedbackIntegration()` | `@sentry/browser` |
| `new CaptureConsole()` | `captureConsoleIntegration()` | `@sentry/integrations` |
| `new Debug()` | `debugIntegration()` | `@sentry/integrations` |
| `new Dedupe()` | `dedupeIntegration()` | `@sentry/browser`, `@sentry/integrations`, `@sentry/deno` |
| `new ExtraErrorData()` | `extraErrorDataIntegration()` | `@sentry/integrations` |
| `new ReportingObserver()` | `reportingObserverIntegration()` | `@sentry/integrations` |
| `new RewriteFrames()` | `rewriteFramesIntegration()` | `@sentry/integrations` |
| `new SessionTiming()` | `sessionTimingIntegration()` | `@sentry/integrations` |
| `new HttpClient()` | `httpClientIntegration()` | `@sentry/integrations` |
| `new ContextLines()` | `contextLinesIntegration()` | `@sentry/integrations`, `@sentry/node`, `@sentry/deno`, `@sentry/bun` |
| `new Breadcrumbs()` | `breadcrumbsIntegration()` | `@sentry/browser`, `@sentry/deno` |
| `new GlobalHandlers()` | `globalHandlersIntegration()` | `@sentry/browser` , `@sentry/deno` |
| `new HttpContext()` | `httpContextIntegration()` | `@sentry/browser` |
| `new TryCatch()` | `browserApiErrorsIntegration()` | `@sentry/browser`, `@sentry/deno` |
| `new VueIntegration()` | `vueIntegration()` | `@sentry/vue` |
| `new DenoContext()` | `denoContextIntegration()` | `@sentry/deno` |
| `new DenoCron()` | `denoCronIntegration()` | `@sentry/deno` |
| `new NormalizePaths()` | `normalizePathsIntegration()` | `@sentry/deno` |
| `new Console()` | `consoleIntegration()` | `@sentry/node` |
| `new Context()` | `nodeContextIntegration()` | `@sentry/node` |
| `new Modules()` | `modulesIntegration()` | `@sentry/node` |
| `new OnUncaughtException()` | `onUncaughtExceptionIntegration()` | `@sentry/node` |
| `new OnUnhandledRejection()` | `onUnhandledRejectionIntegration()` | `@sentry/node` |
| `new LocalVariables()` | `localVariablesIntegration()` | `@sentry/node` |
| `new Spotlight()` | `spotlightIntegration()` | `@sentry/node` |
| `new Anr()` | `anrIntegration()` | `@sentry/node` |
| `new Hapi()` | `hapiIntegration()` | `@sentry/node` |
| `new Undici()` | `nativeNodeFetchIntegration()` | `@sentry/node` |
| `new Http()` | `httpIntegration()` | `@sentry/node` |
| Old | New | Packages |
| ----------------------------------- | ----------------------------------- | ------------------------------------------------------------------------------------------------------- |
| `new BrowserTracing()` | `browserTracingIntegration()` | `@sentry/browser` |
| `new InboundFilters()` | `inboundFiltersIntegration()` | `@sentry/core`, `@sentry/browser`, `@sentry/node`, `@sentry/deno`, `@sentry/bun`, `@sentry/vercel-edge` |
| `new FunctionToString()` | `functionToStringIntegration()` | `@sentry/core`, `@sentry/browser`, `@sentry/node`, `@sentry/deno`, `@sentry/bun`, `@sentry/vercel-edge` |
| `new LinkedErrors()` | `linkedErrorsIntegration()` | `@sentry/core`, `@sentry/browser`, `@sentry/node`, `@sentry/deno`, `@sentry/bun`, `@sentry/vercel-edge` |
| `new ModuleMetadata()` | `moduleMetadataIntegration()` | `@sentry/core`, `@sentry/browser` |
| `new RequestData()` | `requestDataIntegration()` | `@sentry/core`, `@sentry/node`, `@sentry/deno`, `@sentry/bun`, `@sentry/vercel-edge` |
| `new Wasm() ` | `wasmIntegration()` | `@sentry/wasm` |
| `new Replay()` | `replayIntegration()` | `@sentry/browser` |
| `new ReplayCanvas()` | `replayCanvasIntegration()` | `@sentry/browser` |
| `new Feedback()` | `feedbackIntegration()` | `@sentry/browser` |
| `new CaptureConsole()` | `captureConsoleIntegration()` | `@sentry/integrations` |
| `new Debug()` | `debugIntegration()` | `@sentry/integrations` |
| `new Dedupe()` | `dedupeIntegration()` | `@sentry/browser`, `@sentry/integrations`, `@sentry/deno` |
| `new ExtraErrorData()` | `extraErrorDataIntegration()` | `@sentry/integrations` |
| `new ReportingObserver()` | `reportingObserverIntegration()` | `@sentry/integrations` |
| `new RewriteFrames()` | `rewriteFramesIntegration()` | `@sentry/integrations` |
| `new SessionTiming()` | `sessionTimingIntegration()` | `@sentry/integrations` |
| `new HttpClient()` | `httpClientIntegration()` | `@sentry/integrations` |
| `new ContextLines()` | `contextLinesIntegration()` | `@sentry/integrations`, `@sentry/node`, `@sentry/deno`, `@sentry/bun` |
| `new Breadcrumbs()` | `breadcrumbsIntegration()` | `@sentry/browser`, `@sentry/deno` |
| `new GlobalHandlers()` | `globalHandlersIntegration()` | `@sentry/browser` , `@sentry/deno` |
| `new HttpContext()` | `httpContextIntegration()` | `@sentry/browser` |
| `new TryCatch()` | `browserApiErrorsIntegration()` | `@sentry/browser`, `@sentry/deno` |
| `new VueIntegration()` | `vueIntegration()` | `@sentry/vue` |
| `new DenoContext()` | `denoContextIntegration()` | `@sentry/deno` |
| `new DenoCron()` | `denoCronIntegration()` | `@sentry/deno` |
| `new NormalizePaths()` | `normalizePathsIntegration()` | `@sentry/deno` |
| `new Console()` | `consoleIntegration()` | `@sentry/node` |
| `new Context()` | `nodeContextIntegration()` | `@sentry/node` |
| `new Modules()` | `modulesIntegration()` | `@sentry/node` |
| `new OnUncaughtException()` | `onUncaughtExceptionIntegration()` | `@sentry/node` |
| `new OnUnhandledRejection()` | `onUnhandledRejectionIntegration()` | `@sentry/node` |
| `new LocalVariables()` | `localVariablesIntegration()` | `@sentry/node` |
| `new Spotlight()` | `spotlightIntegration()` | `@sentry/node` |
| `new Anr()` | `anrIntegration()` | `@sentry/node` |
| `new Hapi()` | `hapiIntegration()` | `@sentry/node` |
| `new Undici()` | `nativeNodeFetchIntegration()` | `@sentry/node` |
| `new Http()` | `httpIntegration()` | `@sentry/node` |
| `new ProfilingIntegration()` | `nodeProfilingIntegration()` | `@sentry/profiling-node` |
| `new BrowserProfilingIntegration()` | `browserProfilingIntegration()` | `@sentry/browser` |

## Deprecate `hub.bindClient()` and `makeMain()`

Expand Down
4 changes: 2 additions & 2 deletions packages/profiling-node/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ npm install --save @sentry/node @sentry/profiling-node

```javascript
import * as Sentry from '@sentry/node';
import { ProfilingIntegration } from '@sentry/profiling-node';
import { nodeProfilingIntegration } from '@sentry/profiling-node';

Sentry.init({
dsn: 'https://7fa19397baaf433f919fbe02228d5470@o1137848.ingest.sentry.io/6625302',
debug: true,
tracesSampleRate: 1,
profilesSampleRate: 1, // Set profiling sampling rate.
integrations: [new ProfilingIntegration()],
integrations: [nodeProfilingIntegration()],
});
```

Expand Down
6 changes: 5 additions & 1 deletion packages/profiling-node/src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
export { ProfilingIntegration } from './integration';
export {
// eslint-disable-next-line deprecation/deprecation
ProfilingIntegration,
nodeProfilingIntegration,
} from './integration';
23 changes: 22 additions & 1 deletion packages/profiling-node/src/integration.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
import type { NodeClient } from '@sentry/node';
import type { Event, EventProcessor, Hub, Integration, Transaction } from '@sentry/types';
import type {
Event,
EventProcessor,
Hub,
Integration,
IntegrationFn,
IntegrationFnResult,
Transaction,
} from '@sentry/types';

import { logger } from '@sentry/utils';

Expand Down Expand Up @@ -39,6 +47,8 @@ function addToProfileQueue(profile: RawThreadCpuProfile): void {
* and inspect each event to see if it is a transaction event and if that transaction event
* contains a profile on it's metadata. If that is the case, we create a profiling event envelope
* and delete the profile from the transaction metadata.
*
* @deprecated Use `nodeProfilingIntegration` instead.
*/
export class ProfilingIntegration implements Integration {
/**
Expand Down Expand Up @@ -243,3 +253,14 @@ export class ProfilingIntegration implements Integration {
return maybeRemoveProfileFromSdkMetadata(event);
}
}

/**
* We need this integration in order to send data to Sentry. We hook into the event processor
* and inspect each event to see if it is a transaction event and if that transaction event
* contains a profile on it's metadata. If that is the case, we create a profiling event envelope
* and delete the profile from the transaction metadata.
*/
export const nodeProfilingIntegration = (() => {
// eslint-disable-next-line deprecation/deprecation
return new ProfilingIntegration() as unknown as IntegrationFnResult;
}) satisfies IntegrationFn;
2 changes: 2 additions & 0 deletions packages/profiling-node/test/hubextensions.hub.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { CpuProfilerBindings } from '../src/cpu_profiler';
import { ProfilingIntegration } from '../src/index';

function makeClientWithoutHooks(): [Sentry.NodeClient, Transport] {
// eslint-disable-next-line deprecation/deprecation
const integration = new ProfilingIntegration();
const transport = Sentry.makeNodeTransport({
url: 'https://7fa19397baaf433f919fbe02228d5470@o1137848.ingest.sentry.io/6625302',
Expand Down Expand Up @@ -41,6 +42,7 @@ function makeClientWithoutHooks(): [Sentry.NodeClient, Transport] {
}

function makeClientWithHooks(): [Sentry.NodeClient, Transport] {
// eslint-disable-next-line deprecation/deprecation
const integration = new ProfilingIntegration();
const client = new Sentry.NodeClient({
stackParser: Sentry.defaultStackParser,
Expand Down
1 change: 1 addition & 0 deletions packages/profiling-node/test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ function makeStaticTransport(): MockTransport {
}

function makeClientWithoutHooks(): [Sentry.NodeClient, MockTransport] {
// eslint-disable-next-line deprecation/deprecation
const integration = new ProfilingIntegration();
const transport = makeStaticTransport();
const client = new Sentry.NodeClient({
Expand Down

0 comments on commit beed7f6

Please sign in to comment.