util

package
v0.63.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: BSD-2-Clause, BSD-3-Clause, PostgreSQL Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const CollectorNameAndVersion = "pganalyze-collector " + CollectorVersion
View Source
const CollectorVersion = "0.63.0"
View Source
const QueryTextCollector string = "<pganalyze-collector>"

QueryTextCollector - Query generated by the pganalyze collector itself.

View Source
const QueryTextInsufficientPrivs string = "<insufficient privilege>"

QueryTextInsufficientPrivs - We did not have permissions to read this query text.

View Source
const QueryTextTruncated string = "<truncated query>"

QueryTextTruncated - Query was unparsable and is exactly track_activity_query_size-1 long. Only applies to query text from pg_stat_activity. This can be mitigated by raising track_activity_query_size.

View Source
const QueryTextUnavailable string = "<query text unavailable>"

QueryTextUnavailable - We only have the pg_stat_statement queryid for this query, not the actual query text. This occurs when there is high churn on the pg_stat_statements data and the less frequent query text collection didn't contain the text anymore for a query ID we saw earlier. Can be mitigated by increasing pg_stat_statements.max.

View Source
const QueryTextUnparsable string = "<unparsable query>"

QueryTextUnparsable - Query was unparsable and we don't know why. This could be because of the pg_query parser not yet understanding the syntax of newer Postgres versions.

View Source
const TruncatedQueryMarker string = "/* truncated-query */ "

TruncatedQueryMarker - Added to queries that were truncated and caused a parsing error, but we were able to "fix" to allow grouping in the UI

Variables

View Source
var K8sSelectorRegexp = regexp.MustCompile(`\s*([^!=\s]+)\s*(=|==|!=)\s*([^!=\s]+)\s*`)

Functions

func BoolPtrToBool

func BoolPtrToBool(ptr *bool) bool

func CheckLabelSelectorMismatch added in v0.57.0

func CheckLabelSelectorMismatch(labels map[string]string, selectors []string) bool

CheckLabelSelectorMismatch checks if selectors do not match the given labels It uses Kubernetes Label selectors with Equality-based requirement: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#label-selectors

func CleanHTTPError added in v0.41.0

func CleanHTTPError(error error) error

Removes duplicate URLs added by retryablehttp

func FingerprintQuery

func FingerprintQuery(query string, filterQueryText string, trackActivityQuerySize int) (fp uint64)

FingerprintQuery - Generates a unique fingerprint for the given query

func FingerprintText added in v0.42.1

func FingerprintText(query string) (fp uint64)

FingerprintText - Generates a fingerprint for static texts (used for error scenarios)

func HttpRedirectToApp added in v0.43.0

func HttpRedirectToApp(w http.ResponseWriter, r *http.Request)

HttpRedirectToApp - Provides a HTTP redirect to the pganalyze app

func Int32PtrToInt added in v0.59.0

func Int32PtrToInt(ptr *int32) int32

func IntPtrToInt

func IntPtrToInt(ptr *int64) int64

func IsHeroku added in v0.55.0

func IsHeroku() bool

func IsUtilityStmt

func IsUtilityStmt(query string) ([]bool, error)

IsUtilityStmt determines whether each statement in the query text is a utility statement or a standard SELECT/INSERT/UPDATE/DELETE statement.

func NormalizeQuery

func NormalizeQuery(query string, filterQueryText string, trackActivityQuerySize int) string

NormalizeQuery - Normalizes the query text with an improved variant of the pg_stat_statements normalization logic.

func Reload

func Reload() (reloadedPid int, err error)

func SetupHttpHandlerDummy added in v0.43.0

func SetupHttpHandlerDummy()

func StringCustomTypePtrToString added in v0.59.0

func StringCustomTypePtrToString[T ~string](ptr *T) string

func StringPtrToString

func StringPtrToString(ptr *string) string

func TimeFromStr added in v0.52.3

func TimeFromStr(value string) (time.Time, error)

TimeFromStr returns a time of the given value in string. The value is the value of time either as a floating point number of seconds since the Epoch, or it can also be a integer number of seconds.

func TimePtrToTime

func TimePtrToTime(ptr *time.Time) time.Time

func TimePtrToUnixTimestamp

func TimePtrToUnixTimestamp(ptr *time.Time) int64

Types

type Logger

type Logger struct {
	Verbose        bool
	Quiet          bool
	Prefix         *string
	Destination    *log.Logger
	RememberErrors bool
	ErrorMessages  []string
	UseJSON        bool // if true, emit newline delimited JSON
}

func (*Logger) PrintError

func (logger *Logger) PrintError(format string, args ...interface{})

func (*Logger) PrintInfo

func (logger *Logger) PrintInfo(format string, args ...interface{})

func (*Logger) PrintVerbose

func (logger *Logger) PrintVerbose(format string, args ...interface{})

func (*Logger) PrintWarning

func (logger *Logger) PrintWarning(format string, args ...interface{})

func (*Logger) WithPrefix

func (logger *Logger) WithPrefix(prefix string) *Logger

func (*Logger) WithPrefixAndRememberErrors

func (logger *Logger) WithPrefixAndRememberErrors(prefix string) *Logger

type TTLMap added in v0.41.3

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

func NewTTLMap added in v0.41.3

func NewTTLMap(ttl int64) (m *TTLMap)

func (*TTLMap) Get added in v0.41.3

func (m *TTLMap) Get(k string) (v string)

func (*TTLMap) Len added in v0.41.3

func (m *TTLMap) Len() int

func (*TTLMap) Put added in v0.41.3

func (m *TTLMap) Put(k, v string)

type Timestamp

type Timestamp timestamppb.Timestamp

func (*Timestamp) Scan

func (ts *Timestamp) Scan(value interface{}) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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