Skip to content

feat(profiling-node): Expose nodeProfilingIntegration #10868

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 1 commit into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
82 changes: 42 additions & 40 deletions MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -740,46 +740,48 @@ The following list shows how integrations should be migrated:

### List of integrations and their replacements

| 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://[email protected]/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,6 +1,14 @@
import { spanToJSON } from '@sentry/core';
import type { NodeClient } from '@sentry/node-experimental';
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 @@ -40,6 +48,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 @@ -245,3 +255,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://[email protected]/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
Loading