Help us shape the future of Go! Take the 2026 Go Developer Survey

sql

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Migrate

func Migrate(logger *slog.Logger, connStr string) error

Types

type DBTX

type DBTX interface {
	Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)
	Query(context.Context, string, ...interface{}) (pgx.Rows, error)
	QueryRow(context.Context, string, ...interface{}) pgx.Row
}

type FindTraceIDsParams

type FindTraceIDsParams struct {
	ServiceName                  string
	ServiceNameEnableFilter      bool
	OperationName                string
	OperationNameEnableFilter    bool
	StartTimeMinimum             pgtype.Timestamp
	StartTimeMinimumEnableFilter bool
	StartTimeMaximum             pgtype.Timestamp
	StartTimeMaximumEnableFilter bool
	DurationMinimum              pgtype.Interval
	DurationMinimumEnableFilter  bool
	DurationMaximum              pgtype.Interval
	DurationMaximumEnableFilter  bool
	NumTraces                    int32
}

type GetOperationIDParams

type GetOperationIDParams struct {
	Name      string
	ServiceID int64
	Kind      Spankind
}

type GetOperationsRow

type GetOperationsRow struct {
	Name string
	Kind Spankind
}

type GetTraceSpansRow

type GetTraceSpansRow struct {
	SpanID        []byte
	TraceID       []byte
	OperationName string
	Flags         int64
	StartTime     pgtype.Timestamp
	Duration      pgtype.Interval
	Tags          []byte
	ProcessID     string
	Warnings      []string
	Kind          Spankind
	ProcessName   string
	ProcessTags   []byte
	Logs          []byte
	Refs          []byte
}

type InsertSpanParams

type InsertSpanParams struct {
	SpanID      []byte
	TraceID     []byte
	OperationID int64
	Flags       int64
	StartTime   pgtype.Timestamp
	Duration    pgtype.Interval
	Tags        []byte
	ServiceID   int64
	ProcessID   string
	ProcessTags []byte
	Warnings    []string
	Kind        Spankind
	Logs        []byte
	Refs        []byte
}

type NullSpankind

type NullSpankind struct {
	Spankind Spankind
	Valid    bool // Valid is true if Spankind is not NULL
}

func (*NullSpankind) Scan

func (ns *NullSpankind) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullSpankind) Value

func (ns NullSpankind) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type Operation

type Operation struct {
	ID        int64
	Name      string
	ServiceID int64
	Kind      Spankind
}

type Queries

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

func New

func New(db DBTX) *Queries

func (*Queries) CleanSpans added in v1.1.0

func (q *Queries) CleanSpans(ctx context.Context, pruneBefore pgtype.Timestamp) (int64, error)

func (*Queries) FindTraceIDs

func (q *Queries) FindTraceIDs(ctx context.Context, arg FindTraceIDsParams) ([][]byte, error)

func (*Queries) GetOperationID

func (q *Queries) GetOperationID(ctx context.Context, arg GetOperationIDParams) (int64, error)

func (*Queries) GetOperations

func (q *Queries) GetOperations(ctx context.Context, serviceName string) ([]GetOperationsRow, error)

func (*Queries) GetServiceID

func (q *Queries) GetServiceID(ctx context.Context, name string) (int64, error)

func (*Queries) GetServices

func (q *Queries) GetServices(ctx context.Context) ([]string, error)

func (*Queries) GetSpansCount added in v1.5.1

func (q *Queries) GetSpansCount(ctx context.Context) (int64, error)

func (*Queries) GetSpansDiskSize added in v1.2.0

func (q *Queries) GetSpansDiskSize(ctx context.Context) (int64, error)

func (*Queries) GetTraceSpans

func (q *Queries) GetTraceSpans(ctx context.Context, traceID []byte) ([]GetTraceSpansRow, error)

func (*Queries) InsertSpan

func (q *Queries) InsertSpan(ctx context.Context, arg InsertSpanParams) (int64, error)

func (*Queries) UpsertOperation

func (q *Queries) UpsertOperation(ctx context.Context, arg UpsertOperationParams) error

func (*Queries) UpsertService

func (q *Queries) UpsertService(ctx context.Context, name string) error

-- name: GetDependencies :many SELECT

COUNT(*) AS call_count,
source_services.name as parent,
child_services.name as child,
'' as source

FROM spanrefs

INNER JOIN spans AS source_spans ON (source_spans.span_id = spanrefs.source_span_id)
INNER JOIN spans AS child_spans ON (child_spans.span_id = spanrefs.child_span_id)
INNER JOIN services AS source_services ON (source_spans.service_id = source_services.id)
INNER JOIN services AS child_services ON (child_spans.service_id = child_services.id)

GROUP BY source_services.name, child_services.name; -- name: FindTraceIDs :many SELECT DISTINCT spans.trace_id FROM spans

INNER JOIN operations ON (operations.id = spans.operation_id)
INNER JOIN services ON (services.id = spans.service_id)

WHERE

(services.name = sqlc.arg(service_name)::VARCHAR OR sqlc.arg(service_name_enable)::BOOLEAN = FALSE) AND
(operations.name = sqlc.arg(operation_name)::VARCHAR OR sqlc.arg(operation_name_enable)::BOOLEAN = FALSE) AND
(start_time >= sqlc.arg(start_time_minimum)::TIMESTAMPTZ OR sqlc.arg(start_time_minimum_enable)::BOOLEAN = FALSE) AND
(start_time < sqlc.arg(start_time_maximum)::TIMESTAMPTZ OR sqlc.arg(start_time_maximum_enable)::BOOLEAN = FALSE) AND
(duration > sqlc.arg(duration_minimum)::INTERVAL OR sqlc.arg(duration_minimum_enable)::BOOLEAN = FALSE) AND
(duration < sqlc.arg(duration_maximum)::INTERVAL OR sqlc.arg(duration_maximum_enable)::BOOLEAN = FALSE)

; LIMIT sqlc.arg(limit)::INT;

func (*Queries) WithTx

func (q *Queries) WithTx(tx pgx.Tx) *Queries

type Service

type Service struct {
	ID   int64
	Name string
}

type Span

type Span struct {
	HackID      int64
	SpanID      []byte
	TraceID     []byte
	OperationID int64
	Flags       int64
	StartTime   pgtype.Timestamp
	Duration    pgtype.Interval
	Tags        []byte
	ServiceID   int64
	ProcessID   string
	ProcessTags []byte
	Warnings    []string
	Logs        []byte
	Kind        Spankind
	Refs        []byte
}

type Spankind

type Spankind string
const (
	SpankindServer      Spankind = "server"
	SpankindClient      Spankind = "client"
	SpankindUnspecified Spankind = "unspecified"
	SpankindProducer    Spankind = "producer"
	SpankindConsumer    Spankind = "consumer"
	SpankindEphemeral   Spankind = "ephemeral"
	SpankindInternal    Spankind = "internal"
)

func (*Spankind) Scan

func (e *Spankind) Scan(src interface{}) error

type UpsertOperationParams

type UpsertOperationParams struct {
	Name      string
	ServiceID int64
	Kind      Spankind
}

Jump to

Keyboard shortcuts

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