tracing

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2023 License: AGPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Accept EventType = iota + 1
	Connect
	Receive
	Send
	Shutdown
	// extra flags associated with the Shut event type
	ShutRD = 1 << 6
	ShutWR = 1 << 7
	// mask to extract the even type or flags independently
	EventTypeMask = 0b00111111
	EventFlagMask = 0b11000000
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Bytes

type Bytes []byte

func (Bytes) MarshalYAML

func (b Bytes) MarshalYAML() (any, error)

type Conn

type Conn interface {
	// Returns the protocol that this Conn value was constructed from.
	Protocol() ConnProtocol

	// Observe is called when a network event is received for this connection.
	//
	// The receiver is expected to update its state by capturing the data
	// fragments carried in the event.
	Observe(*Event)

	// After calls to Observe, the connection may receive a call to Next in
	// order to consume the next message that was formed by the accumulation of
	// data fragements from network events.
	//
	// The method writes to the Message value passed as argument, returning true
	// if a message could be formed, and false otherwise.
	Next(*Message) bool

	// Indicates whether the connection has reached EOF, and has no more
	// messages to read.
	Done() bool
}

Conn values represent client and server connections.

The instances are intended to reconstruct the state of a connection from observing a sequence of network events which contain data fragments seen by the connection.

type ConnMessage

type ConnMessage interface {
	// Returns the connection that the message was originally decoded from.
	Conn() Conn

	// Marshals the message into a representation intended to be marshaled to
	// structured formats like JSON or YAML.
	Marshal() any

	// Formats the message to a human readable format.
	fmt.Formatter
}

ConnMessage represents a message read from a client or server connection.

type ConnProtocol

type ConnProtocol interface {
	// Returns the name of the protocol.
	//
	// This value is used when printing protocol messages in a human readable
	// format.
	Name() string

	// Given a data segment found at the beginning of a network connection,
	// determine whether the protocol is able to decode it.
	//
	// This method is used to do automatic detection of the protocol being used
	// when inspecting network events.
	CanHandle(data []byte) bool

	// Constructs a Conn instance intended to decode protocol messages exchanged
	// over a client connection.
	NewClient(fd wasi.FD, addr, peer net.Addr) Conn

	// Constructs a Conn instance intended to decode protocol messages exchanged
	// over a server connection.
	NewServer(fd wasi.FD, addr, peer net.Addr) Conn
}

ConnProtocol is an interface implemented by types which represent high level connection-oriented protocols such as HTTP.

func HTTP1

func HTTP1() ConnProtocol

HTTP1 is the implementation of the HTTP/1 protocol.

type Event

type Event struct {
	Record int64      `json:"record"          yaml:"record"`
	Time   time.Time  `json:"time"            yaml:"time"`
	Type   EventType  `json:"type"            yaml:"type"`
	Proto  Protocol   `json:"proto"           yaml:"proto"`
	Error  wasi.Errno `json:"error,omitempty" yaml:"error,omitempty"`
	FD     wasi.FD    `json:"fd"              yaml:"fd"`
	Addr   net.Addr   `json:"addr,omitempty"  yaml:"addr,omitempty"`
	Peer   net.Addr   `json:"peer,omitempty"  yaml:"peer,omitempty"`
	Data   []Bytes    `json:"data,omitempty"  yaml:"data,omitempty"`
}

func (Event) Format

func (e Event) Format(w fmt.State, _ rune)

type EventReader

type EventReader struct {
	Records stream.Reader[timemachine.Record]
	// contains filtered or unexported fields
}

func (*EventReader) Read

func (r *EventReader) Read(events []Event) (n int, err error)

type EventType

type EventType uint8

func (EventType) Flag

func (t EventType) Flag() uint

func (EventType) MarshalText

func (t EventType) MarshalText() ([]byte, error)

func (EventType) String

func (t EventType) String() string

func (EventType) Type

func (t EventType) Type() EventType

func (*EventType) UnmarshalText

func (t *EventType) UnmarshalText(b []byte) error

type Exchange

type Exchange struct {
	Link Link
	Req  Request
	Res  Response
}

Exchange values represent the exchange of a request and response between network peers.

func (Exchange) Format

func (e Exchange) Format(w fmt.State, v rune)

func (Exchange) MarshalJSON

func (e Exchange) MarshalJSON() ([]byte, error)

func (Exchange) MarshalYAML

func (e Exchange) MarshalYAML() (any, error)

type ExchangeReader

type ExchangeReader struct {
	Messages stream.Reader[Message]
	// contains filtered or unexported fields
}

ExchangeReader is a reader of Exchange values. Instances of ExchangeReader consume network messages from a reader of Message values and reconstruct the relationship between requests and responses.

func (*ExchangeReader) Read

func (r *ExchangeReader) Read(exchanges []Exchange) (n int, err error)
type Link struct {
	Src net.Addr `json:"src" yaml:"src"`
	Dst net.Addr `json:"dst" yaml:"dst"`
}

Link represents a network connection initiated from a source address to a local or remote destination.

type Message

type Message struct {
	Link Link
	Time time.Time
	Span time.Duration
	Err  error
	// contains filtered or unexported fields
}

Message is a representation of a message exchanged between two network peers.

func (Message) Format

func (m Message) Format(w fmt.State, v rune)

func (Message) MarshalJSON

func (m Message) MarshalJSON() ([]byte, error)

func (Message) MarshalYAML

func (m Message) MarshalYAML() (any, error)

type MessageReader

type MessageReader struct {
	Events stream.Reader[Event]
	Protos []ConnProtocol
	// contains filtered or unexported fields
}

MessageReader is a reader of Message values. Instances of MessageReader consume network events from a reader of Event values and reconstruct network messages exchanged over network connections.

func (*MessageReader) Read

func (r *MessageReader) Read(msgs []Message) (n int, err error)

type Protocol

type Protocol uint8
const (
	IP  Protocol = 0
	TCP Protocol = 1
	UDP Protocol = 2
)

func (Protocol) MarshalText

func (p Protocol) MarshalText() ([]byte, error)

func (Protocol) String

func (p Protocol) String() string

func (*Protocol) UnmarshalText

func (p *Protocol) UnmarshalText(b []byte) error

type Request

type Request struct {
	Time time.Time
	Span time.Duration
	Err  error
	// contains filtered or unexported fields
}

func (Request) Format

func (r Request) Format(w fmt.State, v rune)

type Response

type Response struct {
	Time time.Duration
	Span time.Duration
	Err  error
	// contains filtered or unexported fields
}

func (Response) Format

func (r Response) Format(w fmt.State, v rune)

Jump to

Keyboard shortcuts

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