Documentation ¶
Overview ¶
Package vm provides a virtual machine environment for executing mtail bytecode.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ProgRuntimeErrors = expvar.NewMap("prog_runtime_errors_total") LineProcessingDurations = prometheus.NewHistogramVec(prometheus.HistogramOpts{ Namespace: "mtail", Subsystem: "vm", Name: "line_processing_duration_seconds", Help: "VM line processing time distribution in seconds.", Buckets: prometheus.ExponentialBuckets(0.00002, 2.0, 10), }, []string{"prog"}) )
Functions ¶
This section is empty.
Types ¶
type VM ¶
type VM struct { Metrics []*metrics.Metric // Metrics accessible to this program. HardCrash bool // User settable flag to make the VM crash instead of recover on panic. // contains filtered or unexported fields }
VM describes the virtual machine for each program. It contains virtual segments of the executable bytecode, constant data (string and regular expressions), mutable state (metrics), and a stack for the current thread of execution.
func New ¶
func New(name string, obj *code.Object, syslogUseCurrentYear bool, loc *time.Location, log bool, trace bool) *VM
New creates a new virtual machine with the given name, and compiler artifacts for executable and data segments.
func (*VM) DumpByteCode ¶
DumpByteCode emits the program disassembly and program objects to a string.
func (*VM) ProcessLogLine ¶
ProcessLogLine handles the incoming lines by running a fetch-execute cycle on the VM bytecode with the line as input to the program, until termination.
func (*VM) Run ¶
Run starts the VM and processes lines coming in on the input channel. When the channel is closed, and the VM has finished processing the VM is shut down and the loader signalled via the given waitgroup.
func (*VM) RuntimeErrorString ¶
RuntimeErrorString returns the last runtime erro rthat the program enountered.