types

package
v0.2.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// Body map keys
	// BodyKeyMessage is the key for the unparsed message field of a log.
	BodyKeyMessage = "message"

	// Attributes map keys
	// AttributeDatabaseName is the name of the ADX database that the log should be sent to.
	AttributeDatabaseName = "adxmon_destination_database"
	// AttributeTableName is the name of the ADX table that the log should be sent to.
	AttributeTableName = "adxmon_destination_table"
)

Variables

View Source
var (
	LogBatchPool = pool.NewGeneric(200, func(sz int) interface{} {
		return &LogBatch{
			Logs: make([]*Log, 0, sz),
		}
	})
	LogPool = pool.NewGeneric(1024, func(sz int) interface{} {
		return NewLog()
	})
)

Functions

func StringOrEmpty added in v0.2.0

func StringOrEmpty(val any, ok bool) string

Types

type Log

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

Log represents a single log entry It is not safe for concurrent updates It is safe to read from multiple goroutines after all modifications have been completed. Freeze is best effort and should be used to indicate that the log is no longer being modified.

func NewLog

func NewLog() *Log

func (*Log) AttributeLen added in v0.2.0

func (l *Log) AttributeLen() int

func (*Log) BodyLen added in v0.2.0

func (l *Log) BodyLen() int

func (*Log) Copy

func (l *Log) Copy() *Log

Copy returns a distinct copy of the log. This is useful for splitting logs.

func (*Log) ForEachAttribute added in v0.2.0

func (l *Log) ForEachAttribute(f func(string, any) error) error

func (*Log) ForEachBody added in v0.2.0

func (l *Log) ForEachBody(f func(string, any) error) error

func (*Log) ForEachResource added in v0.2.0

func (l *Log) ForEachResource(f func(string, any) error) error

func (*Log) Freeze added in v0.2.0

func (l *Log) Freeze()

func (*Log) GetAttributeValue added in v0.2.0

func (l *Log) GetAttributeValue(key string) (any, bool)

func (*Log) GetAttributes added in v0.2.0

func (l *Log) GetAttributes() map[string]any

GetAttributes returns a copy of the attributes map for read-only access This creates a shallow copy of the map elements. The map is safe to modify, but most elements are not.

func (*Log) GetBody added in v0.2.0

func (l *Log) GetBody() map[string]any

GetBody returns a copy of the body map for read-only access This creates a shallow copy of the map elements. The map is safe to modify, but most elements are not.

func (*Log) GetBodyValue added in v0.2.0

func (l *Log) GetBodyValue(key string) (any, bool)

func (*Log) GetObservedTimestamp added in v0.2.0

func (l *Log) GetObservedTimestamp() uint64

func (*Log) GetResource added in v0.2.0

func (l *Log) GetResource() map[string]any

GetResource returns a copy of the resource map for read-only access This creates a shallow copy of the map elements. The map is safe to modify, but most elements are not.

func (*Log) GetResourceValue added in v0.2.0

func (l *Log) GetResourceValue(key string) (any, bool)

func (*Log) GetTimestamp added in v0.2.0

func (l *Log) GetTimestamp() uint64

func (*Log) Reset

func (l *Log) Reset()

func (*Log) ResourceLen added in v0.2.0

func (l *Log) ResourceLen() int

func (*Log) SetAttributeValue added in v0.2.0

func (l *Log) SetAttributeValue(key string, value any)

func (*Log) SetBodyValue added in v0.2.0

func (l *Log) SetBodyValue(key string, value any)

func (*Log) SetObservedTimestamp added in v0.2.0

func (l *Log) SetObservedTimestamp(ts uint64)

func (*Log) SetResourceValue added in v0.2.0

func (l *Log) SetResourceValue(key string, value any)

func (*Log) SetTimestamp added in v0.2.0

func (l *Log) SetTimestamp(ts uint64)

type LogBatch

type LogBatch struct {
	Logs []*Log
	Ack  func()
}

LogBatch represents a batch of logs

func (*LogBatch) AddLiterals added in v0.2.0

func (l *LogBatch) AddLiterals(literals []*LogLiteral)

func (*LogBatch) Reset

func (l *LogBatch) Reset()

type LogLiteral added in v0.2.0

type LogLiteral struct {
	// Timestamp of the event in nanoseconds since the unix epoch
	Timestamp uint64
	// Timestamp when this event was ingested in nanoseconds since the unix epoch
	ObservedTimestamp uint64

	// Body of the log entry
	Body map[string]any

	// Attributes of the log entry, not included in the log body.
	Attributes map[string]any

	// Resource that has collected the log
	Resource map[string]any
}

LogLiteral is a struct that is easily converted to Log.

func (*LogLiteral) ToLog added in v0.2.0

func (l *LogLiteral) ToLog() *Log

type Sink

type Sink interface {
	Open(context.Context) error
	Send(context.Context, *LogBatch) error
	Close() error
	Name() string
}

Sink is a component that receives a LogBatch. Send is potentially called by multiple goroutines concurrently.

type Source

type Source interface {
	Open(context.Context) error
	Close() error
	Name() string
}

Source is a component that produces *LogBatch instances.

type Transformer

type Transformer interface {
	Open(context.Context) error
	Transform(context.Context, *LogBatch) (*LogBatch, error)
	Close() error
	Name() string
}

Transformer is a component that transforms a LogBatch. Transform is potentially called by multiple goroutines concurrently.

Jump to

Keyboard shortcuts

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