Skip to content

Commit 30487a1

Browse files
authored
Merge pull request #16223 from getsentry/prepare-release/9.16.1
meta(changelog): Update changelog for 9.16.1
2 parents e5c0ca1 + a1bdb3c commit 30487a1

File tree

8 files changed

+30
-233
lines changed

8 files changed

+30
-233
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010

1111
- "You miss 100 percent of the chances you don't take. — Wayne Gretzky" — Michael Scott
1212

13+
## 9.16.1
14+
15+
- fix(core): Make sure logs get flushed in server-runtime-client ([#16222](https://github.com/getsentry/sentry-javascript/pull/16222))
16+
- ref(node): Remove vercel flushing code that does nothing ([#16217](https://github.com/getsentry/sentry-javascript/pull/16217))
17+
1318
## 9.16.0
1419

1520
### Important changes

dev-packages/node-integration-tests/suites/vercel/instrument.mjs

-13
This file was deleted.

dev-packages/node-integration-tests/suites/vercel/scenario.mjs

-13
This file was deleted.

dev-packages/node-integration-tests/suites/vercel/test.ts

-53
This file was deleted.

packages/core/src/server-runtime-client.ts

+5
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ export class ServerRuntimeClient<
5252
if (this._options._experiments?.enableLogs) {
5353
// eslint-disable-next-line @typescript-eslint/no-this-alias
5454
const client = this;
55+
5556
client.on('flushLogs', () => {
5657
client._logWeight = 0;
5758
clearTimeout(client._logFlushIdleTimeout);
@@ -72,6 +73,10 @@ export class ServerRuntimeClient<
7273
}, DEFAULT_LOG_FLUSH_INTERVAL);
7374
}
7475
});
76+
77+
client.on('flush', () => {
78+
_INTERNAL_flushLogsBuffer(client);
79+
});
7580
}
7681
}
7782

packages/core/test/lib/server-runtime-client.test.ts

+20
Original file line numberDiff line numberDiff line change
@@ -278,5 +278,25 @@ describe('ServerRuntimeClient', () => {
278278
expect(sendEnvelopeSpy).not.toHaveBeenCalled();
279279
expect(client['_logWeight']).toBe(0);
280280
});
281+
282+
it('flushes logs when flush event is triggered', () => {
283+
const options = getDefaultClientOptions({
284+
dsn: PUBLIC_DSN,
285+
_experiments: { enableLogs: true },
286+
});
287+
client = new ServerRuntimeClient(options);
288+
289+
const sendEnvelopeSpy = vi.spyOn(client, 'sendEnvelope');
290+
291+
// Add some logs
292+
_INTERNAL_captureLog({ message: 'test1', level: 'info' }, client);
293+
_INTERNAL_captureLog({ message: 'test2', level: 'info' }, client);
294+
295+
// Trigger flush event
296+
client.emit('flush');
297+
298+
expect(sendEnvelopeSpy).toHaveBeenCalledTimes(1);
299+
expect(client['_logWeight']).toBe(0); // Weight should be reset after flush
300+
});
281301
});
282302
});

packages/node/src/integrations/http/SentryHttpInstrumentationBeforeOtel.ts

-136
This file was deleted.

packages/node/src/integrations/http/index.ts

-18
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import { addOriginToSpan } from '../../utils/addOriginToSpan';
1212
import { getRequestUrl } from '../../utils/getRequestUrl';
1313
import type { SentryHttpInstrumentationOptions } from './SentryHttpInstrumentation';
1414
import { SentryHttpInstrumentation } from './SentryHttpInstrumentation';
15-
import { SentryHttpInstrumentationBeforeOtel } from './SentryHttpInstrumentationBeforeOtel';
1615

1716
const INTEGRATION_NAME = 'Http';
1817

@@ -117,10 +116,6 @@ interface HttpOptions {
117116
};
118117
}
119118

120-
const instrumentSentryHttpBeforeOtel = generateInstrumentOnce(`${INTEGRATION_NAME}.sentry-before-otel`, () => {
121-
return new SentryHttpInstrumentationBeforeOtel();
122-
});
123-
124119
const instrumentSentryHttp = generateInstrumentOnce<SentryHttpInstrumentationOptions>(
125120
`${INTEGRATION_NAME}.sentry`,
126121
options => {
@@ -162,19 +157,6 @@ export const httpIntegration = defineIntegration((options: HttpOptions = {}) =>
162157
return {
163158
name: INTEGRATION_NAME,
164159
setupOnce() {
165-
// TODO: get rid of this too
166-
// Below, we instrument the Node.js HTTP API three times. 2 times Sentry-specific, 1 time OTEL specific.
167-
// Due to timing reasons, we sometimes need to apply Sentry instrumentation _before_ we apply the OTEL
168-
// instrumentation (e.g. to flush on serverless platforms), and sometimes we need to apply Sentry instrumentation
169-
// _after_ we apply OTEL instrumentation (e.g. for isolation scope handling and breadcrumbs).
170-
171-
// This is Sentry-specific instrumentation that is applied _before_ any OTEL instrumentation.
172-
if (process.env.VERCEL) {
173-
// Currently this instrumentation only does something when deployed on Vercel, so to save some overhead, we short circuit adding it here only for Vercel.
174-
// If it's functionality is extended in the future, feel free to remove the if statement and this comment.
175-
instrumentSentryHttpBeforeOtel();
176-
}
177-
178160
const instrumentSpans = _shouldInstrumentSpans(options, getClient<NodeClient>()?.getOptions());
179161

180162
// This is Sentry-specific instrumentation for request isolation and breadcrumbs

0 commit comments

Comments
 (0)