chtracker

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package chtracker provides Clickhouse query tracker.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type QueryReport

type QueryReport struct {
	DurationNanos int64  `json:"duration_nanos,omitempty" yaml:"duration_nanos,omitempty"`
	Query         string `json:"query,omitempty" yaml:"query,omitempty"`
	ReadBytes     int64  `json:"read_bytes,omitempty" yaml:"read_bytes,omitempty"`
	ReadRows      int64  `json:"read_rows,omitempty" yaml:"read_rows,omitempty"`
	MemoryUsage   int64  `json:"memory_usage,omitempty" yaml:"memory_usage,omitempty"`

	ReceivedRows int64 `json:"recevied_rows,omitempty" yaml:"recevied_rows,omitempty"`
}

QueryReport is a Clickhouse query stats retrieved from trace.

type SetupOptions

type SetupOptions struct {
	// Trace enables tracing.
	Trace bool
	// TempoAddr sets URL to Tempo API to retrieve traces.
	TempoAddr string
}

SetupOptions defines options for Setup.

type TrackedQuery

type TrackedQuery[Q any] struct {
	TraceID  string
	Duration time.Duration
	Timeout  bool
	Meta     Q
}

TrackedQuery stores info about tracked query.

type Tracker

type Tracker[Q any] struct {
	// contains filtered or unexported fields
}

Tracker is a query tracker.

func Setup

func Setup[Q any](ctx context.Context, senderName string, opts SetupOptions) (*Tracker[Q], error)

Setup creates new Tracker.

func (*Tracker[Q]) Flush

func (t *Tracker[Q]) Flush(ctx context.Context) error

Flush writes buffered traces to storage.

func (*Tracker[Q]) HTTPClient

func (t *Tracker[Q]) HTTPClient() *http.Client

HTTPClient returns instrumented HTTP client to use.

func (*Tracker[Q]) Report

func (t *Tracker[Q]) Report(ctx context.Context, cb func(context.Context, TrackedQuery[Q], []QueryReport, error) error) error

Report iterates over tracked queries.

func (*Tracker[Q]) TracerProvider

func (t *Tracker[Q]) TracerProvider() trace.TracerProvider

TracerProvider returns tracer provider to use.

func (*Tracker[Q]) Track

func (t *Tracker[Q]) Track(ctx context.Context, meta Q, cb func(context.Context, Q) error) (rerr error)

Track creates a tracked span and calls given callback.

Jump to

Keyboard shortcuts

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