querymetrics

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultLimit      = 250
	MaxQueryTextBytes = 4 << 10 // 4 KiB

)
View Source
const (
	ServiceNameAttribute      = "service.name"
	DatabaseSystemAttribute   = "db.system"
	CollectorVersionAttribute = "querycomment.collector.version"
)

Variables

This section is empty.

Functions

func LimitQueryText added in v0.1.3

func LimitQueryText(queryText string) string

func NewResourceLogsConsumer added in v0.1.3

func NewResourceLogsConsumer(
	next consumer.Logs,
	databaseSystem string,
	serviceName string,
	settings receiver.Settings,
) consumer.Logs

NewResourceLogsConsumer wraps a logs consumer and stamps the common database resource attributes on every ResourceLogs item it receives.

func NewResourceMetricsConsumer added in v0.1.3

func NewResourceMetricsConsumer(
	next consumer.Metrics,
	databaseSystem string,
	serviceName string,
	settings receiver.Settings,
) consumer.Metrics

NewResourceMetricsConsumer wraps a metrics consumer and stamps the common database resource attributes on every ResourceMetrics item it receives.

func SQLSignature

func SQLSignature(normalizedQuery string) string

SQLSignature returns a stable 128-bit identifier for normalized SQL text.

func SetDatabaseResourceAttributes added in v0.1.3

func SetDatabaseResourceAttributes(attributes pcommon.Map, databaseSystem string, serviceName string, settings receiver.Settings)

SetDatabaseResourceAttributes sets the common database resource attributes used by QueryComment metrics and logs.

func ValidateCandidateLimit added in v0.1.3

func ValidateCandidateLimit(limit, candidateLimit, maximum int) error

ValidateCandidateLimit checks the common top-N candidate-pool bounds.

Types

type Config

type Config struct {
	Enabled      bool               `mapstructure:"enabled"`
	Limit        int                `mapstructure:"limit"`
	ExplainPlans ExplainPlansConfig `mapstructure:"explain_plans"`
}

func DefaultConfig

func DefaultConfig() Config

func (Config) Validate

func (c Config) Validate() error

type ExplainPlansConfig added in v0.1.3

type ExplainPlansConfig struct {
	Enabled            bool          `mapstructure:"enabled"`
	MaxPerInterval     int           `mapstructure:"max_per_interval"`
	CacheSize          int           `mapstructure:"cache_size"`
	CacheTTL           time.Duration `mapstructure:"cache_ttl"`
	FailureCacheTTL    time.Duration `mapstructure:"failure_cache_ttl"`
	QueryTimeout       time.Duration `mapstructure:"query_timeout"`
	CollectionTimeout  time.Duration `mapstructure:"collection_timeout"`
	CollectionInterval time.Duration `mapstructure:"collection_interval"`
	MaxPlanBytes       int           `mapstructure:"max_plan_bytes"`
}

func (ExplainPlansConfig) Validate added in v0.1.3

func (c ExplainPlansConfig) Validate() error

type Snapshot added in v0.1.3

type Snapshot[T any] struct {
	CollectedAt time.Time
	Rows        []T
}

type SnapshotStore added in v0.1.3

type SnapshotStore[T any] struct {
	// contains filtered or unexported fields
}

func NewSnapshotStore added in v0.1.3

func NewSnapshotStore[T any]() *SnapshotStore[T]

func (*SnapshotStore[T]) Load added in v0.1.3

func (s *SnapshotStore[T]) Load() Snapshot[T]

func (*SnapshotStore[T]) Publish added in v0.1.3

func (s *SnapshotStore[T]) Publish(rows []T, collectedAt time.Time)

func (*SnapshotStore[T]) Shutdown added in v0.1.3

func (*SnapshotStore[T]) Shutdown(context.Context) error

func (*SnapshotStore[T]) Start added in v0.1.3

Jump to

Keyboard shortcuts

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