common

package
v7.0.6+incompatible Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2022 License: Apache-2.0 Imports: 15 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotImplemented = errors.New("BPF-based network tracing not implemented on non-linux systems")
)

Functions

func CurrentKernelVersion

func CurrentKernelVersion() (uint32, error)

func LinuxKernelVersionCode

func LinuxKernelVersionCode(major, minor, patch uint32) uint32

func V4IPString

func V4IPString(addr uint32) string

func V6IPString

func V6IPString(addr_h, addr_l uint64) string

Types

type ConnTuple

type ConnTuple struct {
	Laddr string
	Lport uint16
	Raddr string
	Rport uint16
	Pid   uint32
}

func (*ConnTuple) Matches

func (ct *ConnTuple) Matches(stats *ConnectionStats) bool

type ConnectionFamily

type ConnectionFamily uint8
const (
	AF_INET  ConnectionFamily = 0
	AF_INET6 ConnectionFamily = 1
)

type ConnectionMetric

type ConnectionMetric struct {
	Name  MetricName            `json:"name"`
	Tags  map[string]string     `json:"tags"`
	Value ConnectionMetricValue `json:"value"`
}

func (ConnectionMetric) MarshalEasyJSON

func (v ConnectionMetric) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (ConnectionMetric) MarshalJSON

func (v ConnectionMetric) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*ConnectionMetric) UnmarshalEasyJSON

func (v *ConnectionMetric) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*ConnectionMetric) UnmarshalJSON

func (v *ConnectionMetric) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type ConnectionMetricValue

type ConnectionMetricValue struct {
	Histogram *Histogram `json:"ddsketch"`
}

type ConnectionStats

type ConnectionStats struct {
	Pid    uint32           `json:"pid"`
	Type   ConnectionType   `json:"type"`
	Family ConnectionFamily `json:"family"`

	// Local & Remote represented as a string to handle both IPv4 & IPv6
	Local            string    `json:"local"`
	Remote           string    `json:"remote"`
	LocalPort        uint16    `json:"lport"`
	RemotePort       uint16    `json:"rport"`
	Direction        Direction `json:"direction"`
	State            State     `json:"state"`
	NetworkNamespace string    `json:"network_namespace"`

	SendBytes uint64 `json:"send_bytes"`
	RecvBytes uint64 `json:"recv_bytes"`

	ApplicationProtocol string             `json:"app_proto"`
	Metrics             []ConnectionMetric `json:"metrics"`
}

func (ConnectionStats) ByteKey

func (c ConnectionStats) ByteKey(buffer *bytes.Buffer) ([]byte, error)

func (ConnectionStats) Copy

func (ConnectionStats) GetConnection

func (c ConnectionStats) GetConnection() ConnTuple

func (ConnectionStats) MarshalEasyJSON

func (v ConnectionStats) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (ConnectionStats) MarshalJSON

func (v ConnectionStats) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (ConnectionStats) String

func (c ConnectionStats) String() string

func (*ConnectionStats) UnmarshalEasyJSON

func (v *ConnectionStats) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*ConnectionStats) UnmarshalJSON

func (v *ConnectionStats) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

func (ConnectionStats) WithNamespace

func (c ConnectionStats) WithNamespace(namespace string) ConnectionStats

enriches the connection stats with namespace if it's a localhost connection

func (ConnectionStats) WithOnlyLocal

func (c ConnectionStats) WithOnlyLocal() ConnectionStats

func (ConnectionStats) WithUnknownDirection

func (c ConnectionStats) WithUnknownDirection() ConnectionStats

type ConnectionType

type ConnectionType uint8
const (
	TCP ConnectionType = 0
	UDP ConnectionType = 1
)

func (ConnectionType) String

func (c ConnectionType) String() string

type Connections

type Connections struct {
	Conns []ConnectionStats `json:"connections"`
}

func (Connections) MarshalEasyJSON

func (v Connections) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (Connections) MarshalJSON

func (v Connections) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*Connections) UnmarshalEasyJSON

func (v *Connections) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Connections) UnmarshalJSON

func (v *Connections) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type Direction

type Direction uint8
const (
	UNKNOWN  Direction = 0
	OUTGOING Direction = 1
	INCOMING Direction = 2
)

func (Direction) String

func (d Direction) String() string

type HTTPResponse

type HTTPResponse struct {
	StatusCode   int
	ResponseTime time.Duration
}

type Histogram

type Histogram struct {
	DDSketch *ddsketch.DDSketch
}

func (*Histogram) MarshalJSON

func (m *Histogram) MarshalJSON() ([]byte, error)

func (*Histogram) UnmarshalJSON

func (m *Histogram) UnmarshalJSON(data []byte) error

type MetricName

type MetricName string
const (
	// HTTPResponseTime is for the metric that is sent with a connection
	HTTPResponseTime MetricName = "http_response_time_seconds"

	// HTTPRequestsPerSecond is for the metric that is sent with a connection
	HTTPRequestsPerSecond MetricName = "http_requests_per_second"

	// HTTPStatusCodeTagName Status Code tag name
	HTTPStatusCodeTagName = "code"
)

type MySQLGreeting

type MySQLGreeting struct {
	ProtocolVersion int
}

type PerfEvent

type PerfEvent struct {
	HTTPResponse  *HTTPResponse
	MySQLGreeting *MySQLGreeting
	Connection    *ConnTuple
	Timestamp     time.Time
}

type State

type State uint8
const (
	INITIALIZING  State = 0
	ACTIVE        State = 1
	ACTIVE_CLOSED State = 2
	CLOSED        State = 3
)

func (State) String

func (s State) String() string

Jump to

Keyboard shortcuts

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