Module: Snare::Capture
- Defined in:
- lib/snare/capture.rb
Overview
Pure event-building logic — mirrors packages/sdk/src/capture.ts. Kept free of any I/O so it's testable without a live queue/transport.
Constant Summary collapse
- PLATFORM =
"ruby"- MESSAGE_MAX_LENGTH =
Must stay in sync with services/intake/src/routes/telemetry.ts's capturedEventSchema (message.max(2000), stack.max(20_000)) — the server rejects the ENTIRE batch with a 400 if any single event exceeds these caps, and the transport never inspects the response status, so an un-truncated field here means silently dropped error reports.
2000- STACK_MAX_LENGTH =
20_000
Class Method Summary collapse
-
.build_captured_event(exception:, now:, console_log: nil) ⇒ Object
Per the wire protocol (docs/snare-multi-language-sdk-wire-protocol.md, Section 1): no url/userAgent keys for non-browser platforms, platform is always the literal "ruby", and consoleLog is a required key (nil is fine — console/log capture is optional for v1).
Class Method Details
.build_captured_event(exception:, now:, console_log: nil) ⇒ Object
Per the wire protocol (docs/snare-multi-language-sdk-wire-protocol.md, Section 1): no url/userAgent keys for non-browser platforms, platform is always the literal "ruby", and consoleLog is a required key (nil is fine — console/log capture is optional for v1).
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/snare/capture.rb', line 23 def build_captured_event(exception:, now:, console_log: nil) event = { message: exception..to_s[0, MESSAGE_MAX_LENGTH], timestamp: now, console_log: console_log, platform: PLATFORM, } stack = exception.backtrace&.join("\n") event[:stack] = stack[0, STACK_MAX_LENGTH] if stack event end |