tracing

package
v0.0.0-...-7cd50c7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 4, 2023 License: Apache-2.0 Imports: 7 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init()

Initializes the main trace. Cannot be part of the init() function, as the configuration file is not yet loaded when init() is executed.

Types

type BufferedTrace

type BufferedTrace struct {

	// Only trace events whose SampledVal is is a multiple of Sampling.
	// (E.g., client sequence number for request events, sequence number for protocol events is meant to be stored there)
	Sampling int

	BufferCapacity        int
	ProtocolEventCapacity int
	RequestEventCapacity  int
	EthereumEventCapacity int
	// contains filtered or unexported fields
}

func (*BufferedTrace) Event

func (bt *BufferedTrace) Event(e EventType, sampledVal int64, val0 int64)

Create a new protocol trace event.

func (*BufferedTrace) Start

func (bt *BufferedTrace) Start(outFileName string, nodeID int32)

func (*BufferedTrace) Stop

func (bt *BufferedTrace) Stop()

Writes the in-memory traces to a file specified at the call to Start(). Stop() must be called in order to obtain meaningful output.

func (*BufferedTrace) StopOnSignal

func (bt *BufferedTrace) StopOnSignal(sig os.Signal, exit bool)

type DirectTrace

type DirectTrace struct {

	// Only trace events whose sequence number (clSn for request events, seqNr for protocol events)
	// is is a multiple of Sampling.
	Sampling int
	// contains filtered or unexported fields
}

func (*DirectTrace) Ethereum

func (t *DirectTrace) Ethereum(e EventType, configNr int64, gasCost int64)

Create a new request trace event.

func (*DirectTrace) Event

func (t *DirectTrace) Event(e EventType, sampledVal int64, val0 int64)

Create a new trace event.

func (*DirectTrace) Protocol

func (t *DirectTrace) Protocol(e EventType, seqNr int32)

Create a new protocol trace event.

func (*DirectTrace) Request

func (t *DirectTrace) Request(e EventType, clID int32, clSN int32)

Create a new request trace event.

func (*DirectTrace) Start

func (t *DirectTrace) Start(outFileName string, nodeID int32)

Starts the tracing of this DirectTrace. No call to Event(), Protocol(), Request() or Ethereum() must be made before Start() returned. If Start() has been called, then Stop() must be called as well to perform the necessary cleanup before the process finishes.

func (*DirectTrace) Stop

func (t *DirectTrace) Stop()

Stops the tracing and performs the necessary cleanup (closes the output file). Stop() must be called in order to obtain meaningful output.

func (*DirectTrace) StopOnSignal

func (t *DirectTrace) StopOnSignal(sig os.Signal, exit bool)

Sets up a signal handler that calls Stop() when the specified OS signal occurs. This is useful for tracing if the program does not terminate gracefully, but is stopped using an OS signal. StopOnSignal() can be used in this case to still stop the tracer (flushing buffer contents). If the exit flag is set to true, the signal handler will exit the process after stopping the tracer.

type EventType

type EventType int
const (
	PROPOSE EventType = iota
	PREPREPARE
	COMMIT
	CLIENT_SLACK
	REQ_SEND
	REQ_RECEIVE
	RESP_SEND
	RESP_RECEIVE
	ENOUGH_RESP
	REQ_FINISHED
	REQ_DELIVERED
	ETH_VOTE_SUBMIT
	ETH_VOTE_DONE
	CPU_USAGE
	MSG_BATCH
	BANDWIDTH
	BUCKET_STATE
	NEW_EPOCH
	VIEW_CHANGE
)

func (EventType) String

func (et EventType) String() string

type GenericEvent

type GenericEvent struct {
	EventType  EventType
	Timestamp  int64
	NodeId     int32
	SampledVal int64
	Val0       int64
}
type ProtocolEvent struct {
	EventType EventType
	Timestamp int64
	PeerId    int32
	SeqNr     int32
}
type RequestEvent struct {
	EventType EventType
	Timestamp int64
	ClId      int32
	ClSn      int32
	PeerId    int32
}
type EthereumEvent struct {
	EventType EventType
	Timestamp int64
	PeerId    int32
	ConfigNr  int64
	GasCost   int64
}

type Trace

type Trace interface {
	// Starts the tracing of this Trace.
	// No call to Event(), Protocol() or Request() must be made before Start() returned.
	// If Start() has been called, then Stop() must be called as well
	// to perform the necessary cleanup before the process finishes.
	Start(outFileName string, nodeID int32)

	// Create a new trace event
	// sampledVal and val0 are integers whose interpretation depends on the event type.
	// However, sampledVal is also used for sampling
	Event(e EventType, sampledVal int64, val0 int64)

	// Stops the tracing and performs the necessary cleanup (e.g. closes the output file).
	// Stop() must be called in order to obtain meaningful output.
	Stop()

	// Sets up a signal handler that calls Stop() when the specified OS signal occurs.
	// This is useful for tracing if the program does not terminate gracefully, but is stopped using an OS signal.
	// StopOnSignal() can be used in this case to still stop the tracer (flushing buffer contents).
	// If the exit flag is set to true, the signal handler will exit the process after stopping the tracer.
	StopOnSignal(sig os.Signal, exit bool)
}
var (
	MainTrace Trace
)

A global instance of a trace object to be used from anywhere in the code, without having to keep around a reference and dereference it.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL