Skip to content

SDK Truncation Logic #17389

@s1gr1d

Description

@s1gr1d

Description

Data should not be truncated in the SDK itself, but in Relay.

Reference: https://github.com/getsentry/projects/issues/837

Exceptions:

  • 1000 spans per transaction
  • max number of breadcrumbs
  • request body truncation

Going through the repository, several places were found where truncation happens:

Normalizing objects

export function normalize(input: unknown, depth: number = 100, maxProperties: number = +Infinity): any {

Limiting Values

const { environment, release, dist, maxValueLength = 250 } = options;

Context lines

  • Trims context lines

export function snipLine(line: string, colno: number): string {

Exceptions

  • Truncates key length, extra error data

export function extractExceptionKeysForMessage(exception: Record<string, unknown>, maxLength: number = 40): string {

extraErrorInfo[key] = isError(value) || typeof value === 'string' ? truncate(`${value}`, maxValueLength) : value;

Limiting Zod Errors

  • Zod integration limits amount of issues attached (configurable)

export function applyZodErrorsToEvent(

Breadcrumbs

  • Maximum number of breadcrumbs is 100 (this should probably stay)

this._breadcrumbs = this._breadcrumbs.slice(-maxCrumbs);

Feature Flags

HTTP integration

Redis integration

  • Truncates span description (not configurable)

span.updateName(truncate(spanDescription, 1024));

Paths

  • Trims path length for directories, LCP URLs

const truncated = filename.length > 1024 ? `<truncated>${filename.slice(-1024)}` : filename;

entry.url && (attributes['lcp.url'] = entry.url.trim().slice(0, 200));

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions