http

package
v0.0.0-...-234771b Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package http contains the userspace portion of USM's HTTP monitoring code

Index

Constants

View Source
const (
	BufferSize = 0xd0
)
View Source
const RelativeAccuracy = 0.01

RelativeAccuracy defines the acceptable error in quantile values calculated by DDSketch. For example, if the actual value at p50 is 100, with a relative accuracy of 0.01 the value calculated will be between 99 and 101

Variables

Interner is used to intern strings to save memory allocations.

View Source
var (
	StaticTags = map[ConnTag]string{
		GnuTLS:  "tls.library:gnutls",
		OpenSSL: "tls.library:openssl",
		Go:      "tls.library:go",
		TLS:     "tls.connection:encrypted",
		Istio:   "tls.library:istio",
		NodeJS:  "tls.library:nodejs",
	}
)

Functions

This section is empty.

Types

type ConnTag

type ConnTag = uint64
const (
	GnuTLS  ConnTag = 0x1
	OpenSSL ConnTag = 0x2
	Go      ConnTag = 0x4
	TLS     ConnTag = 0x8
	Istio   ConnTag = 0x10
	NodeJS  ConnTag = 0x20
)

type ConnTuple

type ConnTuple = struct {
	Saddr_h  uint64
	Saddr_l  uint64
	Daddr_h  uint64
	Daddr_l  uint64
	Sport    uint16
	Dport    uint16
	Netns    uint32
	Pid      uint32
	Metadata uint32
}

type EbpfEvent

type EbpfEvent struct {
	Tuple ConnTuple
	Http  EbpfTx
}

type EbpfTx

type EbpfTx struct {
	Request_started      uint64
	Response_last_seen   uint64
	Tags                 uint64
	Tcp_seq              uint32
	Response_status_code uint16
	Request_method       uint8
	Pad_cgo_0            [1]byte
	Request_fragment     [208]byte
}

type Key

type Key struct {
	// this field order is intentional to help the GC pointer tracking
	Path Path
	types.ConnectionKey
	Method Method
}

Key is an identifier for a group of HTTP transactions

func NewKey

func NewKey(saddr, daddr util.Address, sport, dport uint16, path []byte, fullPath bool, method Method) Key

NewKey generates a new Key

func NewKeyWithConnection

func NewKeyWithConnection(connKey types.ConnectionKey, path []byte, fullPath bool, method Method) Key

NewKeyWithConnection generates a new Key with a given connection tuple

func (Key) String

func (k Key) String() string

String returns a string representation of the Key

type Method

type Method uint8

Method is the type used to represent HTTP request methods

const (
	// MethodUnknown represents an unknown request method
	MethodUnknown Method = iota
	// MethodGet represents the GET request method
	MethodGet
	// MethodPost represents the POST request method
	MethodPost
	// MethodPut represents the PUT request method
	MethodPut
	// MethodDelete represents the DELETE request method
	MethodDelete
	// MethodHead represents the HEAD request method
	MethodHead
	// MethodOptions represents the OPTIONS request method
	MethodOptions
	// MethodPatch represents the PATCH request method
	MethodPatch
	// MethodTrace represents the TRACE request method
	MethodTrace
)

func (Method) String

func (m Method) String() string

Method returns a string representing the HTTP method of the request

type Path

type Path struct {
	Content  *intern.StringValue
	FullPath bool
}

Path represents the HTTP path

type RequestStat

type RequestStat struct {
	// this field order is intentional to help the GC pointer tracking
	Latencies *ddsketch.DDSketch
	// Note: every time we add a latency value to the DDSketch, it's possible for the sketch to discard that value
	// (ie if it is outside the range that is tracked by the sketch). For that reason, in order to keep an accurate count
	// the number of http transactions processed, we have our own count field (rather than relying on DDSketch.GetCount())
	Count int

	// This field holds the value (in nanoseconds) of the first HTTP request
	// in this bucket. We do this as optimization to avoid creating sketches with
	// a single value. This is quite common in the context of HTTP requests without
	// keep-alives where a short-lived TCP connection is used for a single request.
	FirstLatencySample float64

	// Tags bitfields from tags-types.h
	StaticTags uint64

	// Dynamic tags (if attached)
	DynamicTags []string
}

RequestStat stores stats for HTTP requests to a particular path

type RequestStats

type RequestStats struct {
	Data map[uint16]*RequestStat
}

RequestStats stores HTTP request statistics.

func NewRequestStats

func NewRequestStats() *RequestStats

NewRequestStats creates a new RequestStats object.

func (*RequestStats) AddRequest

func (r *RequestStats) AddRequest(statusCode uint16, latency float64, staticTags uint64, dynamicTags []string)

AddRequest takes information about a HTTP transaction and adds it to the request stats

func (*RequestStats) CombineWith

func (r *RequestStats) CombineWith(newStats *RequestStats)

CombineWith merges the data in 2 RequestStats objects newStats is kept as it is, while the method receiver gets mutated

func (*RequestStats) HalfAllCounts

func (r *RequestStats) HalfAllCounts()

HalfAllCounts sets the count of all stats for each status class to half their current value. This is used to remove duplicates from the count in the context of Windows localhost traffic.

type SslReadArgs

type SslReadArgs struct {
	Ctx *byte
	Buf *byte
}

type SslSock

type SslSock struct {
	Tup       ConnTuple
	Fd        uint32
	Pad_cgo_0 [4]byte
}

type URLQuantizer

type URLQuantizer struct {
	// contains filtered or unexported fields
}

URLQuantizer is responsible for quantizing URLs

func NewURLQuantizer

func NewURLQuantizer() *URLQuantizer

NewURLQuantizer returns a new instance of a URLQuantizer

func (*URLQuantizer) Quantize

func (q *URLQuantizer) Quantize(path []byte) []byte

Quantize path (eg /segment1/segment2/segment3) by doing the following: * If a segment contains only letters, we keep it as it is; * If a segment contains one or more digits or special characters, we replace it by '*' * If a segments represents an API version (eg. v123) we keep it as it is

Note that the quantization happens *in-place* and the supplied argument byte slice is modified, so the returned value will still point to the same underlying byte array.

Directories

Path Synopsis
Package debugging provides a debugging view of the HTTP protocol.
Package debugging provides a debugging view of the HTTP protocol.
lookup
Package lookup provides a lookup table for the protocol package.
Package lookup provides a lookup table for the protocol package.
lookup/internal/testprogram
Package main provides a test program for generating lookup tables for TLS types
Package main provides a test program for generating lookup tables for TLS types
Package testutil provides utilities for testing the HTTP protocol.
Package testutil provides utilities for testing the HTTP protocol.

Jump to

Keyboard shortcuts

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