storage

package
v0.0.0-...-9649366 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2019 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Overview

Package storage is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FetchOptionsToAggregateOptions

func FetchOptionsToAggregateOptions(
	fetchOptions *FetchOptions,
	tagQuery *CompleteTagsQuery,
) index.AggregationOptions

FetchOptionsToAggregateOptions converts a set of coordinator options as well as complete tags query to an M3 aggregate query option.

func FetchOptionsToM3Options

func FetchOptionsToM3Options(fetchOptions *FetchOptions, fetchQuery *FetchQuery) index.QueryOptions

FetchOptionsToM3Options converts a set of coordinator options to M3 options.

func FetchQueryToM3Query

func FetchQueryToM3Query(
	fetchQuery *FetchQuery,
) (index.Query, error)

FetchQueryToM3Query converts an m3coordinator fetch query to an M3 query.

func FetchResultToBlockResult

func FetchResultToBlockResult(
	result *FetchResult,
	query *FetchQuery,
	lookbackDuration time.Duration,
	enforcer cost.ChainedEnforcer,
) (block.Result, error)

FetchResultToBlockResult converts a fetch result into coordinator blocks

func FetchResultToPromResult

func FetchResultToPromResult(
	result *FetchResult,
	keepEmpty bool,
) *prompb.QueryResult

FetchResultToPromResult converts fetch results from M3 to Prometheus result.

func FromIdentTagIteratorToTags

func FromIdentTagIteratorToTags(
	identTags ident.TagIterator,
	tagOptions models.TagOptions,
) (models.Tags, error)

FromIdentTagIteratorToTags converts ident tags to coordinator tags.

func FromM3IdentToMetric

func FromM3IdentToMetric(
	identID ident.ID,
	iterTags ident.TagIterator,
	tagOptions models.TagOptions,
) (models.Metric, error)

FromM3IdentToMetric converts an M3 ident metric to a coordinator metric.

func IsWarning

func IsWarning(store Storage, err error) (bool, error)

IsWarning determines if the given error coming from the storage is a warning, and returns it with appropriate wrapping.

func NewMultiBlockWrapper

func NewMultiBlockWrapper(
	unconsolidatedBlock block.UnconsolidatedBlock,
) block.Block

NewMultiBlockWrapper returns a block wrapper over an unconsolidated block.

func NewMultiSeriesBlock

func NewMultiSeriesBlock(
	fetchResult *FetchResult,
	query *FetchQuery,
	lookbackDuration time.Duration,
) (block.UnconsolidatedBlock, error)

NewMultiSeriesBlock returns a new unconsolidated block from a fetch result.

func NewUnconsolidatedStep

func NewUnconsolidatedStep(
	time time.Time,
	values []ts.Datapoints,
) block.UnconsolidatedStep

NewUnconsolidatedStep returns an unconsolidated step with given values.

func PromLabelsToM3Tags

func PromLabelsToM3Tags(
	labels []prompb.Label,
	tagOptions models.TagOptions,
) models.Tags

PromLabelsToM3Tags converts Prometheus labels to M3 tags

func PromMatcherToM3

func PromMatcherToM3(matcher *prompb.LabelMatcher) (models.Matcher, error)

PromMatcherToM3 converts a prometheus label matcher to m3 matcher

func PromMatchersToM3

func PromMatchersToM3(matchers []*prompb.LabelMatcher) (models.Matchers, error)

PromMatchersToM3 converts prometheus label matchers to m3 matchers

func PromSamplesToM3Datapoints

func PromSamplesToM3Datapoints(samples []prompb.Sample) ts.Datapoints

PromSamplesToM3Datapoints converts Prometheus samples to M3 datapoints

func PromTimestampToTime

func PromTimestampToTime(timestampMS int64) time.Time

PromTimestampToTime converts a prometheus timestamp to time.Time.

func PromTypeToM3

func PromTypeToM3(labelType prompb.LabelMatcher_Type) (models.MatchType, error)

PromTypeToM3 converts a prometheus label type to m3 matcher type

func SeriesToPromSamples

func SeriesToPromSamples(series *ts.Series) []prompb.Sample

SeriesToPromSamples series datapoints to prometheus samples.SeriesToPromSamples.

func SeriesToPromTS

func SeriesToPromTS(series *ts.Series) prompb.TimeSeries

SeriesToPromTS converts a series to prometheus timeseries.

func TagsToIdentTagIterator

func TagsToIdentTagIterator(tags models.Tags) ident.TagIterator

TagsToIdentTagIterator converts coordinator tags to ident tags.

func TagsToPromLabels

func TagsToPromLabels(tags models.Tags) []prompb.Label

TagsToPromLabels converts tags to prometheus labels.

func TimeToPromTimestamp

func TimeToPromTimestamp(timestamp time.Time) int64

TimeToPromTimestamp converts a time.Time to prometheus timestamp.

func ValidateMetricsType

func ValidateMetricsType(v MetricsType) error

ValidateMetricsType validates a stored metrics type.

Types

type Appender

type Appender interface {
	// Write writes a batched set of datapoints to storage based on the provided
	// query.
	Write(ctx context.Context, query *WriteQuery) error
}

Appender provides batched appends against a storage.

type Attributes

type Attributes struct {
	// MetricsType indicates the type of namespace this metric originated from.
	MetricsType MetricsType
	// Retention indicates the retention of the namespace this metric originated
	// from.
	Retention time.Duration
	// Resolution indicates the retention of the namespace this metric originated
	// from.
	Resolution time.Duration
}

Attributes is a set of stored metrics attributes.

type CompleteTagsQuery

type CompleteTagsQuery struct {
	// CompleteNameOnly indicates if the query should return only tag names, or
	// tag names and values.
	CompleteNameOnly bool
	// FilterNameTags is a list of tags to filter results by. If this is empty, no
	// filtering is applied.
	FilterNameTags [][]byte
	// TagMatchers is the search criteria for the query.
	TagMatchers models.Matchers
	// Start is the inclusive start for the query.
	Start time.Time
	// End is the exclusive end for the query.
	End time.Time
}

CompleteTagsQuery represents a query that returns an autocompleted set of tags.

func (*CompleteTagsQuery) String

func (q *CompleteTagsQuery) String() string

type CompleteTagsResult

type CompleteTagsResult struct {
	// CompleteNameOnly indicates if the tags in this result are expected to have
	// both names and values, or only names.
	CompleteNameOnly bool
	// CompletedTag is a list of completed tags.
	CompletedTags []CompletedTag
	// Metadata describes any metadata for the operation.
	Metadata block.ResultMetadata
}

CompleteTagsResult represents a set of autocompleted tag names and values

type CompleteTagsResultBuilder

type CompleteTagsResultBuilder interface {
	// Add appends an incoming CompleteTagsResult.
	Add(*CompleteTagsResult) error
	// Build builds a completed tag result.
	Build() CompleteTagsResult
}

CompleteTagsResultBuilder is a builder that accumulates and deduplicates incoming CompleteTagsResult values.

func NewCompleteTagsResultBuilder

func NewCompleteTagsResultBuilder(
	nameOnly bool,
) CompleteTagsResultBuilder

NewCompleteTagsResultBuilder creates a new complete tags result builder.

type CompletedTag

type CompletedTag struct {
	// Name the name of the tag.
	Name []byte
	// Values is a set of possible values for the tag.
	// NB: if the parent CompleteTagsResult is set to CompleteNameOnly, this is
	// expected to be empty.
	Values [][]byte
}

CompletedTag represents a tag retrieved by a complete tags query.

type Datapoint

type Datapoint struct {
	ts.Datapoint

	Annotation []byte
}

Datapoint is a datapoint containing an annotation.

type Datapoints

type Datapoints []Datapoint

Datapoints is a list of datapoints.

func PromSamplesToM3DatapointsAnnotated

func PromSamplesToM3DatapointsAnnotated(samples []prompb.Sample) Datapoints

PromSamplesToM3DatapointsAnnotated converts Prometheus samples to M3 datapoints

type ErrorBehavior

type ErrorBehavior uint8

ErrorBehavior describes what this storage type should do on error. This is used for determining how to proceed when encountering an error in a fanout storage situation.

const (
	// BehaviorFail is for storages that should fail the entire query when queries
	// against this storage fail.
	BehaviorFail ErrorBehavior = iota
	// BehaviorWarn is for storages that should only warn of incomplete results on
	// failure.
	BehaviorWarn
	// BehaviorContainer is for storages that contain substorages. It is necessary
	// to look at the returned error to determine if it's a failing error or
	// a warning error.
	BehaviorContainer
)

func ParseErrorBehavior

func ParseErrorBehavior(str string) (ErrorBehavior, error)

ParseErrorBehavior parses an error behavior.

func (ErrorBehavior) String

func (e ErrorBehavior) String() string

func (*ErrorBehavior) UnmarshalYAML

func (e *ErrorBehavior) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML unmarshals an error behavior.

type FanoutOption

type FanoutOption uint

FanoutOption describes the fanout option.

const (
	// FanoutDefault defaults to the fanout option.
	FanoutDefault FanoutOption = iota
	// FanoutForceDisable forces disabling fanout.
	FanoutForceDisable
	// FanoutForceEnable forces enabling fanout.
	FanoutForceEnable
)

type FanoutOptions

type FanoutOptions struct {
	// FanoutUnaggregated describes the fanout options for
	// unaggregated namespaces.
	FanoutUnaggregated FanoutOption
	// FanoutAggregated describes the fanout options for
	// aggregated namespaces.
	FanoutAggregated FanoutOption
	// FanoutAggregatedOptimized describes the fanout options for the
	// aggregated namespace optimization.
	FanoutAggregatedOptimized FanoutOption
}

FanoutOptions describes which namespaces should be fanned out to for the query.

type FetchOptions

type FetchOptions struct {
	// Remote is set when this fetch is originated by a remote grpc call.
	Remote bool
	// Limit is the maximum number of series to return.
	Limit int
	// BlockType is the block type that the fetch function returns.
	BlockType models.FetchedBlockType
	// FanoutOptions are the options for the fetch namespace fanout.
	FanoutOptions *FanoutOptions
	// RestrictFetchOptions restricts the fetch to a specific set of
	// conditions.
	RestrictFetchOptions *RestrictFetchOptions
	// Step is the configured step size.
	Step time.Duration
	// LookbackDuration if set overrides the default lookback duration.
	LookbackDuration *time.Duration
	// Enforcer is used to enforce resource limits on the number of datapoints
	// used by a given query. Limits are imposed at time of decompression.
	Enforcer cost.ChainedEnforcer
	// Scope is used to report metrics about the fetch.
	Scope tally.Scope
	// IncludeResolution if set, appends resolution information to fetch results.
	// Currently only used for graphite queries.
	IncludeResolution bool
	// IncludeExemplars if set, appends exemplar information to fetch results.
	IncludeExemplars bool
}

FetchOptions represents the options for fetch query.

func NewFetchOptions

func NewFetchOptions() *FetchOptions

NewFetchOptions creates a new fetch options.

func (*FetchOptions) Clone

func (o *FetchOptions) Clone() *FetchOptions

Clone will clone and return the fetch options.

func (*FetchOptions) LookbackDurationOrDefault

func (o *FetchOptions) LookbackDurationOrDefault(
	defaultValue time.Duration,
) time.Duration

LookbackDurationOrDefault returns either the default lookback duration or overridden lookback duration if set.

func (*FetchOptions) QueryFetchOptions

func (o *FetchOptions) QueryFetchOptions(
	queryCtx *models.QueryContext,
	blockType models.FetchedBlockType,
) (*FetchOptions, error)

QueryFetchOptions returns fetch options for a given query.

type FetchQuery

type FetchQuery struct {
	Raw         string
	TagMatchers models.Matchers `json:"matchers"`
	Start       time.Time       `json:"start"`
	End         time.Time       `json:"end"`
	Interval    time.Duration   `json:"interval"`
}

FetchQuery represents the input query which is fetched from M3DB.

func PromReadQueryToM3

func PromReadQueryToM3(query *prompb.Query) (*FetchQuery, error)

PromReadQueryToM3 converts a prometheus read query to m3 read query

func (*FetchQuery) String

func (q *FetchQuery) String() string

type FetchResult

type FetchResult struct {
	// SeriesList is the list of decompressed and computed series after fetch
	// query execution.
	SeriesList ts.SeriesList
	// Metadata describes any metadata for the operation.
	Metadata block.ResultMetadata
}

FetchResult provides a decompressed fetch result and meta information.

func SeriesIteratorsToFetchResult

func SeriesIteratorsToFetchResult(
	seriesIterators encoding.SeriesIterators,
	readWorkerPool xsync.PooledWorkerPool,
	cleanupSeriesIters bool,
	metadata block.ResultMetadata,
	enforcer cost.ChainedEnforcer,
	tagOptions models.TagOptions,
	fetchOptions *FetchOptions,
) (*FetchResult, error)

SeriesIteratorsToFetchResult converts SeriesIterators into a fetch result

type MetricsType

type MetricsType uint

MetricsType is a type of stored metrics.

const (
	// UnknownMetricsType is the unknown metrics type and is invalid.
	UnknownMetricsType MetricsType = iota
	// UnaggregatedMetricsType is an unaggregated metrics type.
	UnaggregatedMetricsType
	// AggregatedMetricsType is an aggregated metrics type.
	AggregatedMetricsType

	// DefaultMetricsType is the default metrics type value.
	DefaultMetricsType = UnaggregatedMetricsType
)

func ParseMetricsType

func ParseMetricsType(str string) (MetricsType, error)

ParseMetricsType parses a metric type.

func (MetricsType) String

func (t MetricsType) String() string

func (*MetricsType) UnmarshalYAML

func (t *MetricsType) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML unmarshals a stored merics type.

type MockStorage

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

MockStorage is a mock of Storage interface

func NewMockStorage

func NewMockStorage(ctrl *gomock.Controller) *MockStorage

NewMockStorage creates a new mock instance

func (*MockStorage) Close

func (m *MockStorage) Close() error

Close mocks base method

func (*MockStorage) CompleteTags

func (m *MockStorage) CompleteTags(arg0 context.Context, arg1 *CompleteTagsQuery, arg2 *FetchOptions) (*CompleteTagsResult, error)

CompleteTags mocks base method

func (*MockStorage) EXPECT

func (m *MockStorage) EXPECT() *MockStorageMockRecorder

EXPECT returns an object that allows the caller to indicate expected use

func (*MockStorage) ErrorBehavior

func (m *MockStorage) ErrorBehavior() ErrorBehavior

ErrorBehavior mocks base method

func (*MockStorage) Fetch

func (m *MockStorage) Fetch(arg0 context.Context, arg1 *FetchQuery, arg2 *FetchOptions) (*FetchResult, error)

Fetch mocks base method

func (*MockStorage) FetchBlocks

func (m *MockStorage) FetchBlocks(arg0 context.Context, arg1 *FetchQuery, arg2 *FetchOptions) (block.Result, error)

FetchBlocks mocks base method

func (*MockStorage) Name

func (m *MockStorage) Name() string

Name mocks base method

func (*MockStorage) SearchSeries

func (m *MockStorage) SearchSeries(arg0 context.Context, arg1 *FetchQuery, arg2 *FetchOptions) (*SearchResults, error)

SearchSeries mocks base method

func (*MockStorage) Type

func (m *MockStorage) Type() Type

Type mocks base method

func (*MockStorage) Write

func (m *MockStorage) Write(arg0 context.Context, arg1 *WriteQuery) error

Write mocks base method

type MockStorageMockRecorder

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

MockStorageMockRecorder is the mock recorder for MockStorage

func (*MockStorageMockRecorder) Close

func (mr *MockStorageMockRecorder) Close() *gomock.Call

Close indicates an expected call of Close

func (*MockStorageMockRecorder) CompleteTags

func (mr *MockStorageMockRecorder) CompleteTags(arg0, arg1, arg2 interface{}) *gomock.Call

CompleteTags indicates an expected call of CompleteTags

func (*MockStorageMockRecorder) ErrorBehavior

func (mr *MockStorageMockRecorder) ErrorBehavior() *gomock.Call

ErrorBehavior indicates an expected call of ErrorBehavior

func (*MockStorageMockRecorder) Fetch

func (mr *MockStorageMockRecorder) Fetch(arg0, arg1, arg2 interface{}) *gomock.Call

Fetch indicates an expected call of Fetch

func (*MockStorageMockRecorder) FetchBlocks

func (mr *MockStorageMockRecorder) FetchBlocks(arg0, arg1, arg2 interface{}) *gomock.Call

FetchBlocks indicates an expected call of FetchBlocks

func (*MockStorageMockRecorder) Name

func (mr *MockStorageMockRecorder) Name() *gomock.Call

Name indicates an expected call of Name

func (*MockStorageMockRecorder) SearchSeries

func (mr *MockStorageMockRecorder) SearchSeries(arg0, arg1, arg2 interface{}) *gomock.Call

SearchSeries indicates an expected call of SearchSeries

func (*MockStorageMockRecorder) Type

func (mr *MockStorageMockRecorder) Type() *gomock.Call

Type indicates an expected call of Type

func (*MockStorageMockRecorder) Write

func (mr *MockStorageMockRecorder) Write(arg0, arg1 interface{}) *gomock.Call

Write indicates an expected call of Write

type Querier

type Querier interface {
	// Fetch fetches decompressed timeseries data based on a query.
	// TODO: (arnikola) this is largely deprecated in favor of FetchBlocks;
	// should be removed.
	Fetch(
		ctx context.Context,
		query *FetchQuery,
		options *FetchOptions,
	) (*FetchResult, error)

	// FetchBlocks fetches timeseries as blocks based on a query.
	FetchBlocks(
		ctx context.Context,
		query *FetchQuery,
		options *FetchOptions,
	) (block.Result, error)

	// SearchSeries returns series IDs matching the current query.
	SearchSeries(
		ctx context.Context,
		query *FetchQuery,
		options *FetchOptions,
	) (*SearchResults, error)

	// CompleteTags returns autocompleted tag results.
	CompleteTags(
		ctx context.Context,
		query *CompleteTagsQuery,
		options *FetchOptions,
	) (*CompleteTagsResult, error)
}

Querier handles queries against a storage.

type Query

type Query interface {
	fmt.Stringer
	// contains filtered or unexported methods
}

Query is an interface for a M3DB query.

type RestrictFetchOptions

type RestrictFetchOptions struct {
	// MetricsType restricts the type of metrics being returned.
	MetricsType MetricsType
	// StoragePolicy is required if metrics type is not unaggregated
	// to specify which storage policy metrics should be returned from.
	StoragePolicy policy.StoragePolicy
}

RestrictFetchOptions restricts the fetch to a specific set of conditions.

func NewRestrictFetchOptionsFromProto

func NewRestrictFetchOptionsFromProto(
	p *rpcpb.RestrictFetchOptions,
) (RestrictFetchOptions, error)

NewRestrictFetchOptionsFromProto returns a restrict fetch options from protobuf message. TODO: (arnikola) extract these out of types.go

func (RestrictFetchOptions) Proto

Proto returns the protobuf message that corresponds to RestrictFetchOptions.

func (RestrictFetchOptions) Validate

func (o RestrictFetchOptions) Validate() error

Validate will validate the restrict fetch options.

type SearchResults

type SearchResults struct {
	// Metrics is the list of search results.
	Metrics models.Metrics
	// Metadata describes any metadata for the Fetch operation.
	Metadata block.ResultMetadata
}

SearchResults is the result from a search.

type SeriesMatchQuery

type SeriesMatchQuery struct {
	// TagMatchers is the search criteria for the query.
	TagMatchers []models.Matchers
	// Start is the inclusive start for the query.
	Start time.Time
	// End is the exclusive end for the query.
	End time.Time
}

SeriesMatchQuery represents a query that returns a set of series that match the query.

type Storage

type Storage interface {
	Querier
	Appender
	// Type identifies the type of the underlying storage.
	Type() Type
	// Close is used to close the underlying storage and free up resources.
	Close() error
	// ErrorBehavior dictates what fanout storage should do when this storage
	// encounters an error.
	ErrorBehavior() ErrorBehavior
	// Name gives the plaintext name for this storage, used for logging purposes.
	Name() string
}

Storage provides an interface for reading and writing to the tsdb.

type Type

type Type int

Type describes the type of storage.

const (
	// TypeLocalDC is for storages that reside in the local datacenter.
	TypeLocalDC Type = iota
	// TypeRemoteDC is for storages that reside in a remote datacenter.
	TypeRemoteDC
	// TypeMultiDC is for storages that will aggregate multiple datacenters.
	TypeMultiDC
	// TypeDebug is for storages that are used for debugging purposes.
	TypeDebug
)

type WriteQuery

type WriteQuery struct {
	Tags       models.Tags
	Datapoints ts.Datapoints
	Unit       xtime.Unit
	Annotation []byte
	Attributes Attributes
}

WriteQuery represents the input timeseries that is written to the database. TODO: rename WriteQuery to WriteRequest or something similar.

func PromWriteTSToM3

func PromWriteTSToM3(
	timeseries *prompb.TimeSeries,
	opts models.TagOptions,
) *WriteQuery

PromWriteTSToM3 converts a prometheus write query to an M3 one

func (*WriteQuery) String

func (q *WriteQuery) String() string

Directories

Path Synopsis
Package m3 is a generated GoMock package.
Package m3 is a generated GoMock package.

Jump to

Keyboard shortcuts

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