data

package
v0.0.0-...-d30abd5 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

README

package data

import "github.com/zeebo/rothko/data"

package data provides types for handling rothko data.

Usage

var (
	ErrInvalidLengthRecord = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowRecord   = fmt.Errorf("proto: integer overflow")
)
type Record
type Record struct {
	// start and end time in seconds since unix epoch utc
	StartTime int64 `protobuf:"varint,1,opt,name=start_time,json=startTime,proto3" json:"start_time,omitempty"`
	EndTime   int64 `protobuf:"varint,2,opt,name=end_time,json=endTime,proto3" json:"end_time,omitempty"`
	// the number of observations in the distribution
	Observations int64 `protobuf:"varint,3,opt,name=observations,proto3" json:"observations,omitempty"`
	// a serialized distribution. the kind tells us which type of distribution
	// it is.
	Distribution []byte `protobuf:"bytes,4,opt,name=distribution,proto3" json:"distribution,omitempty"`
	Kind         string `protobuf:"bytes,5,opt,name=kind,proto3" json:"kind,omitempty"`
	// minimum and maximum values observed
	Min   float64 `protobuf:"fixed64,6,opt,name=min,proto3" json:"min,omitempty"`
	Max   float64 `protobuf:"fixed64,7,opt,name=max,proto3" json:"max,omitempty"`
	MinId []byte  `protobuf:"bytes,8,opt,name=min_id,json=minId,proto3" json:"min_id,omitempty"`
	MaxId []byte  `protobuf:"bytes,9,opt,name=max_id,json=maxId,proto3" json:"max_id,omitempty"`
	// how many records have been merged into this.
	Merged int64 `protobuf:"varint,10,opt,name=merged,proto3" json:"merged,omitempty"`
}

Record is an observed distribution over some time period with some additional data about observed minimums and maximums.

func (*Record) Marshal
func (m *Record) Marshal() (dAtA []byte, err error)
func (*Record) MarshalTo
func (m *Record) MarshalTo(dAtA []byte) (int, error)
func (*Record) Reset
func (m *Record) Reset()
func (*Record) Size
func (m *Record) Size() (n int)
func (*Record) Unmarshal
func (m *Record) Unmarshal(dAtA []byte) error
type Writer
type Writer struct {
}

Writer keeps track of the distributions of a collection of metrics.

func NewWriter
func NewWriter(params dist.Params) *Writer

NewWriter makes a Writer that will return distributions using the associated compression.

func (*Writer) Add
func (s *Writer) Add(ctx context.Context, metric string,
	value float64, id []byte)

Add adds the metric value to the current set of records. It will be reflected in the distribution of the records returned by Capture. WARNING: under some concurrent scenarios, this can lose updates.

func (*Writer) Capture
func (s *Writer) Capture(ctx context.Context,
	fn func(ctx context.Context, metric string, rec Record) bool)

Capture clears out current set of records for future Add calls and calls the provided function with every record. You must not hold on to any fields of the record after the callback returns.

func (*Writer) Iterate
func (s *Writer) Iterate(ctx context.Context,
	fn func(ctx context.Context, metric string, rec Record) bool)

Iterate calls the provided function with every record. You must not hold on to any fields of the record after the callback returns.

Documentation

Overview

package data provides types for handling rothko data.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidLengthRecord = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowRecord   = fmt.Errorf("proto: integer overflow")
)

Functions

This section is empty.

Types

type Record

type Record struct {
	// start and end time in seconds since unix epoch utc
	StartTime int64 `protobuf:"varint,1,opt,name=start_time,json=startTime,proto3" json:"start_time,omitempty"`
	EndTime   int64 `protobuf:"varint,2,opt,name=end_time,json=endTime,proto3" json:"end_time,omitempty"`
	// the number of observations in the distribution
	Observations int64 `protobuf:"varint,3,opt,name=observations,proto3" json:"observations,omitempty"`
	// a serialized distribution. the kind tells us which type of distribution
	// it is.
	Distribution []byte `protobuf:"bytes,4,opt,name=distribution,proto3" json:"distribution,omitempty"`
	Kind         string `protobuf:"bytes,5,opt,name=kind,proto3" json:"kind,omitempty"`
	// minimum and maximum values observed
	Min   float64 `protobuf:"fixed64,6,opt,name=min,proto3" json:"min,omitempty"`
	Max   float64 `protobuf:"fixed64,7,opt,name=max,proto3" json:"max,omitempty"`
	MinId []byte  `protobuf:"bytes,8,opt,name=min_id,json=minId,proto3" json:"min_id,omitempty"`
	MaxId []byte  `protobuf:"bytes,9,opt,name=max_id,json=maxId,proto3" json:"max_id,omitempty"`
	// how many records have been merged into this.
	Merged int64 `protobuf:"varint,10,opt,name=merged,proto3" json:"merged,omitempty"`
}

Record is an observed distribution over some time period with some additional data about observed minimums and maximums.

func (*Record) Marshal

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

func (*Record) MarshalTo

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

func (*Record) Reset

func (m *Record) Reset()

func (*Record) Size

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

func (*Record) Unmarshal

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

type Writer

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

Writer keeps track of the distributions of a collection of metrics.

func NewWriter

func NewWriter(params dist.Params) *Writer

NewWriter makes a Writer that will return distributions using the associated compression.

func (*Writer) Add

func (s *Writer) Add(ctx context.Context, metric string,
	value float64, id []byte)

Add adds the metric value to the current set of records. It will be reflected in the distribution of the records returned by Capture. WARNING: under some concurrent scenarios, this can lose updates.

func (*Writer) Capture

func (s *Writer) Capture(ctx context.Context,
	fn func(ctx context.Context, metric string, rec Record) bool)

Capture clears out current set of records for future Add calls and calls the provided function with every record. You must not hold on to any fields of the record after the callback returns.

func (*Writer) Iterate

func (s *Writer) Iterate(ctx context.Context,
	fn func(ctx context.Context, metric string, rec Record) bool)

Iterate calls the provided function with every record. You must not hold on to any fields of the record after the callback returns.

Directories

Path Synopsis
package load provides a function to load a dist.Dist from a data.Record.
package load provides a function to load a dist.Dist from a data.Record.

Jump to

Keyboard shortcuts

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