clientdb

package
v0.16.3 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2025 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const CollectGarbageAfter = time.Hour

CollectGarbageAfter is the time after which a database is considered garbage and can be deleted.

Variables

View Source
var Schema string

Functions

func LogsToPB added in v0.13.1

func LogsToPB(dbLog []Log) []*otlplogsv1.ResourceLogs

func MarshalProtoJSONs added in v0.13.1

func MarshalProtoJSONs[T proto.Message](protos []T) ([]byte, error)

func MetricsToPB added in v0.13.6

func MetricsToPB(dbMetrics []Metric) []*otlpmetricsv1.ResourceMetrics

func UnmarshalProtoJSONs added in v0.13.1

func UnmarshalProtoJSONs[T proto.Message](pb []byte, base T, out *[]T) error

Types

type DBTX

type DBTX interface {
	ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
	PrepareContext(context.Context, string) (*sql.Stmt, error)
	QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
	QueryRowContext(context.Context, string, ...interface{}) *sql.Row
}

type DBs

type DBs struct {
	Root string
}

func NewDBs

func NewDBs(root string) *DBs

func (*DBs) Create

func (dbs *DBs) Create(clientID string) (*sql.DB, error)

Create creates a new database for the given clientID and runs the schema migration. This operation must be idempotent.

func (*DBs) GC

func (dbs *DBs) GC(keep map[string]bool) error

GC removes databases that are older than CollectGarbageAfter based on mtime.

func (*DBs) Open

func (dbs *DBs) Open(clientID string) (*sql.DB, error)

Open opens the database for the given client, for reading.

type InsertLogParams

type InsertLogParams struct {
	TraceID              sql.NullString
	SpanID               sql.NullString
	Timestamp            int64
	SeverityNumber       int64
	SeverityText         string
	Body                 []byte
	Attributes           []byte
	InstrumentationScope []byte
	Resource             []byte
	ResourceSchemaUrl    string
}

type InsertSpanParams

type InsertSpanParams struct {
	TraceID                string
	SpanID                 string
	TraceState             string
	ParentSpanID           sql.NullString
	Flags                  int64
	Name                   string
	Kind                   string
	StartTime              int64
	EndTime                sql.NullInt64
	Attributes             []byte
	DroppedAttributesCount int64
	Events                 []byte
	DroppedEventsCount     int64
	Links                  []byte
	DroppedLinksCount      int64
	StatusCode             int64
	StatusMessage          string
	InstrumentationScope   []byte
	Resource               []byte
	ResourceSchemaUrl      string
}

type Log

type Log struct {
	ID                   int64
	TraceID              sql.NullString
	SpanID               sql.NullString
	Timestamp            int64
	SeverityNumber       int64
	SeverityText         string
	Body                 []byte
	Attributes           []byte
	InstrumentationScope []byte
	Resource             []byte
	ResourceSchemaUrl    string
}

type Metric added in v0.13.6

type Metric struct {
	ID   int64
	Data []byte
}

type Queries

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

func New

func New(db DBTX) *Queries

func (*Queries) InsertLog

func (q *Queries) InsertLog(ctx context.Context, arg InsertLogParams) (int64, error)

func (*Queries) InsertMetric added in v0.13.6

func (q *Queries) InsertMetric(ctx context.Context, data []byte) (int64, error)

func (*Queries) InsertSpan

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

func (*Queries) SelectLogsSince

func (q *Queries) SelectLogsSince(ctx context.Context, arg SelectLogsSinceParams) ([]Log, error)

func (*Queries) SelectMetricsSince added in v0.13.6

func (q *Queries) SelectMetricsSince(ctx context.Context, arg SelectMetricsSinceParams) ([]Metric, error)

func (*Queries) SelectSpansSince

func (q *Queries) SelectSpansSince(ctx context.Context, arg SelectSpansSinceParams) ([]Span, error)

func (*Queries) WithTx

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

type SelectLogsSinceParams

type SelectLogsSinceParams struct {
	ID    int64
	Limit int64
}

type SelectMetricsSinceParams added in v0.13.6

type SelectMetricsSinceParams struct {
	ID    int64
	Limit int64
}

type SelectSpansSinceParams

type SelectSpansSinceParams struct {
	ID    int64
	Limit int64
}

type Span

type Span struct {
	ID                     int64
	TraceID                string
	SpanID                 string
	TraceState             string
	ParentSpanID           sql.NullString
	Flags                  int64
	Name                   string
	Kind                   string
	StartTime              int64
	EndTime                sql.NullInt64
	Attributes             []byte
	DroppedAttributesCount int64
	Events                 []byte
	DroppedEventsCount     int64
	Links                  []byte
	DroppedLinksCount      int64
	StatusCode             int64
	StatusMessage          string
	InstrumentationScope   []byte
	Resource               []byte
	ResourceSchemaUrl      string
}

func (*Span) ReadOnly

func (span *Span) ReadOnly() sdktrace.ReadOnlySpan

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳