cortexpb

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2021 License: Apache-2.0 Imports: 22 Imported by: 13

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidLengthCortex = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowCortex   = fmt.Errorf("proto: integer overflow")
)
View Source
var IsTesting = false

IsTesting is only set from tests to get special behaviour to verify that custom sample encode and decode is used, both when using jsonitor or standard json package. It is public, so that test in client package can verify that it works for deprecated "client.Sample" type too.

View Source
var MetricMetadata_MetricType_name = map[int32]string{
	0: "UNKNOWN",
	1: "COUNTER",
	2: "GAUGE",
	3: "HISTOGRAM",
	4: "GAUGEHISTOGRAM",
	5: "SUMMARY",
	6: "INFO",
	7: "STATESET",
}
View Source
var MetricMetadata_MetricType_value = map[string]int32{
	"UNKNOWN":        0,
	"COUNTER":        1,
	"GAUGE":          2,
	"HISTOGRAM":      3,
	"GAUGEHISTOGRAM": 4,
	"SUMMARY":        5,
	"INFO":           6,
	"STATESET":       7,
}
View Source
var WriteRequest_SourceEnum_name = map[int32]string{
	0: "API",
	1: "RULE",
}
View Source
var WriteRequest_SourceEnum_value = map[string]int32{
	"API":  0,
	"RULE": 1,
}

Functions

func CopyLabels

func CopyLabels(input []labels.Label) labels.Labels

Efficiently copies labels input slice. To be used in cases where input slice can be reused, but long-term copy is needed.

func FromLabelAdaptersToLabels

func FromLabelAdaptersToLabels(ls []LabelAdapter) labels.Labels

FromLabelAdaptersToLabels casts []LabelAdapter to labels.Labels. It uses unsafe, but as LabelAdapter == labels.Label this should be safe. This allows us to use labels.Labels directly in protos.

Note: while resulting labels.Labels is supposedly sorted, this function doesn't enforce that. If input is not sorted, output will be wrong.

func FromLabelAdaptersToLabelsWithCopy

func FromLabelAdaptersToLabelsWithCopy(input []LabelAdapter) labels.Labels

FromLabelAdaptersToLabelsWithCopy converts []LabelAdapter to labels.Labels. Do NOT use unsafe to convert between data types because this function may get in input labels whose data structure is reused.

func FromLabelAdaptersToMetric

func FromLabelAdaptersToMetric(ls []LabelAdapter) model.Metric

FromLabelAdaptersToMetric converts []LabelAdapter to a model.Metric. Don't do this on any performance sensitive paths.

func MetricMetadataMetricTypeToMetricType

func MetricMetadataMetricTypeToMetricType(mt MetricMetadata_MetricType) textparse.MetricType

MetricMetadataMetricTypeToMetricType converts a metric type from our internal client to a Prometheus one.

func ReuseSlice

func ReuseSlice(ts []PreallocTimeseries)

ReuseSlice puts the slice back into a sync.Pool for reuse.

func ReuseTimeseries

func ReuseTimeseries(ts *TimeSeries)

ReuseTimeseries puts the timeseries back into a sync.Pool for reuse.

func SampleJsoniterDecode

func SampleJsoniterDecode(ptr unsafe.Pointer, iter *jsoniter.Iterator)

func SampleJsoniterEncode

func SampleJsoniterEncode(ptr unsafe.Pointer, stream *jsoniter.Stream)

Types

type LabelAdapter

type LabelAdapter labels.Label

LabelAdapter is a labels.Label that can be marshalled to/from protos.

func FromLabelsToLabelAdapters

func FromLabelsToLabelAdapters(ls labels.Labels) []LabelAdapter

FromLabelsToLabelAdapters casts labels.Labels to []LabelAdapter. It uses unsafe, but as LabelAdapter == labels.Label this should be safe. This allows us to use labels.Labels directly in protos.

func FromMetricsToLabelAdapters

func FromMetricsToLabelAdapters(metric model.Metric) []LabelAdapter

FromMetricsToLabelAdapters converts model.Metric to []LabelAdapter. Don't do this on any performance sensitive paths. The result is sorted.

func (*LabelAdapter) Compare

func (bs *LabelAdapter) Compare(other LabelAdapter) int

Compare implements proto.Comparer.

func (*LabelAdapter) Equal

func (bs *LabelAdapter) Equal(other LabelAdapter) bool

Equal implements proto.Equaler.

func (*LabelAdapter) Marshal

func (bs *LabelAdapter) Marshal() ([]byte, error)

Marshal implements proto.Marshaller.

func (*LabelAdapter) MarshalTo

func (bs *LabelAdapter) MarshalTo(dAtA []byte) (int, error)

func (*LabelAdapter) MarshalToSizedBuffer

func (bs *LabelAdapter) MarshalToSizedBuffer(buf []byte) (n int, err error)

MarshalTo implements proto.Marshaller.

func (*LabelAdapter) Size

func (bs *LabelAdapter) Size() (n int)

Size implements proto.Sizer.

func (*LabelAdapter) Unmarshal

func (bs *LabelAdapter) Unmarshal(dAtA []byte) error

Unmarshal a LabelAdapter, implements proto.Unmarshaller. NB this is a copy of the autogenerated code to unmarshal a LabelPair, with the byte copying replaced with a yoloString.

type LabelPair

type LabelPair struct {
	Name  []byte `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"`
}

func (*LabelPair) Descriptor

func (*LabelPair) Descriptor() ([]byte, []int)

func (*LabelPair) Equal

func (this *LabelPair) Equal(that interface{}) bool

func (*LabelPair) GetName

func (m *LabelPair) GetName() []byte

func (*LabelPair) GetValue

func (m *LabelPair) GetValue() []byte

func (*LabelPair) GoString

func (this *LabelPair) GoString() string

func (*LabelPair) Marshal

func (m *LabelPair) Marshal() (dAtA []byte, err error)

func (*LabelPair) MarshalTo

func (m *LabelPair) MarshalTo(dAtA []byte) (int, error)

func (*LabelPair) MarshalToSizedBuffer

func (m *LabelPair) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*LabelPair) ProtoMessage

func (*LabelPair) ProtoMessage()

func (*LabelPair) Reset

func (m *LabelPair) Reset()

func (*LabelPair) Size

func (m *LabelPair) Size() (n int)

func (*LabelPair) String

func (this *LabelPair) String() string

func (*LabelPair) Unmarshal

func (m *LabelPair) Unmarshal(dAtA []byte) error

func (*LabelPair) XXX_DiscardUnknown

func (m *LabelPair) XXX_DiscardUnknown()

func (*LabelPair) XXX_Marshal

func (m *LabelPair) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*LabelPair) XXX_Merge

func (m *LabelPair) XXX_Merge(src proto.Message)

func (*LabelPair) XXX_Size

func (m *LabelPair) XXX_Size() int

func (*LabelPair) XXX_Unmarshal

func (m *LabelPair) XXX_Unmarshal(b []byte) error

type Metric

type Metric struct {
	Labels []LabelAdapter `protobuf:"bytes,1,rep,name=labels,proto3,customtype=LabelAdapter" json:"labels"`
}

func (*Metric) Descriptor

func (*Metric) Descriptor() ([]byte, []int)

func (*Metric) Equal

func (this *Metric) Equal(that interface{}) bool

func (*Metric) GoString

func (this *Metric) GoString() string

func (*Metric) Marshal

func (m *Metric) Marshal() (dAtA []byte, err error)

func (*Metric) MarshalTo

func (m *Metric) MarshalTo(dAtA []byte) (int, error)

func (*Metric) MarshalToSizedBuffer

func (m *Metric) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*Metric) ProtoMessage

func (*Metric) ProtoMessage()

func (*Metric) Reset

func (m *Metric) Reset()

func (*Metric) Size

func (m *Metric) Size() (n int)

func (*Metric) String

func (this *Metric) String() string

func (*Metric) Unmarshal

func (m *Metric) Unmarshal(dAtA []byte) error

func (*Metric) XXX_DiscardUnknown

func (m *Metric) XXX_DiscardUnknown()

func (*Metric) XXX_Marshal

func (m *Metric) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Metric) XXX_Merge

func (m *Metric) XXX_Merge(src proto.Message)

func (*Metric) XXX_Size

func (m *Metric) XXX_Size() int

func (*Metric) XXX_Unmarshal

func (m *Metric) XXX_Unmarshal(b []byte) error

type MetricMetadata

type MetricMetadata struct {
	Type             MetricMetadata_MetricType `protobuf:"varint,1,opt,name=type,proto3,enum=cortexpb.MetricMetadata_MetricType" json:"type,omitempty"`
	MetricFamilyName string                    `protobuf:"bytes,2,opt,name=metric_family_name,json=metricFamilyName,proto3" json:"metric_family_name,omitempty"`
	Help             string                    `protobuf:"bytes,4,opt,name=help,proto3" json:"help,omitempty"`
	Unit             string                    `protobuf:"bytes,5,opt,name=unit,proto3" json:"unit,omitempty"`
}

func (*MetricMetadata) Descriptor

func (*MetricMetadata) Descriptor() ([]byte, []int)

func (*MetricMetadata) Equal

func (this *MetricMetadata) Equal(that interface{}) bool

func (*MetricMetadata) GetHelp

func (m *MetricMetadata) GetHelp() string

func (*MetricMetadata) GetMetricFamilyName

func (m *MetricMetadata) GetMetricFamilyName() string

func (*MetricMetadata) GetType

func (*MetricMetadata) GetUnit

func (m *MetricMetadata) GetUnit() string

func (*MetricMetadata) GoString

func (this *MetricMetadata) GoString() string

func (*MetricMetadata) Marshal

func (m *MetricMetadata) Marshal() (dAtA []byte, err error)

func (*MetricMetadata) MarshalTo

func (m *MetricMetadata) MarshalTo(dAtA []byte) (int, error)

func (*MetricMetadata) MarshalToSizedBuffer

func (m *MetricMetadata) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*MetricMetadata) ProtoMessage

func (*MetricMetadata) ProtoMessage()

func (*MetricMetadata) Reset

func (m *MetricMetadata) Reset()

func (*MetricMetadata) Size

func (m *MetricMetadata) Size() (n int)

func (*MetricMetadata) String

func (this *MetricMetadata) String() string

func (*MetricMetadata) Unmarshal

func (m *MetricMetadata) Unmarshal(dAtA []byte) error

func (*MetricMetadata) XXX_DiscardUnknown

func (m *MetricMetadata) XXX_DiscardUnknown()

func (*MetricMetadata) XXX_Marshal

func (m *MetricMetadata) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*MetricMetadata) XXX_Merge

func (m *MetricMetadata) XXX_Merge(src proto.Message)

func (*MetricMetadata) XXX_Size

func (m *MetricMetadata) XXX_Size() int

func (*MetricMetadata) XXX_Unmarshal

func (m *MetricMetadata) XXX_Unmarshal(b []byte) error

type MetricMetadata_MetricType

type MetricMetadata_MetricType int32

func (MetricMetadata_MetricType) EnumDescriptor

func (MetricMetadata_MetricType) EnumDescriptor() ([]byte, []int)

func (MetricMetadata_MetricType) String

func (x MetricMetadata_MetricType) String() string

type PreallocConfig

type PreallocConfig struct{}

PreallocConfig configures how structures will be preallocated to optimise proto unmarshalling.

func (PreallocConfig) RegisterFlags

func (PreallocConfig) RegisterFlags(f *flag.FlagSet)

RegisterFlags registers configuration settings.

type PreallocTimeseries

type PreallocTimeseries struct {
	*TimeSeries
}

PreallocTimeseries is a TimeSeries which preallocs slices on Unmarshal.

func PreallocTimeseriesSliceFromPool

func PreallocTimeseriesSliceFromPool() []PreallocTimeseries

PreallocTimeseriesSliceFromPool retrieves a slice of PreallocTimeseries from a sync.Pool. ReuseSlice should be called once done.

func (*PreallocTimeseries) Unmarshal

func (p *PreallocTimeseries) Unmarshal(dAtA []byte) error

Unmarshal implements proto.Message.

type PreallocWriteRequest

type PreallocWriteRequest struct {
	WriteRequest
}

PreallocWriteRequest is a WriteRequest which preallocs slices on Unmarshal.

func (*PreallocWriteRequest) Unmarshal

func (p *PreallocWriteRequest) Unmarshal(dAtA []byte) error

Unmarshal implements proto.Message.

type Sample

type Sample struct {
	Value       float64 `protobuf:"fixed64,1,opt,name=value,proto3" json:"value,omitempty"`
	TimestampMs int64   `protobuf:"varint,2,opt,name=timestamp_ms,json=timestampMs,proto3" json:"timestamp_ms,omitempty"`
}

func (*Sample) Descriptor

func (*Sample) Descriptor() ([]byte, []int)

func (*Sample) Equal

func (this *Sample) Equal(that interface{}) bool

func (*Sample) GetTimestampMs

func (m *Sample) GetTimestampMs() int64

func (*Sample) GetValue

func (m *Sample) GetValue() float64

func (*Sample) GoString

func (this *Sample) GoString() string

func (*Sample) Marshal

func (m *Sample) Marshal() (dAtA []byte, err error)

func (Sample) MarshalJSON

func (s Sample) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*Sample) MarshalTo

func (m *Sample) MarshalTo(dAtA []byte) (int, error)

func (*Sample) MarshalToSizedBuffer

func (m *Sample) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*Sample) ProtoMessage

func (*Sample) ProtoMessage()

func (*Sample) Reset

func (m *Sample) Reset()

func (*Sample) Size

func (m *Sample) Size() (n int)

func (*Sample) String

func (this *Sample) String() string

func (*Sample) Unmarshal

func (m *Sample) Unmarshal(dAtA []byte) error

func (*Sample) UnmarshalJSON

func (s *Sample) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaler.

func (*Sample) XXX_DiscardUnknown

func (m *Sample) XXX_DiscardUnknown()

func (*Sample) XXX_Marshal

func (m *Sample) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Sample) XXX_Merge

func (m *Sample) XXX_Merge(src proto.Message)

func (*Sample) XXX_Size

func (m *Sample) XXX_Size() int

func (*Sample) XXX_Unmarshal

func (m *Sample) XXX_Unmarshal(b []byte) error

type TimeSeries

type TimeSeries struct {
	Labels []LabelAdapter `protobuf:"bytes,1,rep,name=labels,proto3,customtype=LabelAdapter" json:"labels"`
	// Sorted by time, oldest sample first.
	Samples []Sample `protobuf:"bytes,2,rep,name=samples,proto3" json:"samples"`
}

func TimeseriesFromPool

func TimeseriesFromPool() *TimeSeries

TimeseriesFromPool retrieves a pointer to a TimeSeries from a sync.Pool. ReuseTimeseries should be called once done, unless ReuseSlice was called on the slice that contains this TimeSeries.

func (*TimeSeries) Descriptor

func (*TimeSeries) Descriptor() ([]byte, []int)

func (*TimeSeries) Equal

func (this *TimeSeries) Equal(that interface{}) bool

func (*TimeSeries) GetSamples

func (m *TimeSeries) GetSamples() []Sample

func (*TimeSeries) GoString

func (this *TimeSeries) GoString() string

func (*TimeSeries) Marshal

func (m *TimeSeries) Marshal() (dAtA []byte, err error)

func (*TimeSeries) MarshalTo

func (m *TimeSeries) MarshalTo(dAtA []byte) (int, error)

func (*TimeSeries) MarshalToSizedBuffer

func (m *TimeSeries) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*TimeSeries) ProtoMessage

func (*TimeSeries) ProtoMessage()

func (*TimeSeries) Reset

func (m *TimeSeries) Reset()

func (*TimeSeries) Size

func (m *TimeSeries) Size() (n int)

func (*TimeSeries) String

func (this *TimeSeries) String() string

func (*TimeSeries) Unmarshal

func (m *TimeSeries) Unmarshal(dAtA []byte) error

func (*TimeSeries) XXX_DiscardUnknown

func (m *TimeSeries) XXX_DiscardUnknown()

func (*TimeSeries) XXX_Marshal

func (m *TimeSeries) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*TimeSeries) XXX_Merge

func (m *TimeSeries) XXX_Merge(src proto.Message)

func (*TimeSeries) XXX_Size

func (m *TimeSeries) XXX_Size() int

func (*TimeSeries) XXX_Unmarshal

func (m *TimeSeries) XXX_Unmarshal(b []byte) error

type WriteRequest

type WriteRequest struct {
	Timeseries              []PreallocTimeseries    `protobuf:"bytes,1,rep,name=timeseries,proto3,customtype=PreallocTimeseries" json:"timeseries"`
	Source                  WriteRequest_SourceEnum `protobuf:"varint,2,opt,name=Source,proto3,enum=cortexpb.WriteRequest_SourceEnum" json:"Source,omitempty"`
	Metadata                []*MetricMetadata       `protobuf:"bytes,3,rep,name=metadata,proto3" json:"metadata,omitempty"`
	SkipLabelNameValidation bool                    `` /* 138-byte string literal not displayed */
}

func ToWriteRequest

func ToWriteRequest(lbls []labels.Labels, samples []Sample, metadata []*MetricMetadata, source WriteRequest_SourceEnum) *WriteRequest

ToWriteRequest converts matched slices of Labels, Samples and Metadata into a WriteRequest proto. It gets timeseries from the pool, so ReuseSlice() should be called when done.

func (*WriteRequest) Descriptor

func (*WriteRequest) Descriptor() ([]byte, []int)

func (*WriteRequest) Equal

func (this *WriteRequest) Equal(that interface{}) bool

func (*WriteRequest) GetMetadata

func (m *WriteRequest) GetMetadata() []*MetricMetadata

func (*WriteRequest) GetSkipLabelNameValidation

func (m *WriteRequest) GetSkipLabelNameValidation() bool

func (*WriteRequest) GetSource

func (m *WriteRequest) GetSource() WriteRequest_SourceEnum

func (*WriteRequest) GoString

func (this *WriteRequest) GoString() string

func (*WriteRequest) Marshal

func (m *WriteRequest) Marshal() (dAtA []byte, err error)

func (*WriteRequest) MarshalTo

func (m *WriteRequest) MarshalTo(dAtA []byte) (int, error)

func (*WriteRequest) MarshalToSizedBuffer

func (m *WriteRequest) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*WriteRequest) ProtoMessage

func (*WriteRequest) ProtoMessage()

func (*WriteRequest) Reset

func (m *WriteRequest) Reset()

func (*WriteRequest) Size

func (m *WriteRequest) Size() (n int)

func (*WriteRequest) String

func (this *WriteRequest) String() string

func (*WriteRequest) Unmarshal

func (m *WriteRequest) Unmarshal(dAtA []byte) error

func (*WriteRequest) XXX_DiscardUnknown

func (m *WriteRequest) XXX_DiscardUnknown()

func (*WriteRequest) XXX_Marshal

func (m *WriteRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*WriteRequest) XXX_Merge

func (m *WriteRequest) XXX_Merge(src proto.Message)

func (*WriteRequest) XXX_Size

func (m *WriteRequest) XXX_Size() int

func (*WriteRequest) XXX_Unmarshal

func (m *WriteRequest) XXX_Unmarshal(b []byte) error

type WriteRequest_SourceEnum

type WriteRequest_SourceEnum int32

func (WriteRequest_SourceEnum) EnumDescriptor

func (WriteRequest_SourceEnum) EnumDescriptor() ([]byte, []int)

func (WriteRequest_SourceEnum) String

func (x WriteRequest_SourceEnum) String() string

type WriteResponse

type WriteResponse struct {
}

func (*WriteResponse) Descriptor

func (*WriteResponse) Descriptor() ([]byte, []int)

func (*WriteResponse) Equal

func (this *WriteResponse) Equal(that interface{}) bool

func (*WriteResponse) GoString

func (this *WriteResponse) GoString() string

func (*WriteResponse) Marshal

func (m *WriteResponse) Marshal() (dAtA []byte, err error)

func (*WriteResponse) MarshalTo

func (m *WriteResponse) MarshalTo(dAtA []byte) (int, error)

func (*WriteResponse) MarshalToSizedBuffer

func (m *WriteResponse) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*WriteResponse) ProtoMessage

func (*WriteResponse) ProtoMessage()

func (*WriteResponse) Reset

func (m *WriteResponse) Reset()

func (*WriteResponse) Size

func (m *WriteResponse) Size() (n int)

func (*WriteResponse) String

func (this *WriteResponse) String() string

func (*WriteResponse) Unmarshal

func (m *WriteResponse) Unmarshal(dAtA []byte) error

func (*WriteResponse) XXX_DiscardUnknown

func (m *WriteResponse) XXX_DiscardUnknown()

func (*WriteResponse) XXX_Marshal

func (m *WriteResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*WriteResponse) XXX_Merge

func (m *WriteResponse) XXX_Merge(src proto.Message)

func (*WriteResponse) XXX_Size

func (m *WriteResponse) XXX_Size() int

func (*WriteResponse) XXX_Unmarshal

func (m *WriteResponse) XXX_Unmarshal(b []byte) error

Jump to

Keyboard shortcuts

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