sqlv1

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package sqlv1 provides the normalized database slow-query log record v1.

Index

Constants

View Source
const (
	SchemaVersion = "logschema.sql.query/v1"
	Kind          = "sql.query"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Fingerprint

type Fingerprint = corev1.Fingerprint

Fingerprint is the shared versioned fingerprint representation.

type Query

type Query struct {
	SchemaVersion        string               `json:"schema_version"`
	Kind                 string               `json:"kind"`
	TimeUnixNano         *corev1.DecimalInt64 `json:"time_unix_nano"`
	ObservedTimeUnixNano *corev1.DecimalInt64 `json:"observed_time_unix_nano"`
	DurationNano         corev1.DecimalUint64 `json:"duration_nano"`
	Source               corev1.Source        `json:"source"`
	Resource             corev1.Resource      `json:"resource"`
	TraceContext         *corev1.TraceContext `json:"trace_context"`
	Data                 QueryData            `json:"data"`
}

func NewQuery

func NewQuery(
	durationNano corev1.DecimalUint64,
	source corev1.Source,
	data QueryData,
) (Query, error)

NewQuery creates and validates a SQL query record with canonical metadata.

func (Query) MarshalJSON

func (q Query) MarshalJSON() ([]byte, error)

MarshalJSON validates and encodes a SQL query record.

func (*Query) UnmarshalJSON

func (q *Query) UnmarshalJSON(data []byte) error

func (Query) Validate

func (q Query) Validate() error

type QueryData

type QueryData struct {
	DBSystem         string                `json:"db_system"`
	DatabaseName     *string               `json:"database_name"`
	Operation        *string               `json:"operation"`
	QueryText        *string               `json:"query_text"`
	QuerySummary     *string               `json:"query_summary"`
	Fingerprint      Fingerprint           `json:"fingerprint"`
	LockDurationNano *corev1.DecimalUint64 `json:"lock_duration_nano"`
	RowsSent         *corev1.DecimalUint64 `json:"rows_sent"`
	RowsExamined     *corev1.DecimalUint64 `json:"rows_examined"`
	RowsAffected     *corev1.DecimalUint64 `json:"rows_affected"`
	BytesSent        *corev1.DecimalUint64 `json:"bytes_sent"`
	Attributes       corev1.Attributes     `json:"attributes"`
}

Jump to

Keyboard shortcuts

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