Skip to content

feat(remix): Update remix SDK to be OTEL-powered#11031

Merged
mydea merged 1 commit intodevelopfrom
fn/remix-otel
Mar 14, 2024
Merged

feat(remix): Update remix SDK to be OTEL-powered#11031
mydea merged 1 commit intodevelopfrom
fn/remix-otel

Conversation

@mydea
Copy link
Copy Markdown
Member

@mydea mydea commented Mar 11, 2024

This updates the Remix SDK to use the new OTEL-powered @sentry/node under the hood.

@mydea mydea self-assigned this Mar 11, 2024
@mydea mydea force-pushed the fn/remix-otel branch 2 times, most recently from c0f28c3 to 50bac9b Compare March 12, 2024 13:07
Comment on lines +68 to +99
const sentryRequest = https.request(
sentryIngestUrl,
{ headers: proxyRequest.headers, method: proxyRequest.method },
sentryResponse => {
sentryResponse.addListener('data', (chunk: Buffer) => {
proxyResponse.write(chunk, 'binary');
sentryResponseChunks.push(chunk);
});

sentryResponse.addListener('end', () => {
eventCallbackListeners.forEach(listener => {
const rawSentryResponseBody = Buffer.concat(sentryResponseChunks).toString();

const data: SentryRequestCallbackData = {
envelope: parseEnvelope(proxyRequestBody),
rawProxyRequestBody: proxyRequestBody,
rawSentryResponseBody,
sentryResponseStatusCode: sentryResponse.statusCode,
};

listener(Buffer.from(JSON.stringify(data)).toString('base64'));
});
proxyResponse.end();
});

sentryResponse.addListener('error', err => {
throw err;
});

proxyResponse.writeHead(sentryResponse.statusCode || 500, sentryResponse.headers);
},
);

Check failure

Code scanning / CodeQL

Server-side request forgery

The [URL](1) of this request depends on a [user-provided value](2).
Comment on lines +68 to +99
const sentryRequest = https.request(
sentryIngestUrl,
{ headers: proxyRequest.headers, method: proxyRequest.method },
sentryResponse => {
sentryResponse.addListener('data', (chunk: Buffer) => {
proxyResponse.write(chunk, 'binary');
sentryResponseChunks.push(chunk);
});

sentryResponse.addListener('end', () => {
eventCallbackListeners.forEach(listener => {
const rawSentryResponseBody = Buffer.concat(sentryResponseChunks).toString();

const data: SentryRequestCallbackData = {
envelope: parseEnvelope(proxyRequestBody),
rawProxyRequestBody: proxyRequestBody,
rawSentryResponseBody,
sentryResponseStatusCode: sentryResponse.statusCode,
};

listener(Buffer.from(JSON.stringify(data)).toString('base64'));
});
proxyResponse.end();
});

sentryResponse.addListener('error', err => {
throw err;
});

proxyResponse.writeHead(sentryResponse.statusCode || 500, sentryResponse.headers);
},
);

Check failure

Code scanning / CodeQL

Server-side request forgery

The [URL](1) of this request depends on a [user-provided value](2).
Comment on lines +68 to +99
const sentryRequest = https.request(
sentryIngestUrl,
{ headers: proxyRequest.headers, method: proxyRequest.method },
sentryResponse => {
sentryResponse.addListener('data', (chunk: Buffer) => {
proxyResponse.write(chunk, 'binary');
sentryResponseChunks.push(chunk);
});

sentryResponse.addListener('end', () => {
eventCallbackListeners.forEach(listener => {
const rawSentryResponseBody = Buffer.concat(sentryResponseChunks).toString();

const data: SentryRequestCallbackData = {
envelope: parseEnvelope(proxyRequestBody),
rawProxyRequestBody: proxyRequestBody,
rawSentryResponseBody,
sentryResponseStatusCode: sentryResponse.statusCode,
};

listener(Buffer.from(JSON.stringify(data)).toString('base64'));
});
proxyResponse.end();
});

sentryResponse.addListener('error', err => {
throw err;
});

proxyResponse.writeHead(sentryResponse.statusCode || 500, sentryResponse.headers);
},
);

Check failure

Code scanning / CodeQL

Server-side request forgery

The [URL](1) of this request depends on a [user-provided value](2).
mydea added a commit that referenced this pull request Mar 13, 2024
This does two things:

1. Remove an unused remix integration test
2. Add a test that ensures we send correct server & browser transactions
that are correctly linked

I extracted these out from
#11031, to ensure
this is/remains stable before we migrate and after.

(Side note: Once v8 is somewhat settled, we should really find a way to
extract these event proxy things into a util 😅 )
@mydea mydea marked this pull request as ready for review March 14, 2024 14:30
const testTag = uuid4();

// no server span here!
const httpServerTransactionPromise = waitForTransaction('create-remix-app-express-vite-dev', transactionEvent => {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is actually instrumented now, without us having to do anything - probably the express instrumentation, nice!

@mydea mydea merged commit fc208fe into develop Mar 14, 2024
@mydea mydea deleted the fn/remix-otel branch March 14, 2024 14:46
@@ -1,25 +1,25 @@
import * as Sentry from '@sentry/remix';

Sentry.init({
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.

@mydea, @AbhiPrasad

We should update the wizard and the docs for this right? Also a breaking change warning for the changelog?

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.

We can get to the docs/wizard changes afterwards, this is only going to be released with an alpha.

Though we maybe should add a migration note 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants