Skip to content

SDK Truncation Logic #17389

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;

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

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 {

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

LCP URLs

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

Slicing huge srings

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

Redis integration

  • Truncates span description (not configurable)

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

Activity

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions