point

package
v2.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2026 License: MIT Imports: 32 Imported by: 0

README

DataKit 采集的数据结构定义

Point

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

  1. 行协议
  2. Protobuf

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

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

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

$ 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/encode-json
BenchmarkEncode/encode-json-10         	      97	  10421921 ns/op	 7656217 B/op	   60287 allocs/op
BenchmarkEncode/encode-lp
BenchmarkEncode/encode-lp-10           	     243	   4906325 ns/op	 8676728 B/op	   41045 allocs/op
BenchmarkEncode/v1-encode-pb
BenchmarkEncode/v1-encode-pb-10        	    2685	    431512 ns/op	 1115020 B/op	      16 allocs/op
BenchmarkEncode/v2-encode-pb-PBSize()
BenchmarkEncode/v2-encode-pb-PBSize()-10         	    2158	    549952 ns/op	      17 B/op	       0 allocs/op
BenchmarkEncode/v2-encode-pb-Size()
BenchmarkEncode/v2-encode-pb-Size()-10           	    3211	    368438 ns/op	       5 B/op	       0 allocs/op
BenchmarkEncode/v2-encode-lp
BenchmarkEncode/v2-encode-lp-10                  	     268	   4411220 ns/op	 5260352 B/op	   39069 allocs/op
PASS
ok  	github.com/GuanceCloud/cliutils/point	8.625s

v2 的 encode 效率比 v1 要慢一些(~0.80X),因为在编码过程中要实时计算 point 的大小(目的是不超过总 buffer 大小)。但如果只是错略计算大小,则比 v1 (v1 内部要动态分配内存)要快一些(~1.17X)。

Point 的约束

Point 构建函数:

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

由于 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
	ObjectChange
	CustomObject
	Logging
	Tracing
	RUM
	Security
	Profiling
	DialTesting
	ExecutionLog
	LLM
	AgentLLM

	SUnknownCategory   = "unknown"
	SDynamicDWCategory = "dynamic_dw" // NOTE: not used
	SMetric            = "metric"
	SMetricDeprecated  = "metrics"
	SNetwork           = "network"
	SKeyEvent          = "keyevent"
	SObject            = "object"
	SObjectChange      = "object_change"
	SCustomObject      = "custom_object"
	SLogging           = "logging"
	STracing           = "tracing"
	SRUM               = "rum"
	SSecurity          = "security"
	SProfiling         = "profiling"
	SDialTesting       = "dialtesting"
	SExecutionLog      = "execution_log"
	SLlm               = "llm"
	SAgentLLM          = "agent_llm"

	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"
	URLObjectChange      = "/v1/write/object_change"
	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"
	URLDialTesting       = "/v1/write/dialtesting" // NOTE: not used
	URLExecutionLog      = "/v1/write/siem_logging"
	URLLlm               = "/v1/write/langfuse-v2"
	URLAgentLLM          = "/v1/write/agent_llm"

	CUnknown   = "UNKNOWN"
	CDynamicDW = "DYNAMIC_DW"
	CM         = "M"
	CN         = "N"
	CE         = "E"
	CO         = "O"
	COCH       = "OCH"
	CCO        = "CO"
	CL         = "L"
	CT         = "T"
	CR         = "R"
	CS         = "S"
	CP         = "P"
	CDT        = "DT"
	CEL        = "EL"
	CLlm       = "LLM"
	CAgentLLM  = "AL"
)
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"
	WarnInfConvertToMaxValue  = "convert_inf_to_max_value"
	WarnInfConvertToMinValue  = "convert_inf_to_min_value"
	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"
	WarnNROrTailEscape  = "found_new_line_or_tail_espace"
	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

)
View Source
const (
	DefaultLoggingStatus = "info"
)

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",
	10: "SUM_DELTA",
	11: "SUM_CUMULATIVE",
	12: "SUMMARY_COUNT",
	13: "SUMMARY_SUM",
	14: "SUMMARY_QUANTILE",
	20: "HISTOGRAM_MAX",
	21: "HISTOGRAM_MIN",
	22: "HISTOGRAM_COUNT",
	23: "HISTOGRAM_SUM",
	24: "HISTOGRAM_BUCKET_COUNTS",
	25: "HISTOGRAM_BUCKET_BOUNDS",
	30: "EXPONENTIAL_HISTOGRAM_MAX",
	31: "EXPONENTIAL_HISTOGRAM_MIN",
	32: "EXPONENTIAL_HISTOGRAM_COUNT",
	33: "EXPONENTIAL_HISTOGRAM_SUM",
	34: "EXPONENTIAL_HISTOGRAM_AVG",
	35: "EXPONENTIAL_HISTOGRAM_SCALE",
	36: "EXPONENTIAL_HISTOGRAM_ZERO_COUNT",
	37: "EXPONENTIAL_HISTOGRAM_POS_OFFSET",
	38: "EXPONENTIAL_HISTOGRAM_POS_BUCKET_COUNTS",
	39: "EXPONENTIAL_HISTOGRAM_NEG_OFFSET",
	40: "EXPONENTIAL_HISTOGRAM_NEG_BUCKET_COUNTS",
	41: "EXPONENTIAL_HISTOGRAM_FLAGS",
	42: "EXPONENTIAL_HISTOGRAM_START_TIME",
}
View Source
var MetricType_value = map[string]int32{
	"UNSPECIFIED":                             0,
	"COUNT":                                   1,
	"RATE":                                    2,
	"GAUGE":                                   3,
	"SUM_DELTA":                               10,
	"SUM_CUMULATIVE":                          11,
	"SUMMARY_COUNT":                           12,
	"SUMMARY_SUM":                             13,
	"SUMMARY_QUANTILE":                        14,
	"HISTOGRAM_MAX":                           20,
	"HISTOGRAM_MIN":                           21,
	"HISTOGRAM_COUNT":                         22,
	"HISTOGRAM_SUM":                           23,
	"HISTOGRAM_BUCKET_COUNTS":                 24,
	"HISTOGRAM_BUCKET_BOUNDS":                 25,
	"EXPONENTIAL_HISTOGRAM_MAX":               30,
	"EXPONENTIAL_HISTOGRAM_MIN":               31,
	"EXPONENTIAL_HISTOGRAM_COUNT":             32,
	"EXPONENTIAL_HISTOGRAM_SUM":               33,
	"EXPONENTIAL_HISTOGRAM_AVG":               34,
	"EXPONENTIAL_HISTOGRAM_SCALE":             35,
	"EXPONENTIAL_HISTOGRAM_ZERO_COUNT":        36,
	"EXPONENTIAL_HISTOGRAM_POS_OFFSET":        37,
	"EXPONENTIAL_HISTOGRAM_POS_BUCKET_COUNTS": 38,
	"EXPONENTIAL_HISTOGRAM_NEG_OFFSET":        39,
	"EXPONENTIAL_HISTOGRAM_NEG_BUCKET_COUNTS": 40,
	"EXPONENTIAL_HISTOGRAM_FLAGS":             41,
	"EXPONENTIAL_HISTOGRAM_START_TIME":        42,
}

Functions

func AnyRaw

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

AnyRaw get underlying wrapped value within types.Any.

func AppendPBPointToPBPointsPayload

func AppendPBPointToPBPointsPayload(dst []byte, pb *PBPoint) []byte

AppendPBPointToPBPointsPayload appends one PBPoint into a PBPoints payload.

func AppendPointToPBPointsPayload

func AppendPointToPBPointsPayload(dst []byte, pt *Point) []byte

AppendPointToPBPointsPayload appends one point into a PBPoints payload.

func ClearPointPool

func ClearPointPool()

func GetCfg

func GetCfg(opts ...Option) *cfg

func MustAnyRaw

func MustAnyRaw(x *types.Any) any

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

func MustNewAny

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

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

func MustNewAnyArray

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

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

func MustNewBoolArray

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

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

func MustNewBytesArray

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

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

func MustNewFloatArray

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

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

func MustNewIntArray

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

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

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

func MustNewUintArray

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

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

NewAny create types.Any based on exist proto message.

func NewAnyArray

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

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

func NewBoolArray

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

NewBoolArray wrapped boolean list into types.Any.

func NewBytesArray

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

NewBytesArray wrapped string list into types.Any.

func NewFloatArray

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

NewFloatArray wrapped float list into types.Any.

func NewIntArray

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

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

NewStringArray wrapped string list into types.Any.

func NewUintArray

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

func SetPointPool(pp PointPool)

func SortByTime

func SortByTime(pts []*Point)

SortByTime sort(ASC) pts according to time.

func WalkPBPointsPayload

func WalkPBPointsPayload(payload []byte, fn func(rawPBPoint []byte) bool) error

WalkPBPointsPayload iterates all raw PBPoint message bodies in a PBPoints payload.

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

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

func (*AnyDemo) GetDemo

func (m *AnyDemo) GetDemo() string

func (*AnyDemo) GoString

func (this *AnyDemo) GoString() string

func (*AnyDemo) Marshal

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

func (*AnyDemo) MarshalTo

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

func (*AnyDemo) MarshalToSizedBuffer

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

func (*AnyDemo) ProtoMessage

func (*AnyDemo) ProtoMessage()

func (*AnyDemo) Reset

func (m *AnyDemo) Reset()

func (*AnyDemo) Size

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

func (*AnyDemo) String

func (this *AnyDemo) String() string

func (*AnyDemo) Unmarshal

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

func (*AnyDemo) XXX_DiscardUnknown

func (m *AnyDemo) XXX_DiscardUnknown()

func (*AnyDemo) XXX_Marshal

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

func (*AnyDemo) XXX_Merge

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

func (*AnyDemo) XXX_Size

func (m *AnyDemo) XXX_Size() int

func (*AnyDemo) XXX_Unmarshal

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

type Array

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

func NewArray

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

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

func (*Array) Equal

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

func (*Array) GetArr

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

func (*Array) GoString

func (this *Array) GoString() string

func (*Array) Marshal

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

func (*Array) MarshalTo

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

func (*Array) MarshalToSizedBuffer

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

func (*Array) ProtoMessage

func (*Array) ProtoMessage()

func (*Array) Reset

func (m *Array) Reset()

func (*Array) Size

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

func (*Array) String

func (this *Array) String() string

func (*Array) Unmarshal

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

func (*Array) XXX_DiscardUnknown

func (m *Array) XXX_DiscardUnknown()

func (*Array) XXX_Marshal

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

func (*Array) XXX_Merge

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

func (*Array) XXX_Size

func (m *Array) XXX_Size() int

func (*Array) XXX_Unmarshal

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

type BasicTypes

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

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

func (*BasicTypes) Equal

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

func (*BasicTypes) GetB

func (m *BasicTypes) GetB() bool

func (*BasicTypes) GetD

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

func (*BasicTypes) GetF

func (m *BasicTypes) GetF() float64

func (*BasicTypes) GetI

func (m *BasicTypes) GetI() int64

func (*BasicTypes) GetS

func (m *BasicTypes) GetS() string

func (*BasicTypes) GetU

func (m *BasicTypes) GetU() uint64

func (*BasicTypes) GetX

func (m *BasicTypes) GetX() isBasicTypes_X

func (*BasicTypes) GoString

func (this *BasicTypes) GoString() string

func (*BasicTypes) Marshal

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

func (*BasicTypes) MarshalTo

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

func (*BasicTypes) MarshalToSizedBuffer

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

func (*BasicTypes) ProtoMessage

func (*BasicTypes) ProtoMessage()

func (*BasicTypes) Reset

func (m *BasicTypes) Reset()

func (*BasicTypes) Size

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

func (*BasicTypes) String

func (this *BasicTypes) String() string

func (*BasicTypes) Unmarshal

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

func (*BasicTypes) XXX_DiscardUnknown

func (m *BasicTypes) XXX_DiscardUnknown()

func (*BasicTypes) XXX_Marshal

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

func (*BasicTypes) XXX_Merge

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

func (*BasicTypes) XXX_OneofWrappers

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

XXX_OneofWrappers is for the internal use of the proto package.

func (*BasicTypes) XXX_Size

func (m *BasicTypes) XXX_Size() int

func (*BasicTypes) XXX_Unmarshal

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

type BasicTypes_B

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

func (*BasicTypes_B) Equal

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

func (*BasicTypes_B) GoString

func (this *BasicTypes_B) GoString() string

func (*BasicTypes_B) MarshalTo

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

func (*BasicTypes_B) MarshalToSizedBuffer

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

func (*BasicTypes_B) Size

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

func (*BasicTypes_B) String

func (this *BasicTypes_B) String() string

type BasicTypes_D

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

func (*BasicTypes_D) Equal

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

func (*BasicTypes_D) GoString

func (this *BasicTypes_D) GoString() string

func (*BasicTypes_D) MarshalTo

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

func (*BasicTypes_D) MarshalToSizedBuffer

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

func (*BasicTypes_D) Size

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

func (*BasicTypes_D) String

func (this *BasicTypes_D) String() string

type BasicTypes_F

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

func (*BasicTypes_F) Equal

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

func (*BasicTypes_F) GoString

func (this *BasicTypes_F) GoString() string

func (*BasicTypes_F) MarshalTo

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

func (*BasicTypes_F) MarshalToSizedBuffer

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

func (*BasicTypes_F) Size

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

func (*BasicTypes_F) String

func (this *BasicTypes_F) String() string

type BasicTypes_I

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

func (*BasicTypes_I) Equal

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

func (*BasicTypes_I) GoString

func (this *BasicTypes_I) GoString() string

func (*BasicTypes_I) MarshalTo

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

func (*BasicTypes_I) MarshalToSizedBuffer

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

func (*BasicTypes_I) Size

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

func (*BasicTypes_I) String

func (this *BasicTypes_I) String() string

type BasicTypes_S

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

func (*BasicTypes_S) Equal

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

func (*BasicTypes_S) GoString

func (this *BasicTypes_S) GoString() string

func (*BasicTypes_S) MarshalTo

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

func (*BasicTypes_S) MarshalToSizedBuffer

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

func (*BasicTypes_S) Size

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

func (*BasicTypes_S) String

func (this *BasicTypes_S) String() string

type BasicTypes_U

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

func (*BasicTypes_U) Equal

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

func (*BasicTypes_U) GoString

func (this *BasicTypes_U) GoString() string

func (*BasicTypes_U) MarshalTo

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

func (*BasicTypes_U) MarshalToSizedBuffer

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

func (*BasicTypes_U) Size

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

func (*BasicTypes_U) String

func (this *BasicTypes_U) String() string

type BatchPoints

type BatchPoints struct {
	Points []*Point
	// contains filtered or unexported fields
}

func NewBatchPoints

func NewBatchPoints() *BatchPoints

func (*BatchPoints) Release

func (bp *BatchPoints) Release()

func (*BatchPoints) Reset

func (bp *BatchPoints) Reset()

func (*BatchPoints) Unmarshal

func (bp *BatchPoints) Unmarshal(src []byte) (err error)

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

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

func (*Debug) GetInfo

func (m *Debug) GetInfo() string

func (*Debug) GoString

func (this *Debug) GoString() string

func (*Debug) Marshal

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

func (*Debug) MarshalTo

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

func (*Debug) MarshalToSizedBuffer

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

func (*Debug) ProtoMessage

func (*Debug) ProtoMessage()

func (*Debug) Reset

func (m *Debug) Reset()

func (*Debug) Size

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

func (*Debug) String

func (this *Debug) String() string

func (*Debug) Unmarshal

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

func (*Debug) XXX_DiscardUnknown

func (m *Debug) XXX_DiscardUnknown()

func (*Debug) XXX_Marshal

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

func (*Debug) XXX_Merge

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

func (*Debug) XXX_Size

func (m *Debug) XXX_Size() int

func (*Debug) XXX_Unmarshal

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

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

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

EncodeV2 set points to be encoded.

func (*Encoder) LastErr

func (e *Encoder) LastErr() error

func (*Encoder) LastTrimmed

func (e *Encoder) LastTrimmed() int

func (*Encoder) Next

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

Next is a iterator that return encoded data in prepared buf. If all points encoded done, return false. If any error occurred, we can get the error by call e.LastErr().

func (*Encoder) SkippedPoints

func (e *Encoder) SkippedPoints() int

func (*Encoder) String

func (e *Encoder) String() string

func (*Encoder) TotalPoints

func (e *Encoder) TotalPoints() int

type EncoderOption

type EncoderOption func(e *Encoder)

func WithApproxSize

func WithApproxSize(on bool) EncoderOption

WithApproxSize used to calculate the not-precise bytes required for protobuf encoding. Default to true for better performance under busy encoding conditions.

func WithEncBatchBytes

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

func WithIgnoreLargePoint

func WithIgnoreLargePoint(on bool) EncoderOption

WithIgnoreLargePoint will skip too-large point that can't encoded into buffer.

type Encoding

type Encoding int
const (
	LineProtocol Encoding = iota // encoding in InfluxDB line-protocol
	Protobuf                     // encoding in protobuf
	JSON                         // encoding int simple JSON
	PBJSON                       // encoding in protobuf structured JSON(with better field-type labeled)
)

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

func HTTPContentType(ct string) Encoding

HTTPContentType detect HTTP body content encoding according to header Content-Type.

func (Encoding) HTTPContentType

func (e Encoding) HTTPContentType() string

HTTPContentType get correct HTTP Content-Type value on different body encoding.

func (Encoding) String

func (e Encoding) String() string

type EqualOption

type EqualOption func(*eqopt)

func EqualWithMeasurement

func EqualWithMeasurement(on bool) EqualOption

EqualWithMeasurement set compare on points with/without measurement.

func EqualWithoutKeys

func EqualWithoutKeys(keys ...string) EqualOption

EqualWithoutKeys set compare on points without specific keys.

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"`
	Description string `protobuf:"bytes,12,opt,name=description,proto3" json:"description,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

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) GetDescription

func (m *Field) GetDescription() string

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

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

func (this *Field) GoString() string

func (*Field) Marshal

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

func (*Field) MarshalTo

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

func (*Field) MarshalToSizedBuffer

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

func (*Field) ProtoMessage

func (*Field) ProtoMessage()

func (*Field) Raw

func (kv *Field) Raw() any

Raw return underlying raw data.

func (*Field) Reset

func (m *Field) Reset()

func (*Field) Size

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

func (*Field) String

func (this *Field) String() string

func (*Field) Unmarshal

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

func (*Field) XXX_DiscardUnknown

func (m *Field) XXX_DiscardUnknown()

func (*Field) XXX_Marshal

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

func (*Field) XXX_Merge

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

func (*Field) XXX_OneofWrappers

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

XXX_OneofWrappers is for the internal use of the proto package.

func (*Field) XXX_Size

func (m *Field) XXX_Size() int

func (*Field) XXX_Unmarshal

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

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

func (*Field_A) GoString

func (this *Field_A) GoString() string

func (*Field_A) MarshalTo

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

func (*Field_A) MarshalToSizedBuffer

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

func (*Field_A) Size

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

func (*Field_A) String

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

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

func (*Field_B) GoString

func (this *Field_B) GoString() string

func (*Field_B) MarshalTo

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

func (*Field_B) MarshalToSizedBuffer

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

func (*Field_B) Size

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

func (*Field_B) String

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

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

func (*Field_D) GoString

func (this *Field_D) GoString() string

func (*Field_D) MarshalTo

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

func (*Field_D) MarshalToSizedBuffer

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

func (*Field_D) Size

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

func (*Field_D) String

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

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

func (*Field_F) GoString

func (this *Field_F) GoString() string

func (*Field_F) MarshalTo

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

func (*Field_F) MarshalToSizedBuffer

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

func (*Field_F) Size

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

func (*Field_F) String

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

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

func (*Field_I) GoString

func (this *Field_I) GoString() string

func (*Field_I) MarshalTo

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

func (*Field_I) MarshalToSizedBuffer

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

func (*Field_I) Size

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

func (*Field_I) String

func (this *Field_I) String() string

type Field_S

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

func (*Field_S) Equal

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

func (*Field_S) GoString

func (this *Field_S) GoString() string

func (*Field_S) MarshalTo

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

func (*Field_S) MarshalToSizedBuffer

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

func (*Field_S) Size

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

func (*Field_S) String

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

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

func (*Field_U) GoString

func (this *Field_U) GoString() string

func (*Field_U) MarshalTo

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

func (*Field_U) MarshalToSizedBuffer

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

func (*Field_U) Size

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

func (*Field_U) String

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 WithKVDesc

func WithKVDesc(desc string) KVOption

WithKVDesc set value's description.

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, opts ...KVOption) KVs

Add add new field with opts.

func (KVs) AddKV

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

func (KVs) AddTag

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

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) Pretty

func (x KVs) Pretty() string

Pretty show x' key/value list in orderded(ASC) list.

func (KVs) PrettySorted

func (x KVs) PrettySorted() string

func (KVs) RawPretty

func (x KVs) RawPretty() string

RawPretty show x' key/value list in un-orderded list.

func (KVs) Reset

func (x KVs) Reset()

Reset reset but drop value.

func (KVs) ResetFull

func (x KVs) ResetFull()

ResetFull reset and reuse key-value.

func (KVs) Set

func (x KVs) Set(k string, v any, opts ...KVOption) KVs

Set add new field with opts.

func (KVs) SetKV

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

func (KVs) SetTag

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

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

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

func MustNewMap

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

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

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

func (*Map) Descriptor

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

func (*Map) Equal

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

func (*Map) GetMap

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

func (*Map) GoString

func (this *Map) GoString() string

func (*Map) Marshal

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

func (*Map) MarshalTo

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

func (*Map) MarshalToSizedBuffer

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

func (*Map) ProtoMessage

func (*Map) ProtoMessage()

func (*Map) Reset

func (m *Map) Reset()

func (*Map) Size

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

func (*Map) String

func (this *Map) String() string

func (*Map) Unmarshal

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

func (*Map) XXX_DiscardUnknown

func (m *Map) XXX_DiscardUnknown()

func (*Map) XXX_Marshal

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

func (*Map) XXX_Merge

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

func (*Map) XXX_Size

func (m *Map) XXX_Size() int

func (*Map) XXX_Unmarshal

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

type MetricType

type MetricType int32
const (
	// 0~9
	UNSPECIFIED MetricType = 0
	COUNT       MetricType = 1
	RATE        MetricType = 2
	GAUGE       MetricType = 3
	// 10~19
	SUM_DELTA        MetricType = 10
	SUM_CUMULATIVE   MetricType = 11
	SUMMARY_COUNT    MetricType = 12
	SUMMARY_SUM      MetricType = 13
	SUMMARY_QUANTILE MetricType = 14
	// 20~29
	HISTOGRAM_MAX           MetricType = 20
	HISTOGRAM_MIN           MetricType = 21
	HISTOGRAM_COUNT         MetricType = 22
	HISTOGRAM_SUM           MetricType = 23
	HISTOGRAM_BUCKET_COUNTS MetricType = 24
	HISTOGRAM_BUCKET_BOUNDS MetricType = 25
	// 30 ~ 49
	EXPONENTIAL_HISTOGRAM_MAX               MetricType = 30
	EXPONENTIAL_HISTOGRAM_MIN               MetricType = 31
	EXPONENTIAL_HISTOGRAM_COUNT             MetricType = 32
	EXPONENTIAL_HISTOGRAM_SUM               MetricType = 33
	EXPONENTIAL_HISTOGRAM_AVG               MetricType = 34
	EXPONENTIAL_HISTOGRAM_SCALE             MetricType = 35
	EXPONENTIAL_HISTOGRAM_ZERO_COUNT        MetricType = 36
	EXPONENTIAL_HISTOGRAM_POS_OFFSET        MetricType = 37
	EXPONENTIAL_HISTOGRAM_POS_BUCKET_COUNTS MetricType = 38
	EXPONENTIAL_HISTOGRAM_NEG_OFFSET        MetricType = 39
	EXPONENTIAL_HISTOGRAM_NEG_BUCKET_COUNTS MetricType = 40
	EXPONENTIAL_HISTOGRAM_FLAGS             MetricType = 41
	EXPONENTIAL_HISTOGRAM_START_TIME        MetricType = 42
)

func (MetricType) EnumDescriptor

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

func (MetricType) String

func (x MetricType) String() string

type Option

type Option func(*cfg)

func CommonLoggingOptions

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

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

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

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

func (this *PBPoint) GoString() string

func (*PBPoint) Marshal

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

func (*PBPoint) MarshalTo

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

func (*PBPoint) MarshalToSizedBuffer

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

func (*PBPoint) ProtoMessage

func (*PBPoint) ProtoMessage()

func (*PBPoint) Reset

func (m *PBPoint) Reset()

func (*PBPoint) Size

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

func (*PBPoint) String

func (this *PBPoint) String() string

func (*PBPoint) Unmarshal

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

func (*PBPoint) XXX_DiscardUnknown

func (m *PBPoint) XXX_DiscardUnknown()

func (*PBPoint) XXX_Marshal

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

func (*PBPoint) XXX_Merge

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

func (*PBPoint) XXX_Size

func (m *PBPoint) XXX_Size() int

func (*PBPoint) XXX_Unmarshal

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

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

func (*PBPoints) GetArr

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

func (*PBPoints) GoString

func (this *PBPoints) GoString() string

func (*PBPoints) Marshal

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

func (*PBPoints) MarshalTo

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

func (*PBPoints) MarshalToSizedBuffer

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

func (*PBPoints) ProtoMessage

func (*PBPoints) ProtoMessage()

func (*PBPoints) Reset

func (m *PBPoints) Reset()

func (*PBPoints) Size

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

func (*PBPoints) String

func (this *PBPoints) String() string

func (*PBPoints) Unmarshal

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

func (*PBPoints) XXX_DiscardUnknown

func (m *PBPoints) XXX_DiscardUnknown()

func (*PBPoints) XXX_Marshal

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

func (*PBPoints) XXX_Merge

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

func (*PBPoints) XXX_Size

func (m *PBPoints) XXX_Size() int

func (*PBPoints) XXX_Unmarshal

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

type Point

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

func CheckPoints

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

CheckPoints used to check pts on various opts.

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

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

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

func NewPointDeprecated deprecated

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

NewPointDeprecated 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 NewPoint.

func RandPoints

func RandPoints(count int) []*Point

RandPoints deprecated.

func WrapPB

func WrapPB(pt *Point, pb *PBPoint) *Point

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

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

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

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

func (*Point) CopyTags

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, opts ...EqualOption) 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, opts ...EqualOption) (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) GetA

func (p *Point) GetA(k string) (*types.Any, bool)

func (*Point) GetB

func (p *Point) GetB(k string) (bool, bool)

func (*Point) GetD

func (p *Point) GetD(k string) ([]byte, bool)

func (*Point) GetF

func (p *Point) GetF(k string) (float64, bool)

func (*Point) GetI

func (p *Point) GetI(k string) (int64, bool)

func (*Point) GetS

func (p *Point) GetS(k string) (string, bool)

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) GetU

func (p *Point) GetU(k string) (uint64, bool)

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

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

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

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

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

func (*Point) MustLPPoint

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

func (p *Point) Reset()

func (*Point) Set

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

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

func (*Point) SetFlag

func (p *Point) SetFlag(f uint)

SetFlag set specific bit.

func (*Point) SetKVs

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) SetTag

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

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

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).

NOTE: This is a approxmate size, not equal to the final protobuf size of the point. For precise size, use PBSize() instead(and is slower).

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

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

func (p *Point) WarnsPretty() string

WarnsPretty return human readable warnning info.

type PointPool

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

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

	// For prometheus metrics.
	p8s.Collector
}

func GetPointPool

func GetPointPool() PointPool

func NewReservedCapPointPool

func NewReservedCapPointPool(capacity int64) PointPool

type Points

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
	PrecDyn                  // dynamic precision
)

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

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 WithRandSampleText

func WithRandSampleText(st []string) RandOption

func WithRandStringValues

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

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

func (*ReservedCapPointPool) Collect

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

func (*ReservedCapPointPool) Describe

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

func (*ReservedCapPointPool) Get

func (cpp *ReservedCapPointPool) Get() *Point

func (*ReservedCapPointPool) GetKV

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

func (*ReservedCapPointPool) Put

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

func (*ReservedCapPointPool) PutKV

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

func (*ReservedCapPointPool) String

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

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

func (this *Warn) GoString() string

func (*Warn) Marshal

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

func (*Warn) MarshalTo

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

func (*Warn) MarshalToSizedBuffer

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

func (*Warn) ProtoMessage

func (*Warn) ProtoMessage()

func (*Warn) Reset

func (m *Warn) Reset()

func (*Warn) Size

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

func (*Warn) String

func (this *Warn) String() string

func (*Warn) Unmarshal

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

func (*Warn) XXX_DiscardUnknown

func (m *Warn) XXX_DiscardUnknown()

func (*Warn) XXX_Marshal

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

func (*Warn) XXX_Merge

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

func (*Warn) XXX_Size

func (m *Warn) XXX_Size() int

func (*Warn) XXX_Unmarshal

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