Documentation
¶
Index ¶
- func SetVersions(versions map[string]string)
- type QueryCollector
- func (q *QueryCollector) Add(sql string, duration time.Duration, rows int64, err error)
- func (q *QueryCollector) ApplyToEvent(event *zerolog.Event) *zerolog.Event
- func (q *QueryCollector) HasQueries() bool
- func (q *QueryCollector) TotalDuration() time.Duration
- func (q *QueryCollector) TotalQueries() int
- type QueryInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetVersions ¶
Set version information that you care to track e.g. database version, sql driver version, gorm version Allows to have greater insight and analysis towards DB performance and identify anomalies that can be related to version changes.
Types ¶
type QueryCollector ¶
type QueryCollector struct {
// contains filtered or unexported fields
}
Stores a list of database query information
func NewQueryCollector ¶
func NewQueryCollector(includeSql bool) *QueryCollector
Creates a new query collector If includeSql is set to true, the SQL query is stored NOTE: Only set includeSql to true in a development environment, by nature of including SQL queries, it will disclose user information that should not be present in production logs
func (*QueryCollector) Add ¶
Adds a query to the query collector The sql string will only be stored in the collector if includeSql was set to true in the constructor
func (*QueryCollector) ApplyToEvent ¶
func (q *QueryCollector) ApplyToEvent(event *zerolog.Event) *zerolog.Event
Applies all of the queries as well as a total queries and total query duration field to the database field of a zerolog event
func (*QueryCollector) HasQueries ¶
func (q *QueryCollector) HasQueries() bool
Returns true if any queries were stored
func (*QueryCollector) TotalDuration ¶
func (q *QueryCollector) TotalDuration() time.Duration
Returns the sum of all query durations
func (*QueryCollector) TotalQueries ¶
func (q *QueryCollector) TotalQueries() int
Returns the total number of queries collected