msgpack

package
v1.20.2 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2021 License: MIT Imports: 4 Imported by: 0

README

MessagePack:

MessagePack is an efficient binary serialization format. It lets you exchange data among multiple languages like JSON.

https://msgpack.org

Format Definitions:

Output of this format is MessagePack binary representation of metrics that have identical structure of the below JSON.

{
   "name":"cpu",
   "time": <TIMESTAMP>, // https://github.com/msgpack/msgpack/blob/master/spec.md#timestamp-extension-type
   "tags":{
      "tag_1":"host01",
      ...
   },
   "fields":{
      "field_1":30,
      "field_2":true,
      "field_3":"field_value"
      "field_4":30.1
      ...
   }
}

MessagePack has it's own timestamp representation. You can find additional informations from MessagePack specification.

MessagePack Configuration:

There are no additional configuration options for MessagePack format.

[[outputs.file]]
  ## Files to write to, "stdout" is a specially handled file.
  files = ["stdout", "/tmp/metrics.out"]

  ## Data format to output.
  ## Each data format has its own unique set of configuration options, read
  ## more about them here:
  ## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_OUTPUT.md
  data_format = "msgpack"

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MessagePackTime

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

MessagePackTime implements the official timestamp extension type https://github.com/msgpack/msgpack/blob/master/spec.md#timestamp-extension-type

tinylib/msgp has been using their own custom extension type and the official extension is not available. (https://github.com/tinylib/msgp/issues/214)

func (*MessagePackTime) DecodeMsg

func (z *MessagePackTime) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (MessagePackTime) EncodeMsg

func (z MessagePackTime) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*MessagePackTime) ExtensionType

func (*MessagePackTime) ExtensionType() int8

ExtensionType implements the Extension interface

func (*MessagePackTime) Len

func (t *MessagePackTime) Len() int

Len implements the Extension interface The timestamp extension uses variable length encoding depending the input

32bits: [1970-01-01 00:00:00 UTC, 2106-02-07 06:28:16 UTC) range. If the nanoseconds part is 0 64bits: [1970-01-01 00:00:00.000000000 UTC, 2514-05-30 01:53:04.000000000 UTC) range. 96bits: [-584554047284-02-23 16:59:44 UTC, 584554051223-11-09 07:00:16.000000000 UTC) range.

func (*MessagePackTime) MarshalBinaryTo

func (t *MessagePackTime) MarshalBinaryTo(buf []byte) error

MarshalBinaryTo implements the Extension interface

func (MessagePackTime) MarshalMsg

func (z MessagePackTime) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (MessagePackTime) Msgsize

func (z MessagePackTime) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*MessagePackTime) UnmarshalBinary

func (t *MessagePackTime) UnmarshalBinary(buf []byte) error

UnmarshalBinary implements the Extension interface

func (*MessagePackTime) UnmarshalMsg

func (z *MessagePackTime) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type Metric

type Metric struct {
	Name   string                 `msg:"name"`
	Time   MessagePackTime        `msg:"time,extension"`
	Tags   map[string]string      `msg:"tags"`
	Fields map[string]interface{} `msg:"fields"`
}

Metric is structure to define MessagePack message format will be used by msgp code generator

func (*Metric) DecodeMsg

func (z *Metric) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*Metric) EncodeMsg

func (z *Metric) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*Metric) MarshalMsg

func (z *Metric) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*Metric) Msgsize

func (z *Metric) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*Metric) UnmarshalMsg

func (z *Metric) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type Serializer

type Serializer struct{}

Serializer encodes metrics in MessagePack format

func NewSerializer

func NewSerializer() *Serializer

NewSerializer creates a msgpack.Serializer

func (*Serializer) Serialize

func (s *Serializer) Serialize(metric telegraf.Metric) ([]byte, error)

Serialize implements serializers.Serializer.Serialize github.com/influxdata/telegraf/plugins/serializers/Serializer

func (*Serializer) SerializeBatch

func (s *Serializer) SerializeBatch(metrics []telegraf.Metric) ([]byte, error)

SerializeBatch implements serializers.Serializer.SerializeBatch github.com/influxdata/telegraf/plugins/serializers/Serializer

Jump to

Keyboard shortcuts

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