models

package
v0.0.0-...-68fa65b Latest Latest
Warning

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

Go to latest
Published: May 29, 2024 License: Apache-2.0 Imports: 5 Imported by: 1

Documentation

Index

Constants

View Source
const (
	SpanKindTextInternal = "internal"
	SpanKindTextServer   = "server"
	SpanKindTextClient   = "client"
	SpanKindTextProducer = "producer"
	SpanKindTextConsumer = "consumer"
)

Variables

View Source
var (
	NilStringValues    = &keyValuesNil[string]{}
	NilTypedValues     = &keyValuesNil[*TypedValue]{}
	NilFloatValues     = &keyValuesNil[float64]{}
	NilInterfaceValues = &keyValuesNil[interface{}]{}
)
View Source
var (
	MetricTypeTexts = map[MetricType]string{
		MetricTypeCounter:     "Counter",
		MetricTypeGauge:       "Gauge",
		MetricTypeHistogram:   "Histogram",
		MetricTypeSummary:     "Summary",
		MetricTypeUntyped:     "Untyped",
		MetricTypeMeter:       "Meter",
		MetricTypeRateCounter: "RateCounter",
	}

	MetricTypeValues = map[string]MetricType{
		"Counter":     MetricTypeCounter,
		"Gauge":       MetricTypeGauge,
		"Histogram":   MetricTypeHistogram,
		"Summary":     MetricTypeSummary,
		"Untyped":     MetricTypeUntyped,
		"Meter":       MetricTypeMeter,
		"RateCounter": MetricTypeRateCounter,
	}
)

Functions

This section is empty.

Types

type ByteArray

type ByteArray []byte

Defines a ByteArray event. For example, the agent is deployed as a proxy to directly transparently transmit the received binary data to the backend, using ByteArray can avoid additional Marshal/Unmarshal overhead.

func NewByteArray

func NewByteArray(bytes []byte) ByteArray

func (ByteArray) Clone

func (b ByteArray) Clone() PipelineEvent

func (ByteArray) GetName

func (ByteArray) GetName() string

func (ByteArray) GetObservedTimestamp

func (ByteArray) GetObservedTimestamp() uint64

func (ByteArray) GetTags

func (ByteArray) GetTags() Tags

func (ByteArray) GetTimestamp

func (ByteArray) GetTimestamp() uint64

func (ByteArray) GetType

func (ByteArray) GetType() EventType

func (ByteArray) SetName

func (ByteArray) SetName(name string)

func (ByteArray) SetObservedTimestamp

func (ByteArray) SetObservedTimestamp(timestamp uint64)

type EmptyMetricValue

type EmptyMetricValue struct {
}

func (*EmptyMetricValue) GetMultiValues

func (v *EmptyMetricValue) GetMultiValues() MetricFloatValues

func (*EmptyMetricValue) GetSingleValue

func (v *EmptyMetricValue) GetSingleValue() float64

func (*EmptyMetricValue) IsMultiValues

func (v *EmptyMetricValue) IsMultiValues() bool

func (*EmptyMetricValue) IsSingleValue

func (v *EmptyMetricValue) IsSingleValue() bool

type EventType

type EventType int
const (
	EventTypeMetric EventType
	EventTypeSpan
	EventTypeLogging
	EventTypeByteArray
)

type GroupInfo

type GroupInfo struct {
	Metadata Metadata
	Tags     Tags
}

func NewGroup

func NewGroup(meta Metadata, tags Tags) *GroupInfo

func (*GroupInfo) GetMetadata

func (g *GroupInfo) GetMetadata() Metadata

func (*GroupInfo) GetTags

func (g *GroupInfo) GetTags() Tags

type KeyValue

type KeyValue[TValue string | float64 | *TypedValue | any] struct {
	Key   string
	Value TValue
}

type KeyValueSlice

type KeyValueSlice[TValue string | float64 | *TypedValue | any] []KeyValue[TValue]

func (KeyValueSlice[TValue]) Len

func (x KeyValueSlice[TValue]) Len() int

func (KeyValueSlice[TValue]) Less

func (x KeyValueSlice[TValue]) Less(i, j int) bool

func (KeyValueSlice[TValue]) Swap

func (x KeyValueSlice[TValue]) Swap(i, j int)

type KeyValues

type KeyValues[TValue string | float64 | *TypedValue | any] interface {
	Add(key string, value TValue)

	AddAll(items map[string]TValue)

	Get(key string) TValue

	Contains(key string) bool

	Delete(key string)

	Merge(other KeyValues[TValue])

	Iterator() map[string]TValue

	SortTo(buf []KeyValue[TValue]) []KeyValue[TValue]

	Len() int

	IsNil() bool
}

func NewKeyValues

func NewKeyValues[TValue string | float64 | *TypedValue | any]() KeyValues[TValue]

type Log

type Log struct {
	Name              string
	Level             string
	SpanID            string
	TraceID           string
	Tags              Tags
	Timestamp         uint64
	ObservedTimestamp uint64
	Offset            uint64
	Contents          LogContents
}

func NewLog

func NewLog(name string, body []byte, level, spanID, traceID string, tags Tags, timestamp uint64) *Log

func NewSimpleLevelLog

func NewSimpleLevelLog(level string, body []byte, tags Tags, timestamp uint64) *Log

func NewSimpleLog

func NewSimpleLog(body []byte, tags Tags, timestamp uint64) *Log

func (*Log) Clone

func (m *Log) Clone() PipelineEvent

func (*Log) GetBody

func (m *Log) GetBody() []byte

func (*Log) GetIndices

func (m *Log) GetIndices() LogContents

func (*Log) GetLevel

func (m *Log) GetLevel() string

func (*Log) GetName

func (m *Log) GetName() string

func (*Log) GetObservedTimestamp

func (m *Log) GetObservedTimestamp() uint64

func (*Log) GetOffset

func (m *Log) GetOffset() uint64

func (*Log) GetSpanID

func (m *Log) GetSpanID() string

func (*Log) GetTags

func (m *Log) GetTags() Tags

func (*Log) GetTimestamp

func (m *Log) GetTimestamp() uint64

func (*Log) GetTraceID

func (m *Log) GetTraceID() string

func (*Log) GetType

func (m *Log) GetType() EventType

func (*Log) SetBody

func (m *Log) SetBody(body []byte)

func (*Log) SetIndices

func (m *Log) SetIndices(indices LogContents)

func (*Log) SetLevel

func (m *Log) SetLevel(level string)

func (*Log) SetName

func (m *Log) SetName(name string)

func (*Log) SetObservedTimestamp

func (m *Log) SetObservedTimestamp(observedTimestamp uint64)

func (*Log) SetOffset

func (m *Log) SetOffset(offset uint64)

func (*Log) SetSpanID

func (m *Log) SetSpanID(spanID string)

func (*Log) SetTraceID

func (m *Log) SetTraceID(traceID string)

type LogContents

type LogContents KeyValues[interface{}]

func NewLogContents

func NewLogContents() LogContents

type Metadata

type Metadata KeyValues[string]

func NewMetadata

func NewMetadata() Metadata

func NewMetadataWithKeyValues

func NewMetadataWithKeyValues(keyValues ...string) Metadata

func NewMetadataWithMap

func NewMetadataWithMap(md map[string]string) Metadata

type Metric

type Metric struct {
	Name              string
	Unit              string
	Description       string
	Timestamp         uint64
	ObservedTimestamp uint64

	Tags       Tags
	MetricType MetricType
	Value      MetricValue
	TypedValue MetricTypedValues
}

Defines a Metric which has one or more timeseries. The following is a brief summary of the Metric data model. For more details, see: https://github.com/alibaba/ilogtail/discussions/518 - Metric is composed of a metadata and data. - Metadata part contains a name, description, unit, tags - Data is one of the possible types (Counter, Gauge, Histogram, Summary).

func NewMetric

func NewMetric(name string, metricType MetricType, tags Tags, timestamp int64, value MetricValue, typedValues MetricTypedValues) *Metric

func NewMultiValuesMetric

func NewMultiValuesMetric(name string, metricType MetricType, tags Tags, timestamp int64, values MetricFloatValues) *Metric

func NewSingleValueMetric

func NewSingleValueMetric[T constraints.IntUintFloat](name string, metricType MetricType, tags Tags, timestamp int64, value T) *Metric

func (*Metric) Clone

func (m *Metric) Clone() PipelineEvent

func (*Metric) GetDescription

func (m *Metric) GetDescription() string

func (*Metric) GetMetricType

func (m *Metric) GetMetricType() MetricType

func (*Metric) GetName

func (m *Metric) GetName() string

func (*Metric) GetObservedTimestamp

func (m *Metric) GetObservedTimestamp() uint64

func (*Metric) GetTags

func (m *Metric) GetTags() Tags

func (*Metric) GetTimestamp

func (m *Metric) GetTimestamp() uint64

func (*Metric) GetType

func (m *Metric) GetType() EventType

func (*Metric) GetTypedValue

func (m *Metric) GetTypedValue() MetricTypedValues

func (*Metric) GetUnit

func (m *Metric) GetUnit() string

func (*Metric) GetValue

func (m *Metric) GetValue() MetricValue

func (*Metric) SetName

func (m *Metric) SetName(name string)

func (*Metric) SetObservedTimestamp

func (m *Metric) SetObservedTimestamp(timestamp uint64)

func (*Metric) String

func (m *Metric) String() string

type MetricFloatValues

type MetricFloatValues interface {
	KeyValues[float64]
}

type MetricMultiValue

type MetricMultiValue struct {
	Values MetricFloatValues
}

func NewMetricMultiValue

func NewMetricMultiValue() *MetricMultiValue

func NewMetricMultiValueWithMap

func NewMetricMultiValueWithMap(keyValues map[string]float64) *MetricMultiValue

func (*MetricMultiValue) Add

func (v *MetricMultiValue) Add(key string, value float64)

func (*MetricMultiValue) GetMultiValues

func (v *MetricMultiValue) GetMultiValues() MetricFloatValues

func (*MetricMultiValue) GetSingleValue

func (v *MetricMultiValue) GetSingleValue() float64

func (*MetricMultiValue) IsMultiValues

func (v *MetricMultiValue) IsMultiValues() bool

func (*MetricMultiValue) IsSingleValue

func (v *MetricMultiValue) IsSingleValue() bool

type MetricSingleValue

type MetricSingleValue struct {
	Value float64
}

func (*MetricSingleValue) GetMultiValues

func (v *MetricSingleValue) GetMultiValues() MetricFloatValues

func (*MetricSingleValue) GetSingleValue

func (v *MetricSingleValue) GetSingleValue() float64

func (*MetricSingleValue) IsMultiValues

func (v *MetricSingleValue) IsMultiValues() bool

func (*MetricSingleValue) IsSingleValue

func (v *MetricSingleValue) IsSingleValue() bool

type MetricType

type MetricType int
const (
	MetricTypeUntyped MetricType
	MetricTypeCounter
	MetricTypeGauge
	MetricTypeHistogram
	MetricTypeSummary

	// Extended metrics types
	MetricTypeMeter       // In bytetsd, meter is an extension of the counter type, which contains a counter value and a rate value within a period
	MetricTypeRateCounter // In bytetsd, ratecounter is an extension of the counter type, which contains a rate value within a period
)

type MetricTypedValues

type MetricTypedValues interface {
	KeyValues[*TypedValue]
}

MetricTypedValues In TSDB such as influxdb, its fields not only have numeric types, also string, bool, and array types. MetricTypedValues is used to define types other than numeric values.

func NewMetricTypedValueWithMap

func NewMetricTypedValueWithMap(keyValues map[string]*TypedValue) MetricTypedValues

func NewMetricTypedValues

func NewMetricTypedValues() MetricTypedValues

type MetricValue

type MetricValue interface {
	IsSingleValue() bool

	IsMultiValues() bool

	GetSingleValue() float64

	GetMultiValues() MetricFloatValues
}

type PipelineEvent

type PipelineEvent interface {
	GetName() string

	SetName(string)

	GetTags() Tags

	GetType() EventType

	GetTimestamp() uint64

	GetObservedTimestamp() uint64

	SetObservedTimestamp(uint64)

	Clone() PipelineEvent
}

type PipelineGroupEvents

type PipelineGroupEvents struct {
	Group  *GroupInfo
	Events []PipelineEvent
}

type Span

type Span struct {
	TraceID      string
	SpanID       string
	ParentSpanID string
	Name         string
	TraceState   string

	StartTime         uint64
	EndTime           uint64
	ObservedTimestamp uint64

	Kind   SpanKind
	Status StatusCode
	Tags   Tags
	Links  []*SpanLink
	Events []*SpanEvent
}

A Span represents a single operation performed by a single component of the system.

func NewSpan

func NewSpan(name, traceID, spanID string, kind SpanKind, startTime, endTime uint64, tags Tags, events []*SpanEvent, links []*SpanLink) *Span

func (*Span) Clone

func (m *Span) Clone() PipelineEvent

func (*Span) GetEndTime

func (m *Span) GetEndTime() uint64

func (*Span) GetEvents

func (m *Span) GetEvents() []*SpanEvent

func (*Span) GetKind

func (m *Span) GetKind() SpanKind
func (m *Span) GetLinks() []*SpanLink

func (*Span) GetName

func (m *Span) GetName() string

func (*Span) GetObservedTimestamp

func (m *Span) GetObservedTimestamp() uint64

func (*Span) GetParentSpanID

func (m *Span) GetParentSpanID() string

func (*Span) GetSpanID

func (m *Span) GetSpanID() string

func (*Span) GetStartTime

func (m *Span) GetStartTime() uint64

func (*Span) GetStatus

func (m *Span) GetStatus() StatusCode

func (*Span) GetTags

func (m *Span) GetTags() Tags

func (*Span) GetTimestamp

func (m *Span) GetTimestamp() uint64

func (*Span) GetTraceID

func (m *Span) GetTraceID() string

func (*Span) GetTraceState

func (m *Span) GetTraceState() string

func (*Span) GetType

func (m *Span) GetType() EventType

func (*Span) SetName

func (m *Span) SetName(name string)

func (*Span) SetObservedTimestamp

func (m *Span) SetObservedTimestamp(timestamp uint64)

type SpanEvent

type SpanEvent struct {
	Timestamp int64
	Name      string
	Tags      Tags
}

type SpanKind

type SpanKind int
const (

	// Indicates that the span represents an internal operation within an application,
	// as opposed to an operation happening at the boundaries. Default value.
	SpanKindInternal SpanKind

	// Indicates that the span covers server-side handling of an RPC or other
	// remote network request.
	SpanKindServer

	// Indicates that the span describes a request to some remote service.
	SpanKindClient

	// Indicates that the span describes a producer sending a message to a broker.
	// Unlike CLIENT and SERVER, there is often no direct critical path latency relationship
	// between producer and consumer spans. A PRODUCER span ends when the message was accepted
	// by the broker while the logical processing of the message might span a much longer time.
	SpanKindProducer

	// Indicates that the span describes consumer receiving a message from a broker.
	// Like the PRODUCER kind, there is often no direct critical path latency relationship
	// between producer and consumer spans.
	SpanKindConsumer
)

type SpanKindText

type SpanKindText string
type SpanLink struct {
	TraceID    string
	SpanID     string
	TraceState string
	Tags       Tags
}

type StatusCode

type StatusCode int
const (
	StatusCodeUnSet StatusCode = iota
	StatusCodeOK
	StatusCodeError
)

type Tags

type Tags KeyValues[string]

func NewTags

func NewTags() Tags

func NewTagsWithKeyValues

func NewTagsWithKeyValues(keyValues ...string) Tags

func NewTagsWithMap

func NewTagsWithMap(tags map[string]string) Tags

type TypedValue

type TypedValue struct {
	Type  ValueType
	Value interface{}
}

type ValueType

type ValueType int
const (
	ValueTypeString ValueType
	ValueTypeBoolean
	ValueTypeArray
	ValueTypeMap

	ContentKey = "content"
	BodyKey    = ContentKey
)

Jump to

Keyboard shortcuts

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