Documentation
¶
Index ¶
- Constants
- func ParseURL(url string) (map[string]string, error)
- type ConnectionInfo
- type ConnectionInfoArguments
- type ExplainPlan
- type ExplainPlanArguments
- type PgSQLExplainplan
- type PlanNode
- type QueryDetails
- type QueryDetailsArguments
- type QuerySamples
- type QuerySamplesArguments
- type QuerySamplesInfo
- type SampleKey
- type SampleState
- type SchemaDetails
- type SchemaDetailsArguments
- type TableRegistry
- type WaitEventIdentity
- type WaitEventOccurrence
- type WaitEventTracker
Constants ¶
const ( ExplainPlanCollector = "explain_plans" OP_EXPLAIN_PLAN_OUTPUT = "explain_plan_output" )
const ( QueryDetailsCollector = "query_details" OP_QUERY_ASSOCIATION = "query_association" OP_QUERY_PARSED_TABLE_NAME = "query_parsed_table_name" )
const ( QuerySamplesCollector = "query_samples" OP_QUERY_SAMPLE = "query_sample" OP_WAIT_EVENT = "wait_event" )
const ( SchemaDetailsCollector = "schema_details" OP_SCHEMA_DETECTION = "schema_detection" OP_TABLE_DETECTION = "table_detection" OP_CREATE_STATEMENT = "create_statement" )
const ConnectionInfoName = "connection_info"
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ConnectionInfo ¶
type ConnectionInfo struct {
DSN string
Registry *prometheus.Registry
EngineVersion string
InfoMetric *prometheus.GaugeVec
CloudProvider *database_observability.CloudProvider
// contains filtered or unexported fields
}
func NewConnectionInfo ¶
func NewConnectionInfo(args ConnectionInfoArguments) (*ConnectionInfo, error)
func (*ConnectionInfo) Name ¶
func (c *ConnectionInfo) Name() string
func (*ConnectionInfo) Stop ¶
func (c *ConnectionInfo) Stop()
func (*ConnectionInfo) Stopped ¶
func (c *ConnectionInfo) Stopped() bool
type ConnectionInfoArguments ¶
type ConnectionInfoArguments struct {
DSN string
Registry *prometheus.Registry
EngineVersion string
CloudProvider *database_observability.CloudProvider
}
type ExplainPlan ¶
type ExplainPlan struct {
// contains filtered or unexported fields
}
func NewExplainPlan ¶
func NewExplainPlan(args ExplainPlanArguments) (*ExplainPlan, error)
func (*ExplainPlan) Name ¶
func (c *ExplainPlan) Name() string
func (*ExplainPlan) Stop ¶
func (c *ExplainPlan) Stop()
func (*ExplainPlan) Stopped ¶
func (c *ExplainPlan) Stopped() bool
type ExplainPlanArguments ¶
type PgSQLExplainplan ¶ added in v1.11.0
type PgSQLExplainplan struct {
Plan PlanNode `json:"Plan"`
}
type PlanNode ¶ added in v1.11.0
type PlanNode struct {
NodeType string `json:"Node Type"`
Alias string `json:"Alias"`
RelationName string `json:"Relation Name"`
ParentRelationship string `json:"Parent Relationship"`
PartialMode string `json:"Partial Mode"`
Strategy string `json:"Strategy"`
ParallelAware bool `json:"Parallel Aware"`
AsyncCapable bool `json:"Async Capable"`
JoinType string `json:"Join Type"`
InnerUnique bool `json:"Inner Unique"`
HashCond string `json:"Hash Cond"`
Filter string `json:"Filter"`
StartupCost float64 `json:"Startup Cost"`
TotalCost float64 `json:"Total Cost"`
PlanRows int64 `json:"Plan Rows"`
PlanWidth int64 `json:"Plan Width"`
GroupKey []string `json:"Group Key"`
SortKey []string `json:"Sort Key"`
WorkersPlanned int64 `json:"Workers Planned"`
PlannedPartitions int64 `json:"Planned Partitions"`
Plans []PlanNode `json:"Plans"`
IndexName string `json:"Index Name"`
}
func (*PlanNode) ToExplainPlanOutputNode ¶ added in v1.11.0
func (p *PlanNode) ToExplainPlanOutputNode() (database_observability.ExplainPlanNode, error)
type QueryDetails ¶ added in v1.11.0
type QueryDetails struct {
// contains filtered or unexported fields
}
func NewQueryDetails ¶ added in v1.11.0
func NewQueryDetails(args QueryDetailsArguments) (*QueryDetails, error)
func (*QueryDetails) Name ¶ added in v1.11.0
func (c *QueryDetails) Name() string
func (*QueryDetails) Start ¶ added in v1.11.0
func (c *QueryDetails) Start(ctx context.Context) error
func (*QueryDetails) Stop ¶ added in v1.11.0
func (c *QueryDetails) Stop()
Stop should be kept idempotent
func (*QueryDetails) Stopped ¶ added in v1.11.0
func (c *QueryDetails) Stopped() bool
type QueryDetailsArguments ¶ added in v1.11.0
type QueryDetailsArguments struct {
DB *sql.DB
CollectInterval time.Duration
EntryHandler loki.EntryHandler
TableRegistry *TableRegistry
Logger log.Logger
}
type QuerySamples ¶ added in v1.11.0
type QuerySamples struct {
// contains filtered or unexported fields
}
func NewQuerySamples ¶ added in v1.11.0
func NewQuerySamples(args QuerySamplesArguments) (*QuerySamples, error)
func (*QuerySamples) Name ¶ added in v1.11.0
func (c *QuerySamples) Name() string
func (*QuerySamples) Start ¶ added in v1.11.0
func (c *QuerySamples) Start(ctx context.Context) error
func (*QuerySamples) Stop ¶ added in v1.11.0
func (c *QuerySamples) Stop()
Stop should be kept idempotent
func (*QuerySamples) Stopped ¶ added in v1.11.0
func (c *QuerySamples) Stopped() bool
type QuerySamplesArguments ¶ added in v1.11.0
type QuerySamplesInfo ¶ added in v1.11.0
type QuerySamplesInfo struct {
DatabaseName sql.NullString
DatabaseID int
PID int
LeaderPID sql.NullInt64
UserSysID int
Username sql.NullString
ApplicationName sql.NullString
ClientAddr sql.NullString
ClientPort sql.NullInt32
StateChange sql.NullTime
Now time.Time
BackendStart sql.NullTime
XactStart sql.NullTime
QueryStart sql.NullTime
WaitEventType sql.NullString
WaitEvent sql.NullString
State sql.NullString
BackendType sql.NullString
BackendXID sql.NullInt32
BackendXmin sql.NullInt32
QueryID sql.NullInt64
Query sql.NullString
BlockedByPIDs pq.Int64Array
}
type SampleKey ¶
SampleKey uses (PID, QueryID, QueryStartNs) so concurrent executions of the same query across backends/transactions are uniquely tracked between scrapes.
type SampleState ¶
type SampleState struct {
LastRow QuerySamplesInfo
LastSeenAt time.Time
LastCpuTime string // last cpu_time observed under CPU condition
// EndAt is the time we determined the sample ended (idle transition
// or when it was only observed idle), used to compute durations/timestamps.
EndAt sql.NullTime
// contains filtered or unexported fields
}
SampleState buffers state across scrapes and is emitted once the query turns idle or disappears, avoiding partial/duplicate emissions.
type SchemaDetails ¶ added in v1.11.0
type SchemaDetails struct {
// contains filtered or unexported fields
}
func NewSchemaDetails ¶ added in v1.11.0
func NewSchemaDetails(args SchemaDetailsArguments) (*SchemaDetails, error)
func (*SchemaDetails) GetTableRegistry ¶
func (c *SchemaDetails) GetTableRegistry() *TableRegistry
func (*SchemaDetails) Name ¶ added in v1.11.0
func (c *SchemaDetails) Name() string
func (*SchemaDetails) Start ¶ added in v1.11.0
func (c *SchemaDetails) Start(ctx context.Context) error
func (*SchemaDetails) Stop ¶ added in v1.11.0
func (c *SchemaDetails) Stop()
Stop should be kept idempotent
func (*SchemaDetails) Stopped ¶ added in v1.11.0
func (c *SchemaDetails) Stopped() bool
type SchemaDetailsArguments ¶ added in v1.11.0
type TableRegistry ¶
type TableRegistry struct {
// contains filtered or unexported fields
}
TableRegistry is a source-of-truth cache that keeps track of databases, schemas, tables
func NewTableRegistry ¶
func NewTableRegistry() *TableRegistry
func (*TableRegistry) IsValid ¶
func (tr *TableRegistry) IsValid(database database, parsedTableName string) bool
IsValid returns whether or not a given database and parsed table name exists in the source-of-truth table registry
func (*TableRegistry) SetTablesForDatabase ¶
func (tr *TableRegistry) SetTablesForDatabase(database database, tablesInfo []*tableInfo)
type WaitEventIdentity ¶
type WaitEventIdentity struct {
// contains filtered or unexported fields
}
WaitEventIdentity defines the identity of a wait-event occurrence (type, event, blocked_by set)
func (WaitEventIdentity) Equal ¶
func (w WaitEventIdentity) Equal(other WaitEventIdentity) bool
type WaitEventOccurrence ¶
type WaitEventOccurrence struct {
WaitEventType string
WaitEvent string
BlockedByPIDs []int64 // normalized set (sorted, unique)
LastWaitTime string // last stateDuration seen for this wait event
LastState string
LastTimestamp time.Time
}
WaitEventOccurrence tracks a continuous occurrence of the same wait event with the same blocked_by_pids set.
type WaitEventTracker ¶
type WaitEventTracker struct {
// contains filtered or unexported fields
}
WaitEventTracker coalesces consecutive identical wait events to reduce log volume while preserving timing.
func (*WaitEventTracker) CloseOpen ¶
func (t *WaitEventTracker) CloseOpen()
func (*WaitEventTracker) WaitEvents ¶
func (t *WaitEventTracker) WaitEvents() []WaitEventOccurrence