Skip to content
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
7 changes: 5 additions & 2 deletions controlplane/src/core/composition/composeGraphs.pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,12 @@ export function composeGraphsInWorker(
namespaceId: task.federatedGraph.namespaceId,
},
},
() => {
(span) => {
const traceData = Sentry.getTraceData();
return getComposeGraphsPool().run({
const pool = getComposeGraphsPool();
span.setAttribute('pool.queueSize', pool.queueSize);

return pool.run({
...fullTask,
trace: {
sentryTrace: traceData['sentry-trace'],
Expand Down
15 changes: 14 additions & 1 deletion controlplane/src/core/composition/composeGraphs.worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import type { RouterSubgraph } from '@wundergraph/cosmo-shared';
import * as Sentry from '@sentry/node';
import { workerId } from 'tinypool';
import { z } from 'zod';
import { fastifyIntegration, pinoIntegration } from '@sentry/node';
import { eventLoopBlockIntegration } from '@sentry/node-native';
import { nodeProfilingIntegration } from '@sentry/profiling-node';
import type { SubgraphDTO } from '../../types/index.js';
Expand Down Expand Up @@ -77,8 +78,10 @@ if (SENTRY_ENABLED && SENTRY_DSN) {
Sentry.init({
dsn: SENTRY_DSN,
integrations: [
fastifyIntegration(),
eventLoopBlockIntegration({ threshold: SENTRY_EVENT_LOOP_BLOCK_THRESHOLD_MS }),
nodeProfilingIntegration(),
pinoIntegration({ log: { levels: ['info', 'warn', 'error'] } }),
],
profileSessionSampleRate: SENTRY_PROFILE_SESSION_SAMPLE_RATE,
sendDefaultPii: SENTRY_SEND_DEFAULT_PII,
Expand Down Expand Up @@ -255,7 +258,7 @@ function toCompositionSubgraphs(subgraphs: SubgraphDTO[]) {
);
}

export default function composeGraphsInWorker(task: ComposeGraphsTaskInput): ComposeGraphsTaskResult {
function composeGraphsInWorker(task: ComposeGraphsTaskInput): ComposeGraphsTaskResult {
return Sentry.continueTrace({ sentryTrace: task.trace?.sentryTrace, baggage: task.trace?.baggage }, () =>
Sentry.startSpan(
{
Expand Down Expand Up @@ -346,3 +349,13 @@ export default function composeGraphsInWorker(task: ComposeGraphsTaskInput): Com
),
);
}

export default async function composeGraphsInWorkerActual(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a nitpick on already merged PR 😅 but the name is kinda of confusing even though I understand the intention.

Could we rename it as part of subsequent PR? Maybe use composeGraphsInWorker for this actual exported function and rename the other one to composeGraphsInWorkerWithTraces

task: ComposeGraphsTaskInput,
): Promise<ComposeGraphsTaskResult> {
try {
return composeGraphsInWorker(task);
} finally {
await Sentry.flush();
}
}
Loading