chstorage

package
v0.18.1 Latest Latest
Warning

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

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

Documentation

Overview

Package chstorage provides Clickhouse-based storage.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Attributes added in v0.5.0

type Attributes struct {
	Name  string
	Value proto.ColumnOf[otelstorage.Attrs]
}

func NewAttributes added in v0.5.0

func NewAttributes(name string, opts ...AttributesOption) *Attributes

NewAttributes constructs a new Attributes storage representation.

func (*Attributes) Append added in v0.5.0

func (a *Attributes) Append(kv otelstorage.Attrs)

Append adds a new map of attributes.

func (*Attributes) Columns added in v0.5.0

func (a *Attributes) Columns() Columns

Columns returns a slice of Columns for this attribute set.

func (*Attributes) DDL added in v0.16.0

func (a *Attributes) DDL(table *ddl.Table)

DDL applies the schema changes to the table.

func (*Attributes) Row added in v0.5.0

func (a *Attributes) Row(idx int) otelstorage.Attrs

Row returns a new map of attributes for a given row.

type AttributesOption added in v0.16.0

type AttributesOption func(*attributesOptions)

func WithLowCardinality added in v0.16.0

func WithLowCardinality(v bool) AttributesOption

type ClickhouseClient added in v0.7.0

type ClickhouseClient interface {
	Do(ctx context.Context, q ch.Query) error
	Ping(ctx context.Context) error
}

func Dial added in v0.5.0

func Dial(ctx context.Context, dsn string, opts DialOptions) (ClickhouseClient, error)

Dial creates new ClickhouseClient using given DSN.

func NewDialingClickhouseClient added in v0.7.0

func NewDialingClickhouseClient(options ch.Options) ClickhouseClient

type ClickhouseOptimizer added in v0.10.0

type ClickhouseOptimizer struct{}

ClickhouseOptimizer replaces LogQL engine execution nodes with optimzied Clickhouse queries.

func (*ClickhouseOptimizer) Name added in v0.10.0

func (o *ClickhouseOptimizer) Name() string

Name returns optimizer name.

func (*ClickhouseOptimizer) Optimize added in v0.10.0

Optimize implements [Optimizer].

type Column added in v0.5.0

type Column struct {
	Name string
	Data proto.Column
}

Column is a column with name and data that can be used in INSERT or SELECT query.

type Columns added in v0.5.0

type Columns []Column

Columns is a set of Columns.

func MergeColumns added in v0.5.0

func MergeColumns(sets ...Columns) Columns

MergeColumns merges multiple sets of columns into one.

func (Columns) All added in v0.5.0

func (c Columns) All() string

All returns comma-separated column names for using in SELECT query instead of `SELECT *`.

func (Columns) ChsqlResult added in v0.13.0

func (c Columns) ChsqlResult() []chsql.ResultColumn

ChsqlResult returns columns for using in SELECT query.

func (Columns) Input added in v0.5.0

func (c Columns) Input() proto.Input

Input returns columns for using in INSERT query.

func (Columns) Names added in v0.5.0

func (c Columns) Names() []string

Names returns a slice of column names.

func (Columns) Reset added in v0.5.0

func (c Columns) Reset()

Reset columns.

func (Columns) Result added in v0.5.0

func (c Columns) Result() proto.Results

Result returns columns for using in SELECT query.

type DialOptions added in v0.5.0

type DialOptions struct {
	// MeterProvider provides OpenTelemetry meter for pool.
	MeterProvider metric.MeterProvider
	// TracerProvider provides OpenTelemetry tracer for pool.
	TracerProvider trace.TracerProvider
	// Logger provides logger for pool.
	Logger *zap.Logger
}

DialOptions is Dial function options.

type InputNode added in v0.10.0

type InputNode struct {
	Sel LogsSelector
	// contains filtered or unexported fields
}

InputNode rebuilds LogQL pipeline in as Clickhouse query.

func (*InputNode) EvalPipeline added in v0.10.0

EvalPipeline implements logqlengine.PipelineNode.

func (*InputNode) Traverse added in v0.10.0

func (n *InputNode) Traverse(cb logqlengine.NodeVisitor) error

Traverse implements logqlengine.Node.

type Inserter

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

Inserter implements tracestorage.Inserter using Clickhouse.

func NewInserter

func NewInserter(c ClickhouseClient, opts InserterOptions) (*Inserter, error)

NewInserter creates new Inserter.

func (*Inserter) ConsumeMetrics added in v0.1.0

func (i *Inserter) ConsumeMetrics(ctx context.Context, metrics pmetric.Metrics) error

ConsumeMetrics inserts given metrics.

func (*Inserter) RecordWriter added in v0.15.0

func (i *Inserter) RecordWriter(ctx context.Context) (logstorage.RecordWriter, error)

RecordWriter returns a new logstorage.RecordWriter

func (*Inserter) SpanWriter added in v0.15.0

func (i *Inserter) SpanWriter(ctx context.Context) (tracestorage.SpanWriter, error)

SpanWriter returns a new tracestorage.SpanWriter

type InserterOptions added in v0.0.8

type InserterOptions struct {
	// Tables provides table paths to query.
	Tables Tables
	// MeterProvider provides OpenTelemetry meter for this querier.
	MeterProvider metric.MeterProvider
	// TracerProvider provides OpenTelemetry tracer for this querier.
	TracerProvider trace.TracerProvider
}

InserterOptions is Inserter's options.

type LogsQuery added in v0.10.0

type LogsQuery[E any] struct {
	Start, End time.Time
	Sel        LogsSelector
	Direction  logqlengine.Direction
	Limit      int

	Mapper func(logstorage.Record) (E, error)
}

LogsQuery defines a logs query.

func (*LogsQuery[E]) Execute added in v0.13.0

func (v *LogsQuery[E]) Execute(ctx context.Context, q *Querier) (_ iterators.Iterator[E], rerr error)

Execute executes the query using given querier.

type LogsSelector added in v0.14.0

type LogsSelector struct {
	Labels         []logql.LabelMatcher
	Line           []logql.LineFilter
	PipelineLabels []logql.LabelPredicate
}

LogsSelector defines common parameters for logs selection.

type Querier

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

Querier implements tracestorage.Querier using Clickhouse.

func NewQuerier

func NewQuerier(c ClickhouseClient, opts QuerierOptions) (*Querier, error)

NewQuerier creates new Querier.

func (*Querier) Capabilities added in v0.1.0

func (q *Querier) Capabilities() (caps logqlengine.QuerierCapabilities)

Capabilities implements logqlengine.Querier.

func (*Querier) ExemplarQuerier added in v0.2.0

func (q *Querier) ExemplarQuerier(ctx context.Context) (storage.ExemplarQuerier, error)

Querier returns a new Querier on the storage.

func (*Querier) LabelNames added in v0.1.0

func (q *Querier) LabelNames(ctx context.Context, opts logstorage.LabelsOptions) (result []string, rerr error)

LabelNames implements logstorage.Querier.

func (*Querier) LabelValues added in v0.1.0

func (q *Querier) LabelValues(ctx context.Context, labelName string, opts logstorage.LabelsOptions) (riter iterators.Iterator[logstorage.Label], rerr error)

LabelValues implements logstorage.Querier.

func (*Querier) Querier added in v0.1.0

func (q *Querier) Querier(mint, maxt int64) (storage.Querier, error)

Querier returns a new Querier on the storage.

func (*Querier) Query added in v0.10.0

Query creates new InputNode.

func (*Querier) SearchTags

SearchTags performs search by given tags.

func (*Querier) SelectSpansets added in v0.0.8

SelectSpansets get spansets from storage.

func (*Querier) Series added in v0.13.0

func (q *Querier) Series(ctx context.Context, opts logstorage.SeriesOptions) (result logstorage.Series, rerr error)

Series returns all available log series.

func (*Querier) TagNames

func (q *Querier) TagNames(ctx context.Context, opts tracestorage.TagNamesOptions) (r []tracestorage.TagName, rerr error)

TagNames returns all available tag names.

func (*Querier) TagValues

TagValues returns all available tag values for given tag.

func (*Querier) TraceByID

TraceByID returns spans of given trace.

type QuerierOptions added in v0.0.8

type QuerierOptions struct {
	// Tables provides table paths to query.
	Tables Tables
	// LabelLimit defines limit for label lookup in the main table.
	LabelLimit int
	// MeterProvider provides OpenTelemetry meter for this querier.
	MeterProvider metric.MeterProvider
	// TracerProvider provides OpenTelemetry tracer for this querier.
	TracerProvider trace.TracerProvider
}

QuerierOptions is Querier's options.

type SampleQuery added in v0.10.0

type SampleQuery struct {
	Start, End     time.Time
	Sel            LogsSelector
	Sampling       SamplingOp
	GroupingLabels []logql.Label
}

SampleQuery defines a sample query.

func (*SampleQuery) Execute added in v0.13.0

func (v *SampleQuery) Execute(ctx context.Context, q *Querier) (_ logqlengine.SampleIterator, rerr error)

Execute executes the query using given querier.

type SamplingNode added in v0.10.0

type SamplingNode struct {
	Sel            LogsSelector
	Sampling       SamplingOp
	GroupingLabels []logql.Label
	// contains filtered or unexported fields
}

SamplingNode is a logqlengine.SampleNode, which offloads sampling to Clickhouse

func (*SamplingNode) EvalSample added in v0.10.0

EvalSample implements logqlengine.SampleNode.

func (*SamplingNode) Traverse added in v0.10.0

func (n *SamplingNode) Traverse(cb logqlengine.NodeVisitor) error

Traverse implements logqlengine.Node.

type SamplingOp added in v0.10.0

type SamplingOp int

SamplingOp defines a sampler operation.

const (
	// CountSampling counts lines.
	CountSampling SamplingOp = iota + 1
	// BytesSampling counts line lengths in bytes.
	BytesSampling
)

func (SamplingOp) String added in v0.10.0

func (s SamplingOp) String() string

String implments fmt.Stringer.

type Tables

type Tables struct {
	Spans string
	Tags  string

	Points        string
	ExpHistograms string
	Exemplars     string
	Labels        string

	Logs     string
	LogAttrs string

	Migration string

	TTL     time.Duration
	Cluster string
}

Tables define table names.

func DefaultTables added in v0.1.0

func DefaultTables() Tables

DefaultTables returns default tables.

func (Tables) Create

func (t Tables) Create(ctx context.Context, c ClickhouseClient) error

Create creates tables.

func (*Tables) Each added in v0.1.0

func (t *Tables) Each(cb func(name *string) error) error

Each calls given callback for each table.

func (*Tables) Validate added in v0.1.0

func (t *Tables) Validate() error

Validate checks table names

Directories

Path Synopsis
Package chsql provides fluent Clickhouse SQL query builder.
Package chsql provides fluent Clickhouse SQL query builder.

Jump to

Keyboard shortcuts

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