Caps a free-text message destined for a telemetry payload.

Backend error messages are unbounded — they can embed generated SQL, stack traces, or compilation output. Left uncapped they risk pushing an event past the pipeline's size limit, and oversized events are usually dropped whole: the biggest, most interesting failures are then the ones that silently disappear from the dashboard.

The truncated flag is returned rather than inferred so callers can report it alongside the text. A silently clipped message makes substring searches produce false negatives with no way for an analyst to tell.

NOTE: this is a size control, not a privacy control — if a message embeds sensitive values in its first characters, truncation will not remove them.

  • Parameters

    • message: string
    • limit: number = DEFAULT_TELEMETRY_MESSAGE_LENGTH_LIMIT

    Returns { message: string; truncated: boolean }