Module: Bulldogger::Probe::Writer

Defined in:
lib/bulldogger/probe/writer.rb

Overview

Writes one probe session's aggregated MethodStats as tmp/bulldogger/run-.../probe-NNN-.json. Probe collection stays outside this module; this module only formats and writes the completed statistics.

Filenames use their own "probe-NNN-" sequence, not Run#next_path (which produces plain "NNN-.json" for failure evidence): Run is owned by the base-snapshot task and not touched here, and its sequence and this one are independent counters that happen to share a directory, not a single numbering space. Run#dir is still used for the lazy, on-first-write mkdir: probe is an explicit verb (AGENTS.md), so unlike a green test suite, a session that finished is itself the request to write, and does so even if it observed zero calls.

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.mutexObject (readonly)

Returns the value of attribute mutex.



28
29
30
# File 'lib/bulldogger/probe/writer.rb', line 28

def mutex
  @mutex
end

.sequenceObject

Returns the value of attribute sequence.



27
28
29
# File 'lib/bulldogger/probe/writer.rb', line 27

def sequence
  @sequence
end

Class Method Details

.write(run:, config:, targets:, stats:, started_at:) ⇒ Object



31
32
33
34
35
36
37
38
39
# File 'lib/bulldogger/probe/writer.rb', line 31

def self.write(run:, config:, targets:, stats:, started_at:)
  dir = run.dir
  return nil unless dir

  path = File.join(dir, format("probe-%03d-%s.json", next_sequence, slug_for(targets)))
  File.write(path, "#{JSON.pretty_generate(payload_for(config: config, targets: targets, stats: stats,
                                                        started_at: started_at))}\n")
  path
end