Skip to content
Closed
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
1 change: 1 addition & 0 deletions packages/aws-serverless/src/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ function setupTimeoutWarning(context: Context, options: WrapperOptions): NodeJS.
return setTimeout(() => {
withScope(scope => {
scope.setTag('timeout', humanReadableTimeout);
scope.setAttribute('timeout', humanReadableTimeout);
captureMessage(`Possible function timeout: ${context.functionName}`, 'warning');
});
}, timeoutWarningDelay);
Expand Down
7 changes: 6 additions & 1 deletion packages/aws-serverless/test/sdk.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const mockInit = vi.fn();

const mockScope = {
setTag: vi.fn(),
setAttribute: vi.fn(),
setContext: vi.fn(),
addEventProcessor: vi.fn(),
setTransactionName: vi.fn(),
Expand Down Expand Up @@ -121,6 +122,7 @@ describe('AWSLambda', () => {
expect(mockWithScope).toBeCalledTimes(2);
expect(mockCaptureMessage).toBeCalled();
expect(mockScope.setTag).toBeCalledWith('timeout', '1s');
expect(mockScope.setAttribute).toBeCalledWith('timeout', '1s');
});

test('captureTimeoutWarning disabled', async () => {
Expand All @@ -137,6 +139,7 @@ describe('AWSLambda', () => {
expect(mockWithScope).toBeCalledTimes(1);
expect(mockCaptureMessage).not.toBeCalled();
expect(mockScope.setTag).not.toBeCalledWith('timeout', '1s');
expect(mockScope.setAttribute).not.toBeCalledWith('timeout', '1s');
});

test('captureTimeoutWarning with configured timeoutWarningLimit', async () => {
Expand All @@ -146,7 +149,7 @@ describe('AWSLambda', () => {
* If it would not work as expected, we'd exceed `setTimeout` used and never capture the warning.
*/

expect.assertions(2);
expect.assertions(3);

const handler: Handler = (_event, _context, callback) => {
setTimeout(() => {
Expand All @@ -167,6 +170,7 @@ describe('AWSLambda', () => {

expect(mockCaptureMessage).toBeCalled();
expect(mockScope.setTag).toBeCalledWith('timeout', '1m40s');
expect(mockScope.setAttribute).toBeCalledWith('timeout', '1m40s');
});

test('captureAllSettledReasons disabled (default)', async () => {
Expand Down Expand Up @@ -527,6 +531,7 @@ describe('AWSLambda', () => {
expect(mockWithScope).toBeCalledTimes(2);
expect(mockCaptureMessage).toBeCalled();
expect(mockScope.setTag).toBeCalledWith('timeout', '1s');
expect(mockScope.setAttribute).toBeCalledWith('timeout', '1s');
});

test('marks streaming handler captured errors as unhandled', async () => {
Expand Down
1 change: 1 addition & 0 deletions packages/nextjs/src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export function init(options: BrowserOptions): Client | undefined {
// @ts-expect-error `process.turbopack` is a magic string that will be replaced by Next.js
if (process.turbopack) {
getGlobalScope().setTag('turbopack', true);
getGlobalScope().setAttribute('turbopack', true);
}
} catch {
// Noop
Expand Down
3 changes: 2 additions & 1 deletion packages/react-router/src/client/sdk.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { BrowserOptions } from '@sentry/browser';
import { init as browserInit } from '@sentry/browser';
import type { Client } from '@sentry/core';
import { applySdkMetadata, consoleSandbox, setTag } from '@sentry/core';
import { applySdkMetadata, consoleSandbox, setAttribute, setTag } from '@sentry/core';

const BROWSER_TRACING_INTEGRATION_ID = 'BrowserTracing';

Expand Down Expand Up @@ -30,6 +30,7 @@ export function init(options: BrowserOptions): Client | undefined {
const client = browserInit(options);

setTag('runtime', 'browser');
setAttribute('runtime', 'browser');

return client;
}
3 changes: 2 additions & 1 deletion packages/react-router/src/server/sdk.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Integration } from '@sentry/core';
import { applySdkMetadata, debug, setTag } from '@sentry/core';
import { applySdkMetadata, debug, setAttribute, setTag } from '@sentry/core';
import type { NodeClient, NodeOptions } from '@sentry/node';
import { getDefaultIntegrations as getNodeDefaultIntegrations, init as initNodeSdk } from '@sentry/node';
import { DEBUG_BUILD } from '../common/debug-build';
Expand Down Expand Up @@ -34,6 +34,7 @@ export function init(options: NodeOptions): NodeClient | undefined {
const client = initNodeSdk(opts);

setTag('runtime', 'node');
setAttribute('runtime', 'node');

DEBUG_BUILD && debug.log('SDK successfully initialized');

Expand Down
6 changes: 6 additions & 0 deletions packages/react-router/test/client/sdk.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { init as reactRouterInit } from '../../src/client';

const browserInit = vi.spyOn(SentryBrowser, 'init');
const setTag = vi.spyOn(SentryCore, 'setTag');
const setAttribute = vi.spyOn(SentryCore, 'setAttribute');
const consoleWarn = vi.spyOn(console, 'warn').mockImplementation(() => {});

describe('React Router client SDK', () => {
Expand Down Expand Up @@ -50,6 +51,11 @@ describe('React Router client SDK', () => {
expect(setTag).toHaveBeenCalledWith('runtime', 'browser');
});

it('sets the runtime attribute to browser', () => {
reactRouterInit({});
expect(setAttribute).toHaveBeenCalledWith('runtime', 'browser');
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Feat PR lacks integration tests

Low Severity

This feat PR only adds unit tests that assert setAttribute was called. The project review rules ask feat PRs to include at least one integration or E2E test, and that tests cover the new behaviour on sent payloads. Several new call sites also have no coverage, so it is not verified that the mirrored attributes actually reach logs, metrics, or streamed spans. Flagged because that requirement is in the review rules file.

Additional Locations (1)
Fix in Cursor Fix in Web

Triggered by project rule: PR Review Guidelines for Cursor Bot

Reviewed by Cursor Bugbot for commit 3988407. Configure here.


it('warns if BrowserTracing integration is present', () => {
reactRouterInit({
integrations: [{ name: 'BrowserTracing' }],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -672,9 +672,11 @@ export function captureToolError(span: Span, data: VercelAiChannelMessage, error
scope.setContext('trace', spanToTraceContext(span));
if (toolName) {
scope.setTag('vercel.ai.tool.name', toolName);
scope.setAttribute('vercel.ai.tool.name', toolName);
}
if (toolCallId) {
scope.setTag('vercel.ai.tool.callId', toolCallId);
scope.setAttribute('vercel.ai.tool.callId', toolCallId);
}
scope.setLevel('error');
captureException(
Expand Down
Loading