reporter

package
v0.0.0-...-b755a7c Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2024 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Name defines the name of the agent.
	Name string

	// Version defines the version of the agent.
	Version string

	// CollAgentAddr defines the destination of the backend connection.
	CollAgentAddr string

	// MaxRPCMsgSize defines the maximum size of a gRPC message.
	MaxRPCMsgSize int

	// Disable secure communication with Collection Agent.
	DisableTLS bool
	// CacheSize defines the size of the reporter caches.
	CacheSize uint32
	// samplesPerSecond defines the number of samples per second.
	SamplesPerSecond int
	// HostID is the host ID to be sent to the collection agent.
	HostID uint64
	// KernelVersion is the kernel version of the host.
	KernelVersion string
	// HostName is the name of the host.
	HostName string
	// IPAddress is the IP address of the host.
	IPAddress string

	// Number of connection attempts to the collector after which we give up retrying.
	MaxGRPCRetries uint32

	GRPCOperationTimeout   time.Duration
	GRPCStartupBackoffTime time.Duration
	GRPCConnectionTimeout  time.Duration
	ReportInterval         time.Duration

	// gRPCInterceptor is the client gRPC interceptor, e.g., for sending gRPC metadata.
	GRPCClientInterceptor grpc.UnaryClientInterceptor
}

type ExecutableOpener

type ExecutableOpener = func() (process.ReadAtCloser, error)

type FifoRingBuffer

type FifoRingBuffer[T any] struct {
	sync.Mutex
	// contains filtered or unexported fields
}

FifoRingBuffer implements a first-in-first-out ring buffer that is safe for concurrent access.

func (*FifoRingBuffer[T]) Append

func (q *FifoRingBuffer[T]) Append(v T)

Append adds element v to the FifoRingBuffer. it overwrites existing elements if there is no space left.

func (*FifoRingBuffer[T]) GetOverwriteCount

func (q *FifoRingBuffer[T]) GetOverwriteCount() uint32

func (*FifoRingBuffer[T]) InitFifo

func (q *FifoRingBuffer[T]) InitFifo(size uint32, name string) error

func (*FifoRingBuffer[T]) ReadAll

func (q *FifoRingBuffer[T]) ReadAll() []T

ReadAll returns all elements from the FifoRingBuffer.

type HostMetadataReporter

type HostMetadataReporter interface {
	// ReportHostMetadata enqueues host metadata for sending (to the collection agent).
	ReportHostMetadata(metadataMap map[string]string)

	// ReportHostMetadataBlocking sends host metadata to the collection agent.
	ReportHostMetadataBlocking(ctx context.Context, metadataMap map[string]string,
		maxRetries int, waitRetry time.Duration) error
}

type Metrics

type Metrics struct {
	CountsForTracesOverwriteCount uint32
	ExeMetadataOverwriteCount     uint32
	FrameMetadataOverwriteCount   uint32
	FramesForTracesOverwriteCount uint32
	HostMetadataOverwriteCount    uint32
	MetricsOverwriteCount         uint32
	FallbackSymbolsOverwriteCount uint32
	RPCBytesOutCount              int64
	RPCBytesInCount               int64
	WireBytesOutCount             int64
	WireBytesInCount              int64
}

Metrics holds the metric counters for the reporter package.

type MetricsReporter

type MetricsReporter interface {
	// ReportMetrics accepts an id with a corresponding value and caches this
	// information before a periodic reporting to the backend.
	ReportMetrics(timestamp uint32, ids []uint32, values []int64)
}

type OTLPReporter

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

OTLPReporter receives and transforms information to be OTLP/profiles compliant.

func (*OTLPReporter) ExecutableMetadata

func (r *OTLPReporter) ExecutableMetadata(fileID libpf.FileID, fileName,
	gnuBuildID string, _ libpf.InterpreterType, _ ExecutableOpener)

ExecutableMetadata accepts a fileID with the corresponding filename and caches this information.

func (*OTLPReporter) FrameMetadata

func (r *OTLPReporter) FrameMetadata(fileID libpf.FileID, addressOrLine libpf.AddressOrLineno,
	lineNumber libpf.SourceLineno, functionOffset uint32, functionName, filePath string)

FrameMetadata accepts metadata associated with a frame and caches this information.

func (*OTLPReporter) GetMetrics

func (r *OTLPReporter) GetMetrics() Metrics

GetMetrics returns internal metrics of OTLPReporter.

func (*OTLPReporter) ReportCountForTrace

func (r *OTLPReporter) ReportCountForTrace(_ libpf.TraceHash, _ uint16, _ *TraceEventMeta)

ReportCountForTrace is a NOP for OTLPReporter.

func (*OTLPReporter) ReportFallbackSymbol

func (r *OTLPReporter) ReportFallbackSymbol(frameID libpf.FrameID, symbol string)

ReportFallbackSymbol enqueues a fallback symbol for reporting, for a given frame.

func (*OTLPReporter) ReportFramesForTrace

func (r *OTLPReporter) ReportFramesForTrace(_ *libpf.Trace)

ReportFramesForTrace is a NOP for OTLPReporter.

func (*OTLPReporter) ReportHostMetadata

func (r *OTLPReporter) ReportHostMetadata(metadataMap map[string]string)

ReportHostMetadata enqueues host metadata.

func (*OTLPReporter) ReportHostMetadataBlocking

func (r *OTLPReporter) ReportHostMetadataBlocking(_ context.Context,
	metadataMap map[string]string, _ int, _ time.Duration) error

ReportHostMetadataBlocking enqueues host metadata.

func (*OTLPReporter) ReportMetrics

func (r *OTLPReporter) ReportMetrics(_ uint32, _ []uint32, _ []int64)

ReportMetrics is a NOP for OTLPReporter.

func (*OTLPReporter) ReportTraceEvent

func (r *OTLPReporter) ReportTraceEvent(trace *libpf.Trace, meta *TraceEventMeta)

ReportTraceEvent enqueues reported trace events for the OTLP reporter.

func (*OTLPReporter) Stop

func (r *OTLPReporter) Stop()

Stop triggers a graceful shutdown of OTLPReporter.

func (*OTLPReporter) SupportsReportTraceEvent

func (r *OTLPReporter) SupportsReportTraceEvent() bool

type Reporter

type Reporter interface {
	TraceReporter
	SymbolReporter
	HostMetadataReporter
	MetricsReporter

	// Stop triggers a graceful shutdown of the reporter.
	Stop()
	// GetMetrics returns the reporter internal metrics.
	GetMetrics() Metrics
}

Reporter is the top-level interface implemented by a full reporter.

func Start

func Start(mainCtx context.Context, cfg *Config) (Reporter, error)

Start sets up and manages the reporting connection to a OTLP backend.

type StatsHandlerImpl

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

func NewStatsHandler

func NewStatsHandler() *StatsHandlerImpl

NewStatsHandler creates a new statistics handler.

func (*StatsHandlerImpl) GetRPCBytesIn

func (sh *StatsHandlerImpl) GetRPCBytesIn() int64

func (*StatsHandlerImpl) GetRPCBytesOut

func (sh *StatsHandlerImpl) GetRPCBytesOut() int64

func (*StatsHandlerImpl) GetWireBytesIn

func (sh *StatsHandlerImpl) GetWireBytesIn() int64

func (*StatsHandlerImpl) GetWireBytesOut

func (sh *StatsHandlerImpl) GetWireBytesOut() int64

func (*StatsHandlerImpl) HandleConn

func (sh *StatsHandlerImpl) HandleConn(context.Context, stats.ConnStats)

HandleConn implements the stats.Handler interface.

func (*StatsHandlerImpl) HandleRPC

func (sh *StatsHandlerImpl) HandleRPC(ctx context.Context, s stats.RPCStats)

HandleRPC implements the stats.Handler interface.

func (*StatsHandlerImpl) TagConn

TagConn implements the stats.Handler interface.

func (*StatsHandlerImpl) TagRPC

TagRPC implements the stats.Handler interface.

type SymbolReporter

type SymbolReporter interface {
	// ReportFallbackSymbol enqueues a fallback symbol for reporting, for a given frame.
	ReportFallbackSymbol(frameID libpf.FrameID, symbol string)

	// ExecutableMetadata accepts a fileID with the corresponding filename
	// and caches this information before a periodic reporting to the backend.
	//
	// The `open` argument can be used to open the executable for reading. Interpreters
	// that don't support this may pass a `nil` function pointer. Implementations that
	// wish to upload executables should NOT block this function to do so and instead just
	// open the file and then enqueue the upload in the background.
	ExecutableMetadata(fileID libpf.FileID, fileName, gnuBuildID string,
		interp libpf.InterpreterType, open ExecutableOpener)

	// FrameMetadata accepts metadata associated with a frame and caches this information before
	// a periodic reporting to the backend.
	FrameMetadata(fileID libpf.FileID, addressOrLine libpf.AddressOrLineno,
		lineNumber libpf.SourceLineno, functionOffset uint32, functionName, filePath string)
}

type Times

type Times interface {
	ReportInterval() time.Duration
	ReportMetricsInterval() time.Duration
	GRPCConnectionTimeout() time.Duration
	GRPCOperationTimeout() time.Duration
	GRPCStartupBackoffTime() time.Duration
	GRPCAuthErrorDelay() time.Duration
}

Times is a subset of config.IntervalsAndTimers.

type TraceEventMeta

type TraceEventMeta struct {
	Timestamp      libpf.UnixTime64
	Comm           string
	APMServiceName string
	PID, TID       libpf.PID
}

type TraceReporter

type TraceReporter interface {
	// ReportFramesForTrace accepts a trace with the corresponding frames
	// and caches this information before a periodic reporting to the backend.
	ReportFramesForTrace(trace *libpf.Trace)

	// ReportCountForTrace accepts a hash of a trace with a corresponding count and
	// caches this information before a periodic reporting to the backend.
	ReportCountForTrace(traceHash libpf.TraceHash, count uint16, meta *TraceEventMeta)

	// ReportTraceEvent accepts a trace event (trace metadata with frames and counts)
	// and caches it for reporting to the backend. It returns true if the event was
	// enqueued for reporting, and false if the event was ignored.
	ReportTraceEvent(trace *libpf.Trace, meta *TraceEventMeta)

	// SupportsReportTraceEvent returns true if the reporter supports reporting trace events
	// via ReportTraceEvent().
	SupportsReportTraceEvent() bool
}

Jump to

Keyboard shortcuts

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