logstorage

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: May 7, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package logstorage defines storage structure for logs storage.

Index

Constants

View Source
const (
	LabelTraceID  = "trace_id"
	LabelSpanID   = "span_id"
	LabelSeverity = "level"
	LabelBody     = "msg"

	LabelServiceName       = "service_name"        // resource.service.name
	LabelServiceNamespace  = "service_namespace"   // resource.service.namespace
	LabelServiceInstanceID = "service_instance_id" // resource.service.instance.id
)

Labels to use where prometheus compatible labels are required, e.g. loki.

Variables

This section is empty.

Functions

This section is empty.

Types

type Consumer

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

Consumer consumes given logs and inserts them using given Inserter.

func NewConsumer

func NewConsumer(i Inserter) *Consumer

NewConsumer creates new Consumer.

func (*Consumer) ConsumeLogs

func (c *Consumer) ConsumeLogs(ctx context.Context, logs plog.Logs) error

ConsumeLogs implements otelreceiver.Consumer.

type Inserter

type Inserter interface {
	// InsertRecords inserts given records.
	InsertRecords(ctx context.Context, records []Record) error
	// InsertLogLabels insert given set of labels to the storage.
	InsertLogLabels(ctx context.Context, labels map[Label]struct{}) error
}

Inserter is a log storage insert interface.

type Label

type Label struct {
	Name  string `json:"name"`
	Value string `json:"value"`
	Type  int32  `json:"type"`
}

Label is a data structure for log label.

type LabelsOptions

type LabelsOptions struct {
	// Start defines time range for search.
	//
	// Querier ignores parameter, if it is zero.
	Start otelstorage.Timestamp
	// End defines time range for search.
	//
	// Querier ignores parameter, if it is zero.
	End otelstorage.Timestamp
}

LabelsOptions defines options for Labels and LabelValues methods.

type Querier

type Querier interface {
	// LabelNames returns all available label names.
	LabelNames(ctx context.Context, opts LabelsOptions) ([]string, error)
	// LabelValues returns all available label values for given label.
	LabelValues(ctx context.Context, labelName string, opts LabelsOptions) (iterators.Iterator[Label], error)
}

Querier is a logs storage query interface.

type Record

type Record struct {
	Timestamp         otelstorage.Timestamp `json:"timestamp"`
	ObservedTimestamp otelstorage.Timestamp `json:"observed_timestamp"`
	TraceID           otelstorage.TraceID   `json:"trace_id"`
	SpanID            otelstorage.SpanID    `json:"span_id"`
	Flags             plog.LogRecordFlags   `json:"flags"`
	SeverityText      string                `json:"severity_text"`
	SeverityNumber    plog.SeverityNumber   `json:"severity_number"`
	Body              string                `json:"body"`
	Attrs             otelstorage.Attrs     `json:"attrs"`

	ResourceAttrs otelstorage.Attrs `json:"resource_attrs"`

	ScopeName    string            `json:"scope_name"`
	ScopeVersion string            `json:"scope_version"`
	ScopeAttrs   otelstorage.Attrs `json:"scope_attrs"`
}

Record is a log record.

func NewRecordFromOTEL

func NewRecordFromOTEL(
	res pcommon.Resource,
	scope pcommon.InstrumentationScope,
	record plog.LogRecord,
) Record

NewRecordFromOTEL creates new Record.

Jump to

Keyboard shortcuts

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