reporter

package
v0.0.0-...-0958f0d Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: Apache-2.0 Imports: 24 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CollectorReporter

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

CollectorReporter receives and transforms information to be Collector Collector compliant.

func NewCollector

func NewCollector(cfg *Config, nextConsumer consumerprofiles.Profiles) (*CollectorReporter, error)

NewCollector builds a new CollectorReporter

func (CollectorReporter) ExecutableKnown

func (b CollectorReporter) ExecutableKnown(fileID libpf.FileID) bool

func (CollectorReporter) ExecutableMetadata

func (b CollectorReporter) ExecutableMetadata(args *ExecutableMetadataArgs)

func (CollectorReporter) FrameKnown

func (b CollectorReporter) FrameKnown(frameID libpf.FrameID) bool

func (CollectorReporter) FrameMetadata

func (b CollectorReporter) FrameMetadata(args *FrameMetadataArgs)

func (*CollectorReporter) GetMetrics

func (r *CollectorReporter) GetMetrics() Metrics

func (CollectorReporter) ReportCountForTrace

func (b CollectorReporter) ReportCountForTrace(_ libpf.TraceHash, _ uint16, _ *TraceEventMeta)

ReportCountForTrace is a NOP

func (CollectorReporter) ReportFramesForTrace

func (CollectorReporter) ReportFramesForTrace(_ *libpf.Trace)

ReportFramesForTrace is a NOP

func (CollectorReporter) ReportHostMetadata

func (b CollectorReporter) ReportHostMetadata(metadataMap map[string]string)

func (CollectorReporter) ReportHostMetadataBlocking

func (b CollectorReporter) ReportHostMetadataBlocking(_ context.Context,
	metadataMap map[string]string, _ int, _ time.Duration) error

func (CollectorReporter) ReportMetrics

func (CollectorReporter) ReportMetrics(_ uint32, _ []uint32, _ []int64)

func (CollectorReporter) ReportTraceEvent

func (b CollectorReporter) ReportTraceEvent(trace *libpf.Trace, meta *TraceEventMeta)

func (*CollectorReporter) Start

func (r *CollectorReporter) Start(ctx context.Context) error

func (CollectorReporter) Stop

func (b CollectorReporter) Stop()

func (CollectorReporter) SupportsReportTraceEvent

func (CollectorReporter) SupportsReportTraceEvent() bool

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
	// ExecutablesCacheElements defines item capacity of the executables cache.
	ExecutablesCacheElements uint32
	// FramesCacheElements defines the item capacity of the frames cache.
	FramesCacheElements uint32
	// CGroupCacheElements defines the item capacity of the cgroup cache.
	CGroupCacheElements 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

	// ExtraSampleAttrProd is an optional hook point for adding custom
	// attributes to samples.
	ExtraSampleAttrProd samples.SampleAttrProducer
}

type ExecutableMetadataArgs

type ExecutableMetadataArgs struct {
	// FileID is a unique identifier of the executable.
	FileID libpf.FileID
	// FileName is the base filename of the executable.
	FileName string
	// GnuBuildID is the GNU build ID from .note.gnu.build-id, if any.
	GnuBuildID string
	// DebuglinkFileName is the path to the matching debug file
	// from the .gnu.debuglink, if any. The caller should
	// verify that the file in question matches the GnuBuildID of this executable..
	DebuglinkFileName string
	// Interp is the discovered interpreter type of this executable, if any.
	Interp libpf.InterpreterType
	// Open is a function that can be used to open the executable for reading,
	// or nil for interpreters that don't support this.
	Open ExecutableOpener
}

ExecutableMetadataArgs collects metadata about a discovered executable, for reporting to a SymbolReporter via the ExecutableMetadata function.

type ExecutableOpener

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

ExecutableOpener is a function that attempts to open an executable.

type FrameMetadataArgs

type FrameMetadataArgs struct {
	// FrameID is a unique identifier for the frame.
	FrameID libpf.FrameID
	// FunctionName is the name of the function for the frame.
	FunctionName string
	// SourceFile is the source code file name for the frame.
	SourceFile string
	// SourceLine is the source code level line number of this frame.
	SourceLine libpf.SourceLineno
	// FunctionOffset is the line offset from function start line for the frame.
	FunctionOffset uint32
}

FrameMetadataArgs collects metadata about a single frame in a trace, for reporting it to a SymbolReporter via the FrameMetadata method.

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 {
	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 NewOTLP

func NewOTLP(cfg *Config) (*OTLPReporter, error)

NewOTLP returns a new instance of OTLPReporter

func (OTLPReporter) ExecutableKnown

func (b OTLPReporter) ExecutableKnown(fileID libpf.FileID) bool

func (OTLPReporter) ExecutableMetadata

func (b OTLPReporter) ExecutableMetadata(args *ExecutableMetadataArgs)

func (OTLPReporter) FrameKnown

func (b OTLPReporter) FrameKnown(frameID libpf.FrameID) bool

func (OTLPReporter) FrameMetadata

func (b OTLPReporter) FrameMetadata(args *FrameMetadataArgs)

func (*OTLPReporter) GetMetrics

func (r *OTLPReporter) GetMetrics() Metrics

GetMetrics returns internal metrics of OTLPReporter.

func (OTLPReporter) ReportCountForTrace

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

ReportCountForTrace is a NOP

func (OTLPReporter) ReportFramesForTrace

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

ReportFramesForTrace is a NOP

func (OTLPReporter) ReportHostMetadata

func (b OTLPReporter) ReportHostMetadata(metadataMap map[string]string)

func (OTLPReporter) ReportHostMetadataBlocking

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

func (OTLPReporter) ReportMetrics

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

func (OTLPReporter) ReportTraceEvent

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

func (*OTLPReporter) Start

func (r *OTLPReporter) Start(ctx context.Context) error

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

func (OTLPReporter) Stop

func (b OTLPReporter) Stop()

func (OTLPReporter) SupportsReportTraceEvent

func (OTLPReporter) SupportsReportTraceEvent() bool

type Reporter

type Reporter interface {
	TraceReporter
	SymbolReporter
	HostMetadataReporter
	MetricsReporter

	// Start starts the reporter in the background.
	//
	// If the reporter needs to perform a long-running starting operation then it
	// is recommended that Start() returns quickly and the long-running operation
	// is performed in the background.
	Start(context.Context) error

	// 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.

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 {
	// ExecutableKnown may be used to query the reporter if the FileID is known.
	// The callers of ExecutableMetadata can optionally use this method to determine if the data
	// is already cached and avoid extra work resolving the metadata. If the reporter returns false,
	// the caller will resolve the executable metadata and submit it to the reporter
	// via a subsequent ExecutableMetadata call.
	ExecutableKnown(fileID libpf.FileID) bool

	// ExecutableMetadata accepts a FileID with the corresponding filename
	// and takes some action with it (for example, it might cache it for
	// periodic reporting to a 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(args *ExecutableMetadataArgs)

	// FrameKnown may be used to query the reporter if the FrameID is known. The interpreter
	// modules can optionally use this method to determine if the data is already cached
	// and avoid extra work resolving the metadata. If the reporter returns false,
	// the interpreter plugin will resolve the frame metadata and submit it to the reporter
	// via a subsequent FrameMetadata call.
	FrameKnown(frameID libpf.FrameID) bool

	// FrameMetadata accepts metadata associated with a frame and caches this information before
	// a periodic reporting to the backend.
	FrameMetadata(frameMetadata *FrameMetadataArgs)
}

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 = samples.TraceEventMeta

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
}

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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