tracestorage

package
v0.12.2 Latest Latest
Warning

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

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

Documentation

Overview

Package tracestorage defines storage structure for trace storage.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertToTempoAttrs added in v0.0.8

func ConvertToTempoAttrs(to *tempoapi.Attributes, from otelstorage.Attrs)

ConvertToTempoAttrs converts otelstorage.Attrs to Tempo API attributes.

Types

type Consumer

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

Consumer consumes given traces and inserts them using given Inserter.

func NewConsumer

func NewConsumer(i Inserter) *Consumer

NewConsumer creates new Consumer.

func (*Consumer) ConsumeTraces

func (c *Consumer) ConsumeTraces(ctx context.Context, traces ptrace.Traces) error

ConsumeTraces implements otelreceiver.Consumer.

type Event

type Event struct {
	Timestamp otelstorage.Timestamp `json:"timestamp"`
	Name      string                `json:"name"`
	Attrs     otelstorage.Attrs     `json:"attrs"`
}

Event is a Span event.

type Inserter

type Inserter interface {
	// InsertSpans inserts given spans.
	//
	// FIXME(tdakkota): probably, it's better to return some kind of batch writer.
	InsertSpans(ctx context.Context, spans []Span) error
	// InsertTags insert given set of tags to the storage.
	//
	// FIXME(tdakkota): probably, storage should do tag extraction by itself.
	InsertTags(ctx context.Context, tags map[Tag]struct{}) error
}

Inserter is a trace storage insert interface.

type Link struct {
	TraceID    otelstorage.TraceID `json:"trace_id"`
	SpanID     otelstorage.SpanID  `json:"span_id"`
	TraceState string              `json:"trace_state"`
	Attrs      otelstorage.Attrs   `json:"attrs"`
}

Link is a Span link.

type Querier

type Querier interface {
	// SearchTags performs search by given tags.
	SearchTags(ctx context.Context, tags map[string]string, opts SearchTagsOptions) (iterators.Iterator[Span], error)

	// TagNames returns all available tag names.
	TagNames(ctx context.Context, opts TagNamesOptions) ([]TagName, error)
	// TagValues returns all available tag values for given tag.
	TagValues(ctx context.Context, attr traceql.Attribute, opts TagValuesOptions) (iterators.Iterator[Tag], error)

	// TraceByID returns spans of given trace.
	TraceByID(ctx context.Context, id otelstorage.TraceID, opts TraceByIDOptions) (iterators.Iterator[Span], error)
}

Querier is a trace storage query interface.

type SearchTagsOptions

type SearchTagsOptions struct {
	MinDuration time.Duration
	MaxDuration time.Duration

	// 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
}

SearchTagsOptions defines options for [Querier.SearchTags].

type Span

type Span struct {
	TraceID       otelstorage.TraceID   `json:"trace_id"`
	SpanID        otelstorage.SpanID    `json:"span_id"`
	TraceState    string                `json:"trace_state"`
	ParentSpanID  otelstorage.SpanID    `json:"parent_span_id"`
	Name          string                `json:"name"`
	Kind          int32                 `json:"kind"`
	Start         otelstorage.Timestamp `json:"start"`
	End           otelstorage.Timestamp `json:"end"`
	Attrs         otelstorage.Attrs     `json:"attrs"`
	StatusCode    int32                 `json:"status_code"`
	StatusMessage string                `json:"status_message"`

	BatchID       uuid.UUID         `json:"batch_id"`
	ResourceAttrs otelstorage.Attrs `json:"resource_attrs"`

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

	Events []Event `json:"events"`
	Links  []Link  `json:"links"`
}

Span is a data structure for span.

func NewSpanFromOTEL

func NewSpanFromOTEL(
	batchID uuid.UUID,
	res pcommon.Resource,
	scope pcommon.InstrumentationScope,
	span ptrace.Span,
) (s Span)

NewSpanFromOTEL creates new Span.

func (Span) AsTempoSpan

func (span Span) AsTempoSpan() (s tempoapi.TempoSpan)

AsTempoSpan converts span to TempoSpan.

func (Span) FillOTELSpan

func (span Span) FillOTELSpan(s ptrace.Span)

FillOTELSpan fills given OpenTelemetry span using span fields.

func (Span) FillTraceMetadata

func (span Span) FillTraceMetadata(m *tempoapi.TraceSearchMetadata)

FillTraceMetadata files TraceSearchMetadata fields using span.

The span should be a parent span.

func (Span) ServiceName added in v0.0.8

func (span Span) ServiceName() (string, bool)

ServiceName gets service name from attributes.

type Tag

type Tag struct {
	Name  string                 `json:"name"`
	Value string                 `json:"value"`
	Type  traceql.StaticType     `json:"type"`
	Scope traceql.AttributeScope `json:"scope"`
}

Tag is a data structure for tag.

type TagName added in v0.12.0

type TagName struct {
	Scope traceql.AttributeScope
	Name  string
}

TagNames is a set of tags by scope.

type TagNamesOptions added in v0.12.0

type TagNamesOptions struct {
	// Scope defines attribute scope to lookup.
	//
	// Querier should return attributes from all scopes, if it is zero.
	Scope traceql.AttributeScope
	// 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
}

TagNamesOptions defines options for [Querier.TagNames].

type TagValuesOptions added in v0.12.0

type TagValuesOptions struct {
	// Query is a set of spanset matchers to only return tags seen
	// on matching spansets.
	//
	// Querier ignores parameter, if it is zero.
	Query traceql.Autocomplete
	// 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
}

TagValuesOptions defines options for [Querier.TagValues].

type TraceByIDOptions

type TraceByIDOptions 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
}

TraceByIDOptions defines options for [Querier.TraceByID] method.

Jump to

Keyboard shortcuts

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