point

package
v1.1.14 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: MIT Imports: 33 Imported by: 1

README

DataKit 采集的数据结构定义

Point

Point 是 DataKit 中最常用的一种数据表示形式,目前 Point 有两种表现形式:

  1. 行协议
  2. Protobuf

由于行协议表达能力有限,后面会逐渐迁移到 Protobuf,同时中心仍然长期支持行协议写入(不同的 API 版本)。除此之外,行协议和 Protobuf 之间并无实质性的差异,效率上而言(非极端情况):

  • 编码体积上,Protobuf 和航协议相当(随机出来的数据点)
  • 编码效率上,Protobuf 在效率(X10)和内存占用(X8)上,都较行协议更好
  • 解码效率上,Protobuf 也更好(X5)

以上测试,参见 TestEncodePayloadSize/BenchmarkEncode/BenchmarkDecode。 可参考如下结果:

### BAD
$ CGO_CFLAGS=-Wno-undef-prefix go test -run XXX -test.benchmem -test.v -bench BenchmarkDecode
goos: darwin
goarch: arm64
pkg: github.com/GuanceCloud/cliutils/point
BenchmarkDecode
BenchmarkDecode/bench-decode-lp
BenchmarkDecode/bench-decode-lp-10                   100          12091620 ns/op         4670056 B/op      90282 allocs/op
BenchmarkDecode/bench-decode-pb
BenchmarkDecode/bench-decode-pb-10                   550           2172161 ns/op         3052850 B/op      70024 allocs/op
BenchmarkDecode/bench-decode-json
BenchmarkDecode/bench-decode-json-10                  96          12690984 ns/op         6269919 B/op     137321 allocs/op
PASS
ok      github.com/GuanceCloud/cliutils/point   4.995s

$ CGO_CFLAGS=-Wno-undef-prefix go test -run XXX -test.benchmem -test.v -bench BenchmarkEncode
goos: darwin
goarch: arm64
pkg: github.com/GuanceCloud/cliutils/point
BenchmarkEncode
BenchmarkEncode/bench-encode-json
BenchmarkEncode/bench-encode-json-10                  98          10294642 ns/op         7724543 B/op      60288 allocs/op
BenchmarkEncode/bench-encode-lp
BenchmarkEncode/bench-encode-lp-10                   241           4900589 ns/op         8675253 B/op      41043 allocs/op
BenchmarkEncode/bench-encode-pb
BenchmarkEncode/bench-encode-pb-10                  2727            452257 ns/op         1115027 B/op         16 allocs/op
BenchmarkEncode/v2-encode-pb
BenchmarkEncode/v2-encode-pb-10                     2754            438385 ns/op              15 B/op          0 allocs/op
BenchmarkEncode/v2-encode-lp
BenchmarkEncode/v2-encode-lp-10                      268           4461083 ns/op         5258539 B/op      39066 allocs/op
PASS
ok      github.com/GuanceCloud/cliutils/point   7.483s

Point 的约束

Point 构建函数:

pt := NewPointV2(name []byte, kvs KVs, opts... Option)

NewPoint() 已 Deprecated.

由于 Point 最终需要写入后端存储,故而受到后端存储的各种限制,但原则上采集端仍然做尽量少的限制,以保证数据采集的多样性和完整性。目前 Point 限制如下(本次放开/新加的约束,粗体表示):

  1. 概念上,仍旧区分 tag 和 field。但在底层数据结构上,它们的类型一致,都是 key-value,只是在特定的 key-value 上,会标注其是否为 tag(IsTag)。可以简单理解为 tag/field 都是 key。field 概念不再重要,在这些 key-value 对中,tag 只是更特化的一种 key-value,非 tag 的 key-value 都可以视为 field。

  2. kvs 本质上是一个数组结构,以增加顺序排列

  3. 同一个 point 中,tag 和 field 之间不允许出现同名的 key。这一限制主要用来确保 DQL 查询时字段的唯一性。如果 tag/field 中出现同名 key,后出现的 key 将不再生效。

  4. tag/field key 以及 value 目前不做协议上的限制,这一限制可以在应用层(比如 datakit/kodo)通过 Option 配置来控制

  5. tag/field key/value 的内容均有几个方面的限制:

    • tag key 和 value 中均不允许出现换行字符,如果出现,SDK 会将其替换成空格。如字符串 "abc\ndef" 会被替换成 "abc def"。该限制无法通过 Option 控制。
    • Point 可以没有任何 key(即可以没有 tag 和 field)。对于这样的 point,在上传过程中,自动忽略,但不会影响其它正常 point 的处理。
    • tag key 和 value 均不允许以反斜杠 \ 结尾,如果出现,SDK 会将其移除掉。如字符串 "abc\" 会被替换成 "abc"。该限制无法通过 Option 控制。
    • 对日志类数据(非时序数据)而言,tag/field 的 key 中不允许出现 . 字符,如果出现,SDK 会将其替换成 _,如 key "abc.def" 会被替换成 "abc_def"。该限制可以通过 Option 控制。(注:这一限制主要因后端使用 ES 作为存储所致,如果不用 ES 可以移除这一限制)
    • tag/field 个数、 各个 tag/field key/value 长度(此处特指字符串长度)均可以通过 Option 设置。
    • 某些特定的数据类型(T/L/R/O/...),可以禁用某些 key(这里的 key 是带类型的,比如对象上不允许出现 key 为 class 的字段,一旦出现这些 key,最终的 Point 数据中,这些 key 将被自动移除掉。
      • 所有在构建点的过程中,如果出现自动调整(比如移除某些字段),均会在最终的 point 结构中出现对应的 warning 信息(通过 point.Pretty() 可以查看)
  6. 构建 point 过程中出现的 warning/debug 信息,如果用 PB 结构上报,会一并上传到中心(kodo),中心在写入存储的时候,可以不用理会这些信息,主要是调试用

  7. tag value 目前只支持 string 值

  8. field value 目前支持:

    • int8/int16/int32/int64 表示有符号整数
    • uint8/uint16/uint32/uint64 表示无符号整数
    • float64:浮点数,暂无限制
    • bool:暂无限制
    • []byte:字节流,可以存放二进制数据
    • string:暂无限制
    • []any:数组类型,数组元素必须是基础类型(int/uint/float/string/bool),且数组内类型一致。

Documentation

Overview

Package point implements datakits basic data structure.

Index

Constants

View Source
const (
	ArrayFieldType = "type.googleapis.com/point.Array"
	DictFieldType  = "type.googleapis.com/point.Map"
)
View Source
const (
	UnknownCategory Category = iota
	DynamicDWCategory
	MetricDeprecated

	Metric
	Network
	KeyEvent
	Object
	CustomObject
	Logging
	Tracing
	RUM
	Security
	Profiling

	SUnknownCategory   = "unknown"
	SDynamicDWCategory = "dynamic_dw" // NOTE: not used
	SMetric            = "metric"
	SMetricDeprecated  = "metrics"
	SNetwork           = "network"
	SKeyEvent          = "keyevent"
	SObject            = "object"
	SCustomObject      = "custom_object"
	SLogging           = "logging"
	STracing           = "tracing"
	SRUM               = "rum"
	SSecurity          = "security"
	SProfiling         = "profiling"

	URLUnknownCategory   = "/v1/write/unknown"
	URLDynamicDWCategory = "/v1/write/dynamic_dw" // NOTE: not used
	URLMetric            = "/v1/write/metric"
	URLMetricDeprecated  = "/v1/write/metrics"
	URLNetwork           = "/v1/write/network"
	URLKeyEvent          = "/v1/write/keyevent"
	URLObject            = "/v1/write/object"
	URLCustomObject      = "/v1/write/custom_object"
	URLLogging           = "/v1/write/logging"
	URLTracing           = "/v1/write/tracing"
	URLRUM               = "/v1/write/rum"
	URLSecurity          = "/v1/write/security"
	URLProfiling         = "/v1/write/profiling"

	CUnknown   = "UNKNOWN"
	CDynamicDW = "DYNAMIC_DW"
	CM         = "M"
	CN         = "N"
	CE         = "E"
	CO         = "O"
	CCO        = "CO"
	CL         = "L"
	CT         = "T"
	CR         = "R"
	CS         = "S"
	CP         = "P"
)
View Source
const (
	EnvDefaultEncoding       = "ENV_DEFAULT_ENCODING"
	EnvEnableMixedArrayField = "ENV_ENABLE_MIXED_ARRAY_FIELD"
	EnvEnableDictField       = "ENV_ENABLE_DICT_FIELD"
)
View Source
const (
	WarnMaxTags               = "exceed_max_tags"
	WarnMaxFields             = "exceed_max_fields"
	WarnNoField               = "no_field"
	WarnMaxTagKeyLen          = "exceed_max_tag_key_len"
	WarnMaxTagValueLen        = "exceed_max_tag_value_len"
	WarnMaxFieldKeyLen        = "exceed_max_field_key_len"
	WarnMaxFieldValueLen      = "exceed_max_field_value_len"
	WarnMaxFieldValueInt      = "exceed_max_field_value_int"
	WarnInvalidUTF8String     = "invalid_utf8_string"
	WarnMaxTagKeyValueCompose = "exceed_max_tag_key_value_compose"

	WarnInvalidTagKey         = "invalid_tag_key"
	WarnInvalidTagValue       = "invalid_tag_value"
	WarnInvalidMeasurement    = "invalid_measurement"
	WarnInvalidFieldValueType = "invalid_field_value_type"
	WarnAddRequiredKV         = "add_required_kv"

	WarnFieldDisabled = "field_disabled"
	WarnTagDisabled   = "tag_disabled"

	WarnSameTagFieldKey = "same_tag_field_key"
	WarnKeyNameConflict = "key_name_conflict"
	WarnDotInkey        = "dot_in_key"
	WarnFieldB64Encoded = "field_base64_encoded"
	WarnNilField        = "nil_field"
)

Point warnnings.

View Source
const (
	Psent   = 1 << iota // The Point has been sent
	Ppb                 // the point is Protobuf point
	Pcheck              // checked
	Ppooled             // from point pool

)

Variables

View Source
var (
	// EnableMixedArrayField and EnableDictField used to allow mix-typed array and dict/map
	// value in point field.
	//
	// Currently, GuanceDB backend do NOT support mix-typed array and dict.
	EnableMixedArrayField = false
	EnableDictField       = false
)
View Source
var (
	ErrNoFields            = errors.New("no fields")
	ErrInvalidLineProtocol = errors.New("invalid lineprotocol")
)
View Source
var (
	ErrInvalidLengthPoint        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowPoint          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupPoint = fmt.Errorf("proto: unexpected end of group")
)
View Source
var (
	DefaultMeasurementName = "__default"

	KeyTime        = NewKey("time", I)
	KeyMeasurement = NewKey("measurement", S)
	KeySource      = NewKey("source", S)
	KeyClass       = NewKey("class", S)
	KeyDate        = NewKey("date", I)

	KeyName   = NewKey("name", S, defaultObjectName)
	KeyStatus = NewKey("status", S, defaultLoggingStatus)
)
View Source
var (
	DefaultEncoding = LineProtocol
)
View Source
var KeyType_name = map[int32]string{
	0: "X",
	1: "I",
	2: "U",
	3: "F",
	4: "B",
	5: "D",
	6: "NIL",
	7: "S",
	8: "A",
}
View Source
var KeyType_value = map[string]int32{
	"X":   0,
	"I":   1,
	"U":   2,
	"F":   3,
	"B":   4,
	"D":   5,
	"NIL": 6,
	"S":   7,
	"A":   8,
}
View Source
var MetricType_name = map[int32]string{
	0: "UNSPECIFIED",
	1: "COUNT",
	2: "RATE",
	3: "GAUGE",
}
View Source
var MetricType_value = map[string]int32{
	"UNSPECIFIED": 0,
	"COUNT":       1,
	"RATE":        2,
	"GAUGE":       3,
}

Functions

func AnyRaw added in v0.1.6

func AnyRaw(x *types.Any) (any, error)

AnyRaw get underlying wrapped value within types.Any.

func ClearPointPool added in v1.1.12

func ClearPointPool()

func GetCfg

func GetCfg(opts ...Option) *cfg

func MustAnyRaw added in v0.1.6

func MustAnyRaw(x *types.Any) any

MustAnyRaw get underlying wrapped value, and panic if any error.

func MustNewAny added in v0.1.6

func MustNewAny(x proto.Message) *types.Any

MustNewAny create anypb based on exist proto message, and panic if any error.

func MustNewAnyArray added in v0.1.6

func MustNewAnyArray(a ...any) *types.Any

MustNewAnyArray wrapped mix-basic-typed list into types.Any, and panic if any error.

func MustNewBoolArray added in v0.1.6

func MustNewBoolArray(b ...bool) *types.Any

MustNewBoolArray wrapped boolean list into types.Any, and panic if any error.

func MustNewBytesArray added in v1.1.12

func MustNewBytesArray(bytes ...[]byte) *types.Any

MustNewBytesArray wrapped string list into types.Any, and panic if any error.

func MustNewFloatArray added in v0.1.6

func MustNewFloatArray[T float32 | float64](f ...T) *types.Any

MustNewFloatArray wrapped float list into types.Any, and panic if any error.

func MustNewIntArray added in v0.1.6

func MustNewIntArray[T int8 | int16 | int | int32 | int64](i ...T) *types.Any

MustNewIntArray wrapped signed int list into types.Any, and panic if any error.

func MustNewStringArray added in v0.1.6

func MustNewStringArray(s ...string) *types.Any

MustNewStringArray wrapped string list into types.Any, and panic if any error.

func MustNewUintArray added in v0.1.6

func MustNewUintArray[T uint16 | uint | uint32 | uint64](i ...T) *types.Any

MustNewUintArray wrapped unsigned int list into types.Any, and panic if any error.

func NewAny added in v0.1.6

func NewAny(x proto.Message) (*types.Any, error)

NewAny create types.Any based on exist proto message.

func NewAnyArray added in v0.1.6

func NewAnyArray(a ...any) (*types.Any, error)

NewAnyArray wrapped mix-basic-typed list into types.Any.

func NewBoolArray added in v0.1.6

func NewBoolArray(b ...bool) (*types.Any, error)

NewBoolArray wrapped boolean list into types.Any.

func NewBytesArray added in v1.1.12

func NewBytesArray(bytes ...[]byte) (*types.Any, error)

NewBytesArray wrapped string list into types.Any.

func NewFloatArray added in v0.1.6

func NewFloatArray[T float32 | float64](f ...T) (*types.Any, error)

NewFloatArray wrapped float list into types.Any.

func NewIntArray added in v0.1.6

func NewIntArray[T int8 | int16 | int | int32 | int64](i ...T) (*types.Any, error)

NewIntArray wrapped signed int list into types.Any.

func NewRander

func NewRander(opts ...RandOption) *ptRander

func NewStringArray added in v0.1.6

func NewStringArray(s ...string) (*types.Any, error)

NewStringArray wrapped string list into types.Any.

func NewUintArray added in v0.1.6

func NewUintArray[T uint16 | uint | uint32 | uint64](i ...T) (*types.Any, error)

NewUintArray wrapped unsigned int list into types.Any.

func PB2LP

func PB2LP(pb []byte) (lp []byte, err error)

PB2LP convert protobuf Point to line-protocol Point.

func PutCfg

func PutCfg(c *cfg)

func PutDecoder

func PutDecoder(d *Decoder)

func PutEncoder

func PutEncoder(e *Encoder)

func SetPointPool added in v1.1.12

func SetPointPool(pp PointPool)

func SortByTime added in v0.1.6

func SortByTime(pts []*Point)

SortByTime sort(ASC) pts according to time.

Types

type AnyDemo

type AnyDemo struct {
	Demo string `protobuf:"bytes,1,opt,name=demo,proto3" json:"demo,omitempty"`
}

example of pb.Any

func (*AnyDemo) Descriptor

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

func (*AnyDemo) Equal added in v1.1.12

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

func (*AnyDemo) GetDemo

func (m *AnyDemo) GetDemo() string

func (*AnyDemo) GoString added in v1.1.12

func (this *AnyDemo) GoString() string

func (*AnyDemo) Marshal added in v1.1.12

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

func (*AnyDemo) MarshalTo added in v1.1.12

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

func (*AnyDemo) MarshalToSizedBuffer added in v1.1.12

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

func (*AnyDemo) ProtoMessage

func (*AnyDemo) ProtoMessage()

func (*AnyDemo) Reset

func (m *AnyDemo) Reset()

func (*AnyDemo) Size added in v1.1.12

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

func (*AnyDemo) String

func (this *AnyDemo) String() string

func (*AnyDemo) Unmarshal added in v1.1.12

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

func (*AnyDemo) XXX_DiscardUnknown added in v1.1.12

func (m *AnyDemo) XXX_DiscardUnknown()

func (*AnyDemo) XXX_Marshal added in v1.1.12

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

func (*AnyDemo) XXX_Merge added in v1.1.12

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

func (*AnyDemo) XXX_Size added in v1.1.12

func (m *AnyDemo) XXX_Size() int

func (*AnyDemo) XXX_Unmarshal added in v1.1.12

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

type Array added in v0.1.6

type Array struct {
	Arr []*BasicTypes `protobuf:"bytes,1,rep,name=arr,proto3" json:"arr,omitempty"`
}

func NewArray added in v0.1.6

func NewArray(ents ...any) (arr *Array, err error)

NewArray create array value that can be used in point field. The types within ents can be mixed basic types.

func (*Array) Descriptor added in v0.1.6

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

func (*Array) Equal added in v1.1.12

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

func (*Array) GetArr added in v0.1.6

func (m *Array) GetArr() []*BasicTypes

func (*Array) GoString added in v1.1.12

func (this *Array) GoString() string

func (*Array) Marshal added in v1.1.12

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

func (*Array) MarshalTo added in v1.1.12

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

func (*Array) MarshalToSizedBuffer added in v1.1.12

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

func (*Array) ProtoMessage added in v0.1.6

func (*Array) ProtoMessage()

func (*Array) Reset added in v0.1.6

func (m *Array) Reset()

func (*Array) Size added in v1.1.12

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

func (*Array) String added in v0.1.6

func (this *Array) String() string

func (*Array) Unmarshal added in v1.1.12

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

func (*Array) XXX_DiscardUnknown added in v1.1.12

func (m *Array) XXX_DiscardUnknown()

func (*Array) XXX_Marshal added in v1.1.12

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

func (*Array) XXX_Merge added in v1.1.12

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

func (*Array) XXX_Size added in v1.1.12

func (m *Array) XXX_Size() int

func (*Array) XXX_Unmarshal added in v1.1.12

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

type BasicTypes added in v0.1.6

type BasicTypes struct {
	// Types that are valid to be assigned to X:
	//	*BasicTypes_I
	//	*BasicTypes_U
	//	*BasicTypes_F
	//	*BasicTypes_B
	//	*BasicTypes_D
	//	*BasicTypes_S
	X isBasicTypes_X `protobuf_oneof:"x"`
}

func (*BasicTypes) Descriptor added in v0.1.6

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

func (*BasicTypes) Equal added in v1.1.12

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

func (*BasicTypes) GetB added in v0.1.6

func (m *BasicTypes) GetB() bool

func (*BasicTypes) GetD added in v0.1.6

func (m *BasicTypes) GetD() []byte

func (*BasicTypes) GetF added in v0.1.6

func (m *BasicTypes) GetF() float64

func (*BasicTypes) GetI added in v0.1.6

func (m *BasicTypes) GetI() int64

func (*BasicTypes) GetS added in v0.1.6

func (m *BasicTypes) GetS() string

func (*BasicTypes) GetU added in v0.1.6

func (m *BasicTypes) GetU() uint64

func (*BasicTypes) GetX added in v0.1.6

func (m *BasicTypes) GetX() isBasicTypes_X

func (*BasicTypes) GoString added in v1.1.12

func (this *BasicTypes) GoString() string

func (*BasicTypes) Marshal added in v1.1.12

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

func (*BasicTypes) MarshalTo added in v1.1.12

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

func (*BasicTypes) MarshalToSizedBuffer added in v1.1.12

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

func (*BasicTypes) ProtoMessage added in v0.1.6

func (*BasicTypes) ProtoMessage()

func (*BasicTypes) Reset added in v0.1.6

func (m *BasicTypes) Reset()

func (*BasicTypes) Size added in v1.1.12

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

func (*BasicTypes) String added in v0.1.6

func (this *BasicTypes) String() string

func (*BasicTypes) Unmarshal added in v1.1.12

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

func (*BasicTypes) XXX_DiscardUnknown added in v1.1.12

func (m *BasicTypes) XXX_DiscardUnknown()

func (*BasicTypes) XXX_Marshal added in v1.1.12

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

func (*BasicTypes) XXX_Merge added in v1.1.12

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

func (*BasicTypes) XXX_OneofWrappers added in v1.1.12

func (*BasicTypes) XXX_OneofWrappers() []interface{}

XXX_OneofWrappers is for the internal use of the proto package.

func (*BasicTypes) XXX_Size added in v1.1.12

func (m *BasicTypes) XXX_Size() int

func (*BasicTypes) XXX_Unmarshal added in v1.1.12

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

type BasicTypes_B added in v0.1.6

type BasicTypes_B struct {
	B bool `protobuf:"varint,4,opt,name=b,proto3,oneof" json:"b,omitempty"`
}

func (*BasicTypes_B) Equal added in v1.1.12

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

func (*BasicTypes_B) GoString added in v1.1.12

func (this *BasicTypes_B) GoString() string

func (*BasicTypes_B) MarshalTo added in v1.1.12

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

func (*BasicTypes_B) MarshalToSizedBuffer added in v1.1.12

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

func (*BasicTypes_B) Size added in v1.1.12

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

func (*BasicTypes_B) String added in v1.1.12

func (this *BasicTypes_B) String() string

type BasicTypes_D added in v0.1.6

type BasicTypes_D struct {
	D []byte `protobuf:"bytes,5,opt,name=d,proto3,oneof" json:"d,omitempty"`
}

func (*BasicTypes_D) Equal added in v1.1.12

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

func (*BasicTypes_D) GoString added in v1.1.12

func (this *BasicTypes_D) GoString() string

func (*BasicTypes_D) MarshalTo added in v1.1.12

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

func (*BasicTypes_D) MarshalToSizedBuffer added in v1.1.12

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

func (*BasicTypes_D) Size added in v1.1.12

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

func (*BasicTypes_D) String added in v1.1.12

func (this *BasicTypes_D) String() string

type BasicTypes_F added in v0.1.6

type BasicTypes_F struct {
	F float64 `protobuf:"fixed64,3,opt,name=f,proto3,oneof" json:"f,omitempty"`
}

func (*BasicTypes_F) Equal added in v1.1.12

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

func (*BasicTypes_F) GoString added in v1.1.12

func (this *BasicTypes_F) GoString() string

func (*BasicTypes_F) MarshalTo added in v1.1.12

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

func (*BasicTypes_F) MarshalToSizedBuffer added in v1.1.12

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

func (*BasicTypes_F) Size added in v1.1.12

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

func (*BasicTypes_F) String added in v1.1.12

func (this *BasicTypes_F) String() string

type BasicTypes_I added in v0.1.6

type BasicTypes_I struct {
	I int64 `protobuf:"varint,1,opt,name=i,proto3,oneof" json:"i,omitempty"`
}

func (*BasicTypes_I) Equal added in v1.1.12

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

func (*BasicTypes_I) GoString added in v1.1.12

func (this *BasicTypes_I) GoString() string

func (*BasicTypes_I) MarshalTo added in v1.1.12

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

func (*BasicTypes_I) MarshalToSizedBuffer added in v1.1.12

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

func (*BasicTypes_I) Size added in v1.1.12

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

func (*BasicTypes_I) String added in v1.1.12

func (this *BasicTypes_I) String() string

type BasicTypes_S added in v0.1.6

type BasicTypes_S struct {
	S string `protobuf:"bytes,6,opt,name=s,proto3,oneof" json:"s,omitempty"`
}

func (*BasicTypes_S) Equal added in v1.1.12

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

func (*BasicTypes_S) GoString added in v1.1.12

func (this *BasicTypes_S) GoString() string

func (*BasicTypes_S) MarshalTo added in v1.1.12

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

func (*BasicTypes_S) MarshalToSizedBuffer added in v1.1.12

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

func (*BasicTypes_S) Size added in v1.1.12

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

func (*BasicTypes_S) String added in v1.1.12

func (this *BasicTypes_S) String() string

type BasicTypes_U added in v0.1.6

type BasicTypes_U struct {
	U uint64 `protobuf:"varint,2,opt,name=u,proto3,oneof" json:"u,omitempty"`
}

func (*BasicTypes_U) Equal added in v1.1.12

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

func (*BasicTypes_U) GoString added in v1.1.12

func (this *BasicTypes_U) GoString() string

func (*BasicTypes_U) MarshalTo added in v1.1.12

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

func (*BasicTypes_U) MarshalToSizedBuffer added in v1.1.12

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

func (*BasicTypes_U) Size added in v1.1.12

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

func (*BasicTypes_U) String added in v1.1.12

func (this *BasicTypes_U) String() string

type Callback

type Callback func(*Point) (*Point, error)

type Category

type Category int

func AllCategories

func AllCategories() []Category

func CatAlias

func CatAlias(c string) Category

func CatString

func CatString(c string) Category

func CatURL

func CatURL(c string) Category

func (Category) Alias

func (c Category) Alias() string

func (Category) String

func (c Category) String() string

func (Category) URL

func (c Category) URL() string

type Debug

type Debug struct {
	Info string `protobuf:"bytes,1,opt,name=info,proto3" json:"info,omitempty"`
}

Debug used to attached some debug info for the point, these debug info will encoded into payload, storage can take optional handle on these debug info.

func (*Debug) Descriptor

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

func (*Debug) Equal added in v1.1.12

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

func (*Debug) GetInfo

func (m *Debug) GetInfo() string

func (*Debug) GoString added in v1.1.12

func (this *Debug) GoString() string

func (*Debug) Marshal added in v1.1.12

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

func (*Debug) MarshalTo added in v1.1.12

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

func (*Debug) MarshalToSizedBuffer added in v1.1.12

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

func (*Debug) ProtoMessage

func (*Debug) ProtoMessage()

func (*Debug) Reset

func (m *Debug) Reset()

func (*Debug) Size added in v1.1.12

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

func (*Debug) String

func (this *Debug) String() string

func (*Debug) Unmarshal added in v1.1.12

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

func (*Debug) XXX_DiscardUnknown added in v1.1.12

func (m *Debug) XXX_DiscardUnknown()

func (*Debug) XXX_Marshal added in v1.1.12

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

func (*Debug) XXX_Merge added in v1.1.12

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

func (*Debug) XXX_Size added in v1.1.12

func (m *Debug) XXX_Size() int

func (*Debug) XXX_Unmarshal added in v1.1.12

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

type DecodeFn

type DecodeFn func([]*Point) error

DecodeFn used to iterate on []*Point payload, if error returned, the iterate terminated.

type Decoder

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

func GetDecoder

func GetDecoder(opts ...DecoderOption) *Decoder

func (*Decoder) Decode

func (d *Decoder) Decode(data []byte, opts ...Option) ([]*Point, error)

func (*Decoder) DetailedError

func (d *Decoder) DetailedError() error

type DecoderOption

type DecoderOption func(e *Decoder)

func WithDecEasyproto added in v1.1.12

func WithDecEasyproto(on bool) DecoderOption

func WithDecEncoding

func WithDecEncoding(enc Encoding) DecoderOption

func WithDecFn

func WithDecFn(fn DecodeFn) DecoderOption

type EncodeFn

type EncodeFn func(batchSize int, payload []byte) error

EncodeFn used to iterate on []*Point payload, if error returned, the iterate terminated.

type Encoder

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

func GetEncoder

func GetEncoder(opts ...EncoderOption) *Encoder

func (*Encoder) Encode

func (e *Encoder) Encode(pts []*Point) ([][]byte, error)

Encode get bytes form of multiple Points, often used to Write to somewhere(file/network/...), batchSize used to split huge points into multiple part. Set batchSize to 0 to disable the split.

func (*Encoder) EncodeV2 added in v1.1.12

func (e *Encoder) EncodeV2(pts []*Point)

func (*Encoder) LastErr added in v1.1.12

func (e *Encoder) LastErr() error

func (*Encoder) Next added in v1.1.12

func (e *Encoder) Next(buf []byte) ([]byte, bool)

func (*Encoder) String added in v1.1.12

func (e *Encoder) String() string

type EncoderOption

type EncoderOption func(e *Encoder)

func WithEncBatchBytes added in v0.1.6

func WithEncBatchBytes(bytes int) EncoderOption

func WithEncBatchSize

func WithEncBatchSize(size int) EncoderOption

func WithEncEncoding

func WithEncEncoding(enc Encoding) EncoderOption

func WithEncFn

func WithEncFn(fn EncodeFn) EncoderOption

type Encoding

type Encoding int
const (
	LineProtocol Encoding = iota
	Protobuf
	JSON
)

func EncodingStr

func EncodingStr(s string) Encoding

EncodingStr convert encoding-string in configure file to encoding enum.

Here v1/v2 are alias for lineprotocol and protobuf, this makes people easy to switch between lineprotocol and protobuf. For json, you should not configure json encoding in production environments(json do not classify int and float).

func HTTPContentType added in v0.1.5

func HTTPContentType(ct string) Encoding

func (Encoding) HTTPContentType added in v0.1.5

func (e Encoding) HTTPContentType() string

func (Encoding) String added in v0.1.5

func (e Encoding) String() string

type Field

type Field struct {
	Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
	// See https://developers.google.com/protocol-buffers/docs/proto3#json
	//
	// Types that are valid to be assigned to Val:
	//	*Field_I
	//	*Field_U
	//	*Field_F
	//	*Field_B
	//	*Field_D
	//	*Field_S
	//	*Field_A
	Val   isField_Val `protobuf_oneof:"val"`
	IsTag bool        `protobuf:"varint,8,opt,name=is_tag,proto3" json:"is_tag,omitempty"`
	Type  MetricType  `protobuf:"varint,9,opt,name=type,proto3,enum=point.MetricType" json:"type,omitempty"`
	// field unit name
	Unit string `protobuf:"bytes,10,opt,name=unit,proto3" json:"unit,omitempty"`
}

func NewKV

func NewKV(k string, v any, opts ...KVOption) *Field

NewKV get kv on specified key and value.

func (*Field) Descriptor

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

func (*Field) Equal added in v1.1.12

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

func (*Field) GetA

func (m *Field) GetA() *types.Any

func (*Field) GetB

func (m *Field) GetB() bool

func (*Field) GetD

func (m *Field) GetD() []byte

func (*Field) GetF

func (m *Field) GetF() float64

func (*Field) GetI

func (m *Field) GetI() int64

func (*Field) GetIsTag

func (m *Field) GetIsTag() bool

func (*Field) GetKey

func (m *Field) GetKey() string

func (*Field) GetS added in v0.1.6

func (m *Field) GetS() string

func (*Field) GetType

func (m *Field) GetType() MetricType

func (*Field) GetU

func (m *Field) GetU() uint64

func (*Field) GetUnit

func (m *Field) GetUnit() string

func (*Field) GetVal

func (m *Field) GetVal() isField_Val

func (*Field) GoString added in v1.1.12

func (this *Field) GoString() string

func (*Field) Marshal added in v1.1.12

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

func (*Field) MarshalTo added in v1.1.12

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

func (*Field) MarshalToSizedBuffer added in v1.1.12

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

func (*Field) ProtoMessage

func (*Field) ProtoMessage()

func (*Field) Raw added in v0.1.6

func (kv *Field) Raw() any

Raw return underlying raw data.

func (*Field) Reset

func (m *Field) Reset()

func (*Field) Size added in v1.1.12

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

func (*Field) String

func (this *Field) String() string

func (*Field) Unmarshal added in v1.1.12

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

func (*Field) XXX_DiscardUnknown added in v1.1.12

func (m *Field) XXX_DiscardUnknown()

func (*Field) XXX_Marshal added in v1.1.12

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

func (*Field) XXX_Merge added in v1.1.12

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

func (*Field) XXX_OneofWrappers added in v1.1.12

func (*Field) XXX_OneofWrappers() []interface{}

XXX_OneofWrappers is for the internal use of the proto package.

func (*Field) XXX_Size added in v1.1.12

func (m *Field) XXX_Size() int

func (*Field) XXX_Unmarshal added in v1.1.12

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

type Field_A

type Field_A struct {
	A *types.Any `protobuf:"bytes,7,opt,name=a,proto3,oneof" json:"a,omitempty"`
}

func (*Field_A) Equal added in v1.1.12

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

func (*Field_A) GoString added in v1.1.12

func (this *Field_A) GoString() string

func (*Field_A) MarshalTo added in v1.1.12

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

func (*Field_A) MarshalToSizedBuffer added in v1.1.12

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

func (*Field_A) Size added in v1.1.12

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

func (*Field_A) String added in v1.1.12

func (this *Field_A) String() string

type Field_B

type Field_B struct {
	B bool `protobuf:"varint,5,opt,name=b,proto3,oneof" json:"b,omitempty"`
}

func (*Field_B) Equal added in v1.1.12

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

func (*Field_B) GoString added in v1.1.12

func (this *Field_B) GoString() string

func (*Field_B) MarshalTo added in v1.1.12

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

func (*Field_B) MarshalToSizedBuffer added in v1.1.12

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

func (*Field_B) Size added in v1.1.12

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

func (*Field_B) String added in v1.1.12

func (this *Field_B) String() string

type Field_D

type Field_D struct {
	D []byte `protobuf:"bytes,6,opt,name=d,proto3,oneof" json:"d,omitempty"`
}

func (*Field_D) Equal added in v1.1.12

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

func (*Field_D) GoString added in v1.1.12

func (this *Field_D) GoString() string

func (*Field_D) MarshalTo added in v1.1.12

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

func (*Field_D) MarshalToSizedBuffer added in v1.1.12

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

func (*Field_D) Size added in v1.1.12

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

func (*Field_D) String added in v1.1.12

func (this *Field_D) String() string

type Field_F

type Field_F struct {
	F float64 `protobuf:"fixed64,4,opt,name=f,proto3,oneof" json:"f,omitempty"`
}

func (*Field_F) Equal added in v1.1.12

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

func (*Field_F) GoString added in v1.1.12

func (this *Field_F) GoString() string

func (*Field_F) MarshalTo added in v1.1.12

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

func (*Field_F) MarshalToSizedBuffer added in v1.1.12

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

func (*Field_F) Size added in v1.1.12

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

func (*Field_F) String added in v1.1.12

func (this *Field_F) String() string

type Field_I

type Field_I struct {
	I int64 `protobuf:"varint,2,opt,name=i,proto3,oneof" json:"i,omitempty"`
}

func (*Field_I) Equal added in v1.1.12

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

func (*Field_I) GoString added in v1.1.12

func (this *Field_I) GoString() string

func (*Field_I) MarshalTo added in v1.1.12

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

func (*Field_I) MarshalToSizedBuffer added in v1.1.12

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

func (*Field_I) Size added in v1.1.12

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

func (*Field_I) String added in v1.1.12

func (this *Field_I) String() string

type Field_S added in v0.1.6

type Field_S struct {
	S string `protobuf:"bytes,11,opt,name=s,proto3,oneof" json:"s,omitempty"`
}

func (*Field_S) Equal added in v1.1.12

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

func (*Field_S) GoString added in v1.1.12

func (this *Field_S) GoString() string

func (*Field_S) MarshalTo added in v1.1.12

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

func (*Field_S) MarshalToSizedBuffer added in v1.1.12

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

func (*Field_S) Size added in v1.1.12

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

func (*Field_S) String added in v1.1.12

func (this *Field_S) String() string

type Field_U

type Field_U struct {
	U uint64 `protobuf:"varint,3,opt,name=u,proto3,oneof" json:"u,omitempty"`
}

func (*Field_U) Equal added in v1.1.12

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

func (*Field_U) GoString added in v1.1.12

func (this *Field_U) GoString() string

func (*Field_U) MarshalTo added in v1.1.12

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

func (*Field_U) MarshalToSizedBuffer added in v1.1.12

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

func (*Field_U) Size added in v1.1.12

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

func (*Field_U) String added in v1.1.12

func (this *Field_U) String() string

type JSONPoint

type JSONPoint struct {
	// Requride
	Measurement string `json:"measurement"`

	// Optional
	Tags map[string]string `json:"tags,omitempty"`

	// Requride
	Fields map[string]interface{} `json:"fields"`

	// Unix nanosecond
	Time int64 `json:"time,omitempty"`
}

func (*JSONPoint) Point

func (jp *JSONPoint) Point(opts ...Option) (*Point, error)

type KVOption

type KVOption func(kv *Field)

func WithKVTagSet

func WithKVTagSet(on bool) KVOption

func WithKVType

func WithKVType(t MetricType) KVOption

WithKVType set field type(count/gauge/rate).

func WithKVUnit

func WithKVUnit(u string) KVOption

WithKVUnit set value's unit.

type KVs

type KVs []*Field

func NewKVs

func NewKVs(kvs map[string]interface{}) (res KVs)

NewKVs create kvs slice from map structure.

func NewTags

func NewTags(tags map[string]string) (arr KVs)

NewTags create tag kvs from map structure.

func (KVs) Add

func (x KVs) Add(k string, v any, isTag, force bool) KVs

Add add new field. Deprecated: use AddV2 If force enabled, overwrite exist key.

func (KVs) AddKV

func (x KVs) AddKV(kv *Field, force bool) KVs

func (KVs) AddTag

func (x KVs) AddTag(k, v string) KVs

func (KVs) AddV2 added in v1.1.12

func (x KVs) AddV2(k string, v any, force bool, opts ...KVOption) KVs

AddV2 add new field with opts. If force enabled, overwrite exist key.

func (KVs) Del

func (x KVs) Del(k string) KVs

Del delete field from x with Key == k.

func (KVs) FieldCount

func (x KVs) FieldCount() (i int)

func (KVs) Fields

func (x KVs) Fields() (arr KVs)

func (KVs) Get

func (x KVs) Get(k string) *Field

Get get k's value, if k not exist, return nil.

func (KVs) GetTag

func (x KVs) GetTag(k string) string

GetTag get tag k's value, if the tag not exist, return nil.

func (KVs) Has

func (x KVs) Has(k string) bool

Has test if k exist.

func (KVs) InfluxFields

func (x KVs) InfluxFields() map[string]any

InfluxFields convert KVs to map structure.

func (KVs) InfluxTags

func (x KVs) InfluxTags() (res influxm.Tags)

InfluxTags convert tag KVs to map structure.

func (KVs) Keys

func (x KVs) Keys() *Keys

Keys get k's value, if k not exist, return nil.

func (KVs) Len

func (x KVs) Len() int

func (KVs) Less

func (x KVs) Less(i, j int) bool

func (KVs) MustAddKV

func (x KVs) MustAddKV(kv *Field) KVs

func (KVs) MustAddTag

func (x KVs) MustAddTag(k, v string) KVs

func (KVs) Pretty

func (x KVs) Pretty() string

func (KVs) Reset added in v1.1.12

func (x KVs) Reset()

Reset reset but drop value.

func (KVs) ResetFull added in v1.1.12

func (x KVs) ResetFull()

ResetFull reset and reuse key-value.

func (KVs) Swap

func (x KVs) Swap(i, j int)

func (KVs) TagCount

func (x KVs) TagCount() (i int)

func (KVs) Tags

func (x KVs) Tags() (arr KVs)

func (KVs) TrimFields

func (x KVs) TrimFields(n int) (arr KVs)

TrimFields keep max-n field kvs and drop the rest.

func (KVs) TrimTags

func (x KVs) TrimTags(n int) (arr KVs)

TrimTags keep max-n tag kvs.

type Key

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

Key is the key-name and it's type composite.

func KVKey

func KVKey(kv *Field) *Key

func NewKey

func NewKey(k string, t KeyType, defaultVal ...any) *Key

NewKey create Key.

func NewTagKey

func NewTagKey(k string, defaultVal string) *Key

NewTagKey create tag key with type string.

func (*Key) Default

func (k *Key) Default() any

Default get key's default value.

func (*Key) Key

func (k *Key) Key() string

Key get key-name.

func (*Key) Type

func (k *Key) Type() KeyType

Type get key-type.

type KeyType

type KeyType int32
const (
	X   KeyType = 0
	I   KeyType = 1
	U   KeyType = 2
	F   KeyType = 3
	B   KeyType = 4
	D   KeyType = 5
	NIL KeyType = 6
	S   KeyType = 7
	A   KeyType = 8
)

func PBType

func PBType(v isField_Val) KeyType

func (KeyType) EnumDescriptor

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

func (KeyType) String

func (x KeyType) String() string

type Keys

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

Keys is sorted Keys.

func (*Keys) Add

func (x *Keys) Add(k *Key)

Add add specific k. if key & type exist, do nothing.

func (*Keys) Del

func (x *Keys) Del(k *Key)

Del remove specific k.

func (*Keys) Has

func (x *Keys) Has(k *Key) bool

Has test if k exist.

func (*Keys) Hash

func (x *Keys) Hash() uint64

Hash calculate x's hash.

func (*Keys) Len

func (x *Keys) Len() int

func (*Keys) Less

func (x *Keys) Less(i, j int) bool

func (*Keys) Pretty

func (x *Keys) Pretty() string

Pretty get pretty showing of all keys.

func (*Keys) Swap

func (x *Keys) Swap(i, j int)

type Map added in v0.1.6

type Map struct {
	Map map[string]*BasicTypes `` /* 147-byte string literal not displayed */
}

func MustNewMap added in v0.1.6

func MustNewMap(ents map[string]any) *Map

MustNewMap create map value that can be used in point field, and panic if any error.

func NewMap added in v0.1.6

func NewMap(ents map[string]any) (dict *Map, err error)

NewMap create map value that can be used in point field.

func (*Map) Descriptor added in v0.1.6

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

func (*Map) Equal added in v1.1.12

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

func (*Map) GetMap added in v0.1.6

func (m *Map) GetMap() map[string]*BasicTypes

func (*Map) GoString added in v1.1.12

func (this *Map) GoString() string

func (*Map) Marshal added in v1.1.12

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

func (*Map) MarshalTo added in v1.1.12

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

func (*Map) MarshalToSizedBuffer added in v1.1.12

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

func (*Map) ProtoMessage added in v0.1.6

func (*Map) ProtoMessage()

func (*Map) Reset added in v0.1.6

func (m *Map) Reset()

func (*Map) Size added in v1.1.12

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

func (*Map) String added in v0.1.6

func (this *Map) String() string

func (*Map) Unmarshal added in v1.1.12

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

func (*Map) XXX_DiscardUnknown added in v1.1.12

func (m *Map) XXX_DiscardUnknown()

func (*Map) XXX_Marshal added in v1.1.12

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

func (*Map) XXX_Merge added in v1.1.12

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

func (*Map) XXX_Size added in v1.1.12

func (m *Map) XXX_Size() int

func (*Map) XXX_Unmarshal added in v1.1.12

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

type MetricType

type MetricType int32
const (
	UNSPECIFIED MetricType = 0
	COUNT       MetricType = 1
	RATE        MetricType = 2
	GAUGE       MetricType = 3
)

func (MetricType) EnumDescriptor

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

func (MetricType) String

func (x MetricType) String() string

type Option

type Option func(*cfg)

func CommonLoggingOptions added in v0.1.1

func CommonLoggingOptions() []Option

CommonLoggingOptions defined options on RUM/Tracing/Security/Event/Profile/Network point.

func DefaultLoggingOptions

func DefaultLoggingOptions() []Option

DefaultLoggingOptions defined options on Logging point.

func DefaultMetricOptions

func DefaultMetricOptions() []Option

DefaultMetricOptions defined options on Metric point.

func DefaultMetricOptionsForInflux1X

func DefaultMetricOptionsForInflux1X() []Option

DefaultMetricOptionsForInflux1X get influxdb 1.x options. For influxdb 1.x, uint64 not support.

func DefaultObjectOptions

func DefaultObjectOptions() []Option

DefaultObjectOptions defined options on Object/CustomObject point.

func WithCallback

func WithCallback(fn Callback) Option

func WithDisabledKeys

func WithDisabledKeys(keys ...*Key) Option

func WithDotInKey

func WithDotInKey(on bool) Option

func WithEncoding

func WithEncoding(enc Encoding) Option

func WithExtraTags

func WithExtraTags(tags map[string]string) Option

func WithKeySorted added in v0.1.6

func WithKeySorted(on bool) Option

func WithMaxFieldKeyLen

func WithMaxFieldKeyLen(n int) Option

func WithMaxFieldValLen

func WithMaxFieldValLen(n int) Option

func WithMaxFields

func WithMaxFields(n int) Option

func WithMaxKVComposeLen

func WithMaxKVComposeLen(n int) Option

func WithMaxMeasurementLen

func WithMaxMeasurementLen(n int) Option

func WithMaxTagKeyLen

func WithMaxTagKeyLen(n int) Option

func WithMaxTagValLen

func WithMaxTagValLen(n int) Option

func WithMaxTags

func WithMaxTags(n int) Option

func WithPrecheck

func WithPrecheck(on bool) Option

func WithPrecision

func WithPrecision(p Precision) Option

func WithRequiredKeys

func WithRequiredKeys(keys ...*Key) Option

func WithStrField

func WithStrField(on bool) Option

func WithTime

func WithTime(t time.Time) Option

func WithTimestamp added in v1.1.12

func WithTimestamp(ts int64) Option

func WithU64Field

func WithU64Field(on bool) Option

type PBPoint

type PBPoint struct {
	Name   string   `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	Fields []*Field `protobuf:"bytes,2,rep,name=fields,proto3" json:"fields,omitempty"`
	Time   int64    `protobuf:"varint,3,opt,name=time,proto3" json:"time,omitempty"`
	// Auxiliary fields for the point, they should not
	// write to the final storage on production.
	Warns  []*Warn  `protobuf:"bytes,4,rep,name=warns,proto3" json:"warns,omitempty"`
	Debugs []*Debug `protobuf:"bytes,5,rep,name=debugs,proto3" json:"debugs,omitempty"`
}

func (*PBPoint) Descriptor

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

func (*PBPoint) Equal added in v1.1.12

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

func (*PBPoint) GetDebugs

func (m *PBPoint) GetDebugs() []*Debug

func (*PBPoint) GetFields

func (m *PBPoint) GetFields() []*Field

func (*PBPoint) GetName

func (m *PBPoint) GetName() string

func (*PBPoint) GetTime

func (m *PBPoint) GetTime() int64

func (*PBPoint) GetWarns

func (m *PBPoint) GetWarns() []*Warn

func (*PBPoint) GoString added in v1.1.12

func (this *PBPoint) GoString() string

func (*PBPoint) Marshal added in v1.1.12

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

func (*PBPoint) MarshalTo added in v1.1.12

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

func (*PBPoint) MarshalToSizedBuffer added in v1.1.12

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

func (*PBPoint) ProtoMessage

func (*PBPoint) ProtoMessage()

func (*PBPoint) Reset

func (m *PBPoint) Reset()

func (*PBPoint) Size added in v1.1.12

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

func (*PBPoint) String

func (this *PBPoint) String() string

func (*PBPoint) Unmarshal added in v1.1.12

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

func (*PBPoint) XXX_DiscardUnknown added in v1.1.12

func (m *PBPoint) XXX_DiscardUnknown()

func (*PBPoint) XXX_Marshal added in v1.1.12

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

func (*PBPoint) XXX_Merge added in v1.1.12

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

func (*PBPoint) XXX_Size added in v1.1.12

func (m *PBPoint) XXX_Size() int

func (*PBPoint) XXX_Unmarshal added in v1.1.12

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

type PBPoints

type PBPoints struct {
	Arr []*PBPoint `protobuf:"bytes,1,rep,name=arr,proto3" json:"arr,omitempty"`
}

batch of pbpoint.

func RandPBPoints

func RandPBPoints(count int) *PBPoints

RandPBPoints deprecated.

func (*PBPoints) Descriptor

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

func (*PBPoints) Equal added in v1.1.12

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

func (*PBPoints) GetArr

func (m *PBPoints) GetArr() []*PBPoint

func (*PBPoints) GoString added in v1.1.12

func (this *PBPoints) GoString() string

func (*PBPoints) Marshal added in v1.1.12

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

func (*PBPoints) MarshalTo added in v1.1.12

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

func (*PBPoints) MarshalToSizedBuffer added in v1.1.12

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

func (*PBPoints) ProtoMessage

func (*PBPoints) ProtoMessage()

func (*PBPoints) Reset

func (m *PBPoints) Reset()

func (*PBPoints) Size added in v1.1.12

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

func (*PBPoints) String

func (this *PBPoints) String() string

func (*PBPoints) Unmarshal added in v1.1.12

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

func (*PBPoints) XXX_DiscardUnknown added in v1.1.12

func (m *PBPoints) XXX_DiscardUnknown()

func (*PBPoints) XXX_Marshal added in v1.1.12

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

func (*PBPoints) XXX_Merge added in v1.1.12

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

func (*PBPoints) XXX_Size added in v1.1.12

func (m *PBPoints) XXX_Size() int

func (*PBPoints) XXX_Unmarshal added in v1.1.12

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

type Point

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

func CheckPoints added in v1.1.12

func CheckPoints(pts []*Point, opts ...Option) (arr []*Point)

CheckPoints used to check pts on various opts.

func FromJSONPoint

func FromJSONPoint(j *JSONPoint) *Point

func FromModelsLP

func FromModelsLP(lp influxm.Point) *Point

func FromPB

func FromPB(pb *PBPoint) *Point

func FromPBJson

func FromPBJson(j []byte) (*Point, error)

func GatherPoints added in v1.1.12

func GatherPoints(reg prometheus.Gatherer) ([]*Point, error)

GatherPoints gather all metrics in global registry, but convert these metrics to Point.

func MustFromPBJson

func MustFromPBJson(j []byte) *Point

func NewLPPoint

func NewLPPoint(lp influxm.Point) *Point

NewLPPoint create Point based on a lineproto point.

func NewPoint deprecated

func NewPoint(name string, tags map[string]string, fields map[string]any, opts ...Option) (*Point, error)

NewPoint returns a new Point given name(measurement), tags, fields and optional options.

If fields empty(or nil), error ErrNoField will returned.

Values in fields only allowed for int/uint(8-bit/16-bit/32-bit/64-bit), string, bool, float(32-bit/64-bit) and []byte, other types are ignored.

Deprecated: use NewPointV2.

func NewPointV2

func NewPointV2(name string, kvs KVs, opts ...Option) *Point

func RandPoints

func RandPoints(count int) []*Point

RandPoints deprecated.

func WrapPoint

func WrapPoint(pts []influxm.Point) (arr []*Point)

WrapPoint wrap lagacy line-protocol point into Point.

func (*Point) Add

func (p *Point) Add(k string, v any)

Add add specific key value to fields, if k exist, do nothing.

func (*Point) AddDebug

func (p *Point) AddDebug(d *Debug)

func (*Point) AddKVs added in v1.1.12

func (p *Point) AddKVs(kvs ...*Field)

AddKVs add(shallow-copy) kvs, if keys exist, do nothing.

func (*Point) AddTag

func (p *Point) AddTag(k, v string)

AddTag add specific key value to fields, if k exist, do nothing.

func (*Point) ClearFlag

func (p *Point) ClearFlag(f uint64)

ClearFlag clear specific bit.

func (*Point) CopyField added in v1.1.12

func (p *Point) CopyField(kvs ...*Field)

CopyField deep-copy field kvs, if keys exist, do nothing.

func (*Point) CopyTags added in v1.1.12

func (p *Point) CopyTags(kvs ...*Field)

CopyTags deep-copy tag kvs, if keys exist, do nothing.

func (*Point) Del

func (p *Point) Del(k string)

Del delete specific key from tags/fields.

func (*Point) Equal

func (p *Point) Equal(x *Point) bool

Equal test if two point are the same. Equality test NOT check on warns and debugs. If two points equal, they have the same ID(MD5/Sha256), but same ID do not means they are equal.

func (*Point) EqualWithReason

func (p *Point) EqualWithReason(x *Point) (bool, string)

func (*Point) Fields

func (p *Point) Fields() (arr KVs)

Fields return point's key-values except tags.

func (*Point) Get

func (p *Point) Get(k string) any

Get get specific key from point.

func (*Point) GetTag

func (p *Point) GetTag(k string) string

GetTag get value of tag k. If key k not tag or k not eixst, return nil.

func (*Point) HasFlag

func (p *Point) HasFlag(f uint) bool

HasFlag test if specific bit set.

func (*Point) InfluxFields

func (p *Point) InfluxFields() map[string]any

InfluxFields convert fields to map structure.

func (*Point) InfluxTags

func (p *Point) InfluxTags() influxm.Tags

InfluxTags convert tags to map structure.

func (*Point) KVMap added in v0.1.6

func (p *Point) KVMap() map[string]any

KVMap return all key-value in map.

func (*Point) KVs

func (p *Point) KVs() (arr KVs)

KVs return point's all key-values.

func (*Point) Keys

func (p *Point) Keys() *Keys

Keys get points all keys.

func (*Point) LPPoint

func (p *Point) LPPoint() (influxm.Point, error)

LPPoint get line-protocol part of the point.

func (*Point) LPSize

func (p *Point) LPSize() int

LPSize get point line-protocol size.

func (*Point) LineProto

func (p *Point) LineProto(prec ...Precision) string

LineProto convert point to text lineprotocol(both for lineproto point and protobuf point).

func (*Point) MD5

func (p *Point) MD5() string

MD5 get point MD5 id.

func (*Point) MapTags added in v0.1.6

func (p *Point) MapTags() map[string]string

MapTags convert all key-value to map.

func (*Point) MarshalJSON

func (p *Point) MarshalJSON() ([]byte, error)

MarshalJSON to protobuf json.

func (*Point) MustAdd

func (p *Point) MustAdd(k string, v any)

MustAdd add specific key value to fields, if k exist, override it.

func (*Point) MustAddKVs added in v1.1.12

func (p *Point) MustAddKVs(kvs ...*Field)

MustAddKVs add kv, if the key exist, override it.

func (*Point) MustAddTag

func (p *Point) MustAddTag(k, v string)

MustAddTag add specific key value to fields, if k exist, override it.

func (*Point) MustLPPoint added in v0.1.6

func (p *Point) MustLPPoint() influxm.Point

func (*Point) Name

func (p *Point) Name() string

Name return point's measurement name.

func (*Point) PBJson

func (p *Point) PBJson() ([]byte, error)

func (*Point) PBJsonPretty

func (p *Point) PBJsonPretty() ([]byte, error)

func (*Point) PBPoint

func (p *Point) PBPoint() *PBPoint

PBPoint create Point based on a protobuf point.

func (*Point) PBSize

func (p *Point) PBSize() int

PBSize get point protobuf size.

func (*Point) Pretty

func (p *Point) Pretty() string

Pretty get string representation of point, all key-valus will be sorted in output.

func (*Point) Reset added in v1.1.12

func (p *Point) Reset()

func (*Point) SetFlag

func (p *Point) SetFlag(f uint)

SetFlag set specific bit.

func (*Point) SetKVs added in v1.1.12

func (p *Point) SetKVs(kvs ...*Field)

SetKVs set kvs as p's new KVs.

func (*Point) SetName

func (p *Point) SetName(name string)

func (*Point) SetTime

func (p *Point) SetTime(t time.Time)

func (*Point) Sha256

func (p *Point) Sha256() string

Sha256 get point Sha256 id.

func (*Point) Size

func (p *Point) Size() int

Size get underling data size in byte(exclude warning/debug info).

func (*Point) Tags

func (p *Point) Tags() (arr KVs)

Tags return point's key-values except fields.

func (*Point) Time

func (p *Point) Time() time.Time

Time return point's time.

func (*Point) TimeSeriesHash added in v0.1.8

func (p *Point) TimeSeriesHash() []string

func (*Point) UnmarshalJSON

func (p *Point) UnmarshalJSON(j []byte) error

UnmarshalJSON unmarshal protobuf json.

func (*Point) Warns

func (p *Point) Warns() []*Warn

Warns return warnning info when build the point.

func (*Point) WarnsPretty added in v0.1.6

func (p *Point) WarnsPretty() string

WarnsPretty return human readable warnning info.

type PointPool added in v1.1.12

type PointPool interface {
	Get() *Point
	Put(*Point)

	GetKV(k string, v any) *Field
	PutKV(f *Field)

	String() string

	// For prometheus metrics.
	p8s.Collector
}

func NewPointPoolLevel1 added in v1.1.12

func NewPointPoolLevel1() PointPool

NewPointPoolLevel1 get point pool that only cache point but it's key-valus.

func NewPointPoolLevel2 added in v1.1.12

func NewPointPoolLevel2() PointPool

NewPointPoolLevel2 get point cache that cache all but drop Field's Val.

func NewPointPoolLevel3 added in v1.1.12

func NewPointPoolLevel3() PointPool

NewPointPoolLevel3 cache everything within point.

func NewReservedCapPointPool added in v1.1.12

func NewReservedCapPointPool(capacity int64) PointPool

type Points added in v1.1.12

type Points []*Point

type Precision

type Precision int
const (
	PrecNS Precision = iota // nano-second
	PrecUS                  // micro-second
	PrecMS                  // milli-second
	PrecS                   // second
	PrecM                   // minute
	PrecH                   // hour
	PrecD                   // day
	PrecW                   // week
)

func PrecStr

func PrecStr(s string) Precision

func (Precision) String

func (p Precision) String() string

type RandOption

type RandOption func(*ptRander)

func WithCategory

func WithCategory(c Category) RandOption

func WithFixedKeys

func WithFixedKeys(on bool) RandOption

func WithFixedTags

func WithFixedTags(on bool) RandOption

func WithKVSorted added in v0.1.6

func WithKVSorted(on bool) RandOption

func WithRandFields

func WithRandFields(n int) RandOption

func WithRandKeyLen

func WithRandKeyLen(n int) RandOption

func WithRandMeasurementPrefix

func WithRandMeasurementPrefix(s string) RandOption

func WithRandPB

func WithRandPB(on bool) RandOption

func WithRandPointPool added in v1.1.12

func WithRandPointPool(pp PointPool) RandOption

func WithRandSampleText added in v1.1.12

func WithRandSampleText(st []string) RandOption

func WithRandStringValues added in v1.1.12

func WithRandStringValues(on bool) RandOption

func WithRandTags

func WithRandTags(n int) RandOption

func WithRandText

func WithRandText(n int) RandOption

func WithRandTime

func WithRandTime(t time.Time) RandOption

func WithRandValLen

func WithRandValLen(n int) RandOption

type ReservedCapPointPool added in v1.1.12

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

func (*ReservedCapPointPool) Collect added in v1.1.12

func (cpp *ReservedCapPointPool) Collect(ch chan<- p8s.Metric)

func (*ReservedCapPointPool) Describe added in v1.1.12

func (cpp *ReservedCapPointPool) Describe(ch chan<- *p8s.Desc)

func (*ReservedCapPointPool) Get added in v1.1.12

func (cpp *ReservedCapPointPool) Get() *Point

func (*ReservedCapPointPool) GetKV added in v1.1.12

func (cpp *ReservedCapPointPool) GetKV(k string, v any) *Field

func (*ReservedCapPointPool) Put added in v1.1.12

func (cpp *ReservedCapPointPool) Put(p *Point)

func (*ReservedCapPointPool) PutKV added in v1.1.12

func (cpp *ReservedCapPointPool) PutKV(f *Field)

func (*ReservedCapPointPool) String added in v1.1.12

func (cpp *ReservedCapPointPool) String() string

type Warn

type Warn struct {
	Type string `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"`
	Msg  string `protobuf:"bytes,2,opt,name=msg,json=message,proto3" json:"msg,omitempty"`
}

Warn used to attach some warning message during building the point.

func (*Warn) Descriptor

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

func (*Warn) Equal added in v1.1.12

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

func (*Warn) GetMsg

func (m *Warn) GetMsg() string

func (*Warn) GetType

func (m *Warn) GetType() string

func (*Warn) GoString added in v1.1.12

func (this *Warn) GoString() string

func (*Warn) Marshal added in v1.1.12

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

func (*Warn) MarshalTo added in v1.1.12

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

func (*Warn) MarshalToSizedBuffer added in v1.1.12

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

func (*Warn) ProtoMessage

func (*Warn) ProtoMessage()

func (*Warn) Reset

func (m *Warn) Reset()

func (*Warn) Size added in v1.1.12

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

func (*Warn) String

func (this *Warn) String() string

func (*Warn) Unmarshal added in v1.1.12

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

func (*Warn) XXX_DiscardUnknown added in v1.1.12

func (m *Warn) XXX_DiscardUnknown()

func (*Warn) XXX_Marshal added in v1.1.12

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

func (*Warn) XXX_Merge added in v1.1.12

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

func (*Warn) XXX_Size added in v1.1.12

func (m *Warn) XXX_Size() int

func (*Warn) XXX_Unmarshal added in v1.1.12

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

Directories

Path Synopsis
Package main used for GC escape:
Package main used for GC escape:

Jump to

Keyboard shortcuts

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