Emit one event per operation
Do not logstarted, processing, and completed for routine work. Emit one final event, for
example in a finally block. With captureTelemetry, one call records a log, a span, and metric
points for the operation:
captureTelemetry is also in @squasher-ai/nextjs. The same fields work on the
HTTP API.
Use stable field names
Group and chart by fields with few values, such as route, region, and release. Use fields with many
values, such as user or order IDs, only to find one exact event.
Keep attribute types
Send numbers and booleans as numbers and booleans, not as strings. Thelog helper in
@squasher-ai/edge turns nested objects into dotted keys:
cache.hit=true, cache.age_ms=42, and result_count=8. The helper replaces the
values of keys such as password, token, secret, cookie, authorization, and api_key with
[REDACTED]. It keeps at most 64 attributes, 4 levels, and 2,048 characters for each string.
Sample by outcome
Keep failures and slow operations, and sample routine success:- The SDK counts an event as a failure when its level is
warning,error, orfatal, when its trace status iserror, or whensquasher.outcomeisfailure. - Events with the same trace ID get the same decision for the same rate.
- When the SDK samples out an event that has
measurements, it still sends the metric points. alwaysSampleReleasesandalwaysSampleUserIdskeep every event for those releases and users.- The SDK never samples out LLM generation events.
Protect private data
- Do not record credentials, session cookies, authorization headers, prompts, or payment data.
- Record route templates instead of raw URLs with customer IDs.
- Use
beforeSendininitto remove or change fields before the SDK sends an event.
Check the quality of your logs
Next steps
Node.js SDK
See every option of the Node.js SDK.
HTTP API
See every event field.