dogproto

package
v0.0.0-...-5e858b1 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// A port <= 0 should instruct Java to skip this and use an internal default
	StatsDPort int `json:"statsd_port"`
}

type ConfigResponse

type ConfigResponse struct {
	Version string `json:"version"`
	Config  Config `json:"config"`

	// Must not be nil.
	// These are just paths, not hosts:
	// - https://github.com/DataDog/dd-trace-java/blob/0f986a71765d0bad85ed4e5c3bc6ef44b8cb78fe/communication/src/main/java/datadog/communication/ddagent/DDAgentFeaturesDiscovery.java#L39
	// - https://github.com/DataDog/dd-trace-java/blob/0f986a71765d0bad85ed4e5c3bc6ef44b8cb78fe/communication/src/main/java/datadog/communication/ddagent/DDAgentFeaturesDiscovery.java#L59C46-L59C65
	// In the java version, whether or not metrics or tracing are enabled is contingent on
	// whether those paths are found in here.
	Endpoints []string `json:"endpoints"`

	ClientDropP0s bool `json:"client_drop_p0s,omitempty"`
}

JSON response to 'GET /v0.7/config', sponged out of DDAgentFeaturesDiscovery.java in https://github.com/DataDog/dd-trace-java/

type Metric

type Metric struct {
	LogType   string     `json:"_type"` // Useless field to cover over lousy polymorphism support in Go; should always be "metric"
	At        time.Time  `json:"at"`
	From      string     `json:"from"` // Client that sent the metric. Not part of the protocol, but useful for dumping.
	Name      string     `json:"name"`
	Type      ValueType  `json:"type"`
	Int       int64      `json:"int"`
	Ints      []int64    `json:"ints,omitempty"`
	Float     float64    `json:"float"`
	Floats    []float64  `json:"floats,omitempty"`
	Metric    MetricType `json:"metric"`
	Rate      float64    `json:"rate"`    // [0.0, 1.0]
	HasRate   bool       `json:"hasRate"` // false if no rate parsed from msg
	Tags      Tags       `json:"tagList,omitempty"`
	Container string     `json:"container,omitempty"`

	// When this field is provided, the Datadog Agent doesn’t do any processing with the
	// metrics (no aggregation) except from enriching the metrics with tags. This can be
	// useful if you already aggregate your metrics in your application, and you want to
	// send them to Datadog without extra processing.
	//
	// The Unix timestamp should be a valid positive number in the past. Only GAUGE and
	// COUNT metrics are supported.
	UnixTimeSecs int64 `json:"unixTimeSecs,omitempty"`

	Unsupported []string `json:"unsupported,omitempty"`
}

Metric parsed from a single dogstats entry in a dogstatsd packet.

Note that this does not use a Go generic as there's no ergonomic way to do so and maintain some usefulness with the JSON encoder, but it is effectively a union.

The Type field determines whether the Int, Ints, Float or Floats field should be used.

---

func (Metric) AllFloats

func (m Metric) AllFloats() []float64

func (Metric) AllInts

func (m Metric) AllInts() []int64

func (Metric) AllValues

func (m Metric) AllValues() (out []any)

func (Metric) CanMarshalJSON

func (m Metric) CanMarshalJSON() bool

DogstatsD will handle float values like infinity and NaN just fine, but we can't directly dump those to JSON. This is a stopgap until a better approach emerges that doesn't compromise the usefulness of the Metric type.

func (*Metric) FromMsg

func (m *Metric) FromMsg(at time.Time, from string, msg string) (err error)

Parses a Metric from a string.

Formats documented here: https://docs.datadoghq.com/developers/dogstatsd/datagram_shell/?tab=metrics

Dogstats 1.0: <METRIC_NAME>:<VALUE>|<TYPE>|@<SAMPLE_RATE>|#<TAG_KEY_1>:<TAG_VALUE_1>,<TAG_2>

Dogstats 1.1: <METRIC_NAME>:<VALUE1>:<VALUE2>:<VALUE3>|<TYPE>|@<SAMPLE_RATE>|#<TAG_KEY_1>:<TAG_VALUE_1>,<TAG_2>

Dogstats 1.2: <METRIC_NAME>:<VALUE>|<TYPE>|#<TAG_KEY_1>:<TAG_VALUE_1>,<TAG_2>|c:<CONTAINER_ID>

Dogstats 1.3: <METRIC_NAME>:<VALUE>|<TYPE>|#<TAG_KEY_1>:<TAG_VALUE_1>,<TAG_2>|T<METRIC_TIMESTAMP>

---

func (Metric) Value

func (m Metric) Value() any

type MetricType

type MetricType string
const (
	CountMetric        MetricType = "c"
	GaugeMetric        MetricType = "g"
	TimerMetric        MetricType = "ms"
	HistogramMetric    MetricType = "h"
	SetMetric          MetricType = "s"
	DistributionMetric MetricType = "d"
)

func (MetricType) IsValid

func (m MetricType) IsValid() bool

type Span

type Span struct {
	Name          string             `msg:"name" json:"name"`
	Service       string             `msg:"service" json:"service"`
	Resource      string             `msg:"resource" json:"resource"`
	Type          *string            `msg:"type" json:"type"`
	StartUnixNano int64              `msg:"start" json:"start"` // NOTE: This is a float of 'seconds' in /api/v1/trace, but a unixnano here
	Duration      time.Duration      `msg:"duration" json:"duration"`
	Meta          map[string]string  `msg:"meta,omitempty" json:"meta,omitempty"`
	Metrics       map[string]float64 `msg:"metrics,omitempty" json:"metrics,omitempty"`
	SpanID        uint64             `msg:"span_id" json:"spanId"`
	TraceID       uint64             `msg:"trace_id" json:"traceId"`
	ParentID      uint64             `msg:"parent_id" json:"parentId"`
	Error         int32              `msg:"error" json:"error"`
}

func (*Span) DecodeMsg

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

DecodeMsg implements msgp.Decodable

func (*Span) EncodeMsg

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

EncodeMsg implements msgp.Encodable

func (Span) EndTime

func (span Span) EndTime() time.Time

func (*Span) MarshalMsg

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

MarshalMsg implements msgp.Marshaler

func (*Span) Msgsize

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

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

func (Span) StartTime

func (span Span) StartTime() time.Time

func (*Span) UnmarshalMsg

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

UnmarshalMsg implements msgp.Unmarshaler

type SpanList

type SpanList []Span

func (*SpanList) DecodeMsg

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

DecodeMsg implements msgp.Decodable

func (SpanList) EncodeMsg

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

EncodeMsg implements msgp.Encodable

func (SpanList) MarshalMsg

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

MarshalMsg implements msgp.Marshaler

func (SpanList) Msgsize

func (z SpanList) Msgsize() (s int)

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

func (*SpanList) UnmarshalMsg

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

UnmarshalMsg implements msgp.Unmarshaler

type SpanLists

type SpanLists []SpanList

func (*SpanLists) DecodeMsg

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

DecodeMsg implements msgp.Decodable

func (SpanLists) EncodeMsg

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

EncodeMsg implements msgp.Encodable

func (SpanLists) MarshalMsg

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

MarshalMsg implements msgp.Marshaler

func (SpanLists) Msgsize

func (z SpanLists) Msgsize() (s int)

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

func (*SpanLists) UnmarshalMsg

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

UnmarshalMsg implements msgp.Unmarshaler

type Tag

type Tag struct {
	Key string `json:"key"`
	Val string `json:"val"`
}

type Tags

type Tags []Tag

func ParseTags

func ParseTags(rawTags string) (tags Tags, err error)

func (Tags) IntoMap

func (t Tags) IntoMap(into map[string]string)

func (Tags) String

func (t Tags) String() string

func (Tags) ToMap

func (tags Tags) ToMap() map[string]string

type ValueType

type ValueType string
const (
	IntValue    ValueType = "int"
	IntsValue   ValueType = "ints"
	FloatValue  ValueType = "float"
	FloatsValue ValueType = "floats"
)

Jump to

Keyboard shortcuts

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