stanza

package module
v0.52.0 Latest Latest
Warning

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

Go to latest
Published: May 25, 2022 License: Apache-2.0 Imports: 41 Imported by: 0

Documentation

Overview

nolint:errcheck

nolint:errcheck

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Convert

func Convert(ent *entry.Entry) plog.Logs

Convert converts one entry.Entry into plog.Logs. To be used in a stateless setting like tests where ease of use is more important than performance or throughput.

func ConvertFrom added in v0.51.0

func ConvertFrom(pLogs plog.Logs) []*entry.Entry

ConvertFrom converts plog.Logs into a slice of entry.Entry To be used in a stateless setting like tests where ease of use is more important than performance or throughput.

func GetPersister added in v0.51.0

func GetPersister(storageClient storage.Client) operator.Persister

func GetStorageClient added in v0.51.0

func GetStorageClient(ctx context.Context, id config.ComponentID, componentKind component.Kind, host component.Host) (storage.Client, error)

func HashResource added in v0.46.0

func HashResource(resource map[string]interface{}) uint64

HashResource will hash an entry.Entry.Resource

func NewFactory

func NewFactory(logReceiverType LogReceiverType) component.ReceiverFactory

NewFactory creates a factory for a Stanza-based receiver

Types

type BaseConfig

type BaseConfig struct {
	config.ReceiverSettings `mapstructure:",squash"`
	Operators               OperatorConfigs `mapstructure:"operators"`
	Converter               ConverterConfig `mapstructure:"converter"`
}

BaseConfig is the common configuration of a stanza-based receiver

func (BaseConfig) DecodeOperatorConfigs added in v0.51.0

func (cfg BaseConfig) DecodeOperatorConfigs() ([]operator.Config, error)

decodeOperatorConfigs is an unmarshaling workaround for stanza operators This is needed only until stanza operators are migrated to mapstructure

type Converter added in v0.25.0

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

Converter converts a batch of entry.Entry into plog.Logs aggregating translated entries into logs coming from the same Resource.

The diagram below illustrates the internal communication inside the Converter:

          ┌─────────────────────────────────┐
          │ Batch()                         │
┌─────────┤  Ingests batches of log entries │
│         │  and sends them onto workerChan │
│         └─────────────────────────────────┘
│
│ ┌───────────────────────────────────────────────────┐
├─► workerLoop()                                      │
│ │ ┌─────────────────────────────────────────────────┴─┐
├─┼─► workerLoop()                                      │
│ │ │ ┌─────────────────────────────────────────────────┴─┐
└─┼─┼─► workerLoop()                                      │
  └─┤ │   consumes sent log entries from workerChan,      │
    │ │   translates received entries to plog.LogRecords,│
    └─┤   hashes them to generate an ID, and sends them   │
      │   onto batchChan                                  │
      └─────────────────────────┬─────────────────────────┘
                                │
                                ▼
    ┌─────────────────────────────────────────────────────┐
    │ aggregationLoop()                                   │
    │   consumes from batchChan, aggregates log records   │
    │   by marshaled Resource and sends the               │
    │   aggregated buffer to flushChan                    │
    └───────────────────────────┬─────────────────────────┘
                                │
                                ▼
    ┌─────────────────────────────────────────────────────┐
    │ flushLoop()                                         │
    │   receives log records from flushChan and sends     │
    │   them onto pLogsChan which is consumed by          │
    │   downstream consumers via OutChannel()             │
    └─────────────────────────────────────────────────────┘

func NewConverter added in v0.25.0

func NewConverter(opts ...ConverterOption) *Converter

func (*Converter) Batch added in v0.25.0

func (c *Converter) Batch(e []*entry.Entry) error

Batch takes in an entry.Entry and sends it to an available worker for processing.

func (*Converter) OutChannel added in v0.25.0

func (c *Converter) OutChannel() <-chan plog.Logs

OutChannel returns the channel on which converted entries will be sent to.

func (*Converter) Start added in v0.25.0

func (c *Converter) Start()

func (*Converter) Stop added in v0.25.0

func (c *Converter) Stop()

type ConverterConfig added in v0.25.0

type ConverterConfig struct {
	// MaxFlushCount defines the maximum number of entries that can be
	// accumulated before flushing them for further processing.
	MaxFlushCount uint `mapstructure:"max_flush_count"`
	// FlushInterval defines how often to flush the converted and accumulated
	// log entries.
	FlushInterval time.Duration `mapstructure:"flush_interval"`
	// WorkerCount defines how many worker goroutines used for entry.Entry to
	// log records translation should be spawned.
	// By default: math.Max(1, runtime.NumCPU()/4) workers are spawned.
	WorkerCount int `mapstructure:"worker_count"`
}

ConverterConfig controls how the internal entry.Entry to plog.Logs converter works.

type ConverterOption added in v0.25.0

type ConverterOption interface {
	// contains filtered or unexported methods
}

func WithLogger added in v0.25.0

func WithLogger(logger *zap.Logger) ConverterOption

func WithWorkerCount added in v0.27.0

func WithWorkerCount(workerCount int) ConverterOption

type FromPdataConverter added in v0.51.0

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

FromPdataConverter converts a set of entry.Entry into plog.Logs

The diagram below illustrates the internal communication inside the FromPdataConverter:

          ┌─────────────────────────────────┐
          │ Batch()                         │
┌─────────┤  Ingests plog.Logs, splits up   │
│         │  and places them on workerChan  │
│         └─────────────────────────────────┘
│
│ ┌───────────────────────────────────────────────────┐
├─► workerLoop()                                      │
│ │ ┌─────────────────────────────────────────────────┴─┐
├─┼─► workerLoop()                                      │
│ │ │ ┌─────────────────────────────────────────────────┴─┐
└─┼─┼─► workerLoop()                                      │
  └─┤ │   consumes sent log entries from workerChan,      │
    │ │   translates received logs to entry.Entry,        │
    └─┤   and sends them along entriesChan                │
      └───────────────────────────────────────────────────┘

func NewFromPdataConverter added in v0.51.0

func NewFromPdataConverter(workerCount int, logger *zap.Logger) *FromPdataConverter

func (*FromPdataConverter) Batch added in v0.51.0

func (c *FromPdataConverter) Batch(pLogs plog.Logs) error

Batch takes in an set of plog.Logs and sends it to an available worker for processing.

func (*FromPdataConverter) OutChannel added in v0.51.0

func (c *FromPdataConverter) OutChannel() <-chan []*entry.Entry

OutChannel returns the channel on which converted entries will be sent to.

func (*FromPdataConverter) Start added in v0.51.0

func (c *FromPdataConverter) Start()

func (*FromPdataConverter) Stop added in v0.51.0

func (c *FromPdataConverter) Stop()

type InputConfig

type InputConfig map[string]interface{}

InputConfig is an alias that allows unmarshaling outside of mapstructure This is meant to be used only for the input operator

type LogEmitter

type LogEmitter struct {
	helper.OutputOperator
	// contains filtered or unexported fields
}

LogEmitter is a stanza operator that emits log entries to a channel

func NewLogEmitter

func NewLogEmitter(opts ...LogEmitterOption) *LogEmitter

NewLogEmitter creates a new receiver output

func (*LogEmitter) OutChannel added in v0.51.0

func (e *LogEmitter) OutChannel() <-chan []*entry.Entry

OutChannel returns the channel on which entries will be sent to.

func (*LogEmitter) Process

func (e *LogEmitter) Process(ctx context.Context, ent *entry.Entry) error

Process will emit an entry to the output channel

func (*LogEmitter) Start added in v0.41.0

func (e *LogEmitter) Start(_ operator.Persister) error

Start starts the goroutine(s) required for this operator

func (*LogEmitter) Stop

func (e *LogEmitter) Stop() error

Stop will close the log channel and stop running goroutines

type LogEmitterOption added in v0.41.0

type LogEmitterOption func(*LogEmitter)

func LogEmitterWithFlushInterval added in v0.41.0

func LogEmitterWithFlushInterval(flushInterval time.Duration) LogEmitterOption

LogEmitterWithFlushInterval returns an option that makes the LogEmitter use the specified flush interval

func LogEmitterWithLogger added in v0.41.0

func LogEmitterWithLogger(logger *zap.SugaredLogger) LogEmitterOption

LogEmitterWithLogger returns an option that makes the LogEmitter use the specified logger

func LogEmitterWithMaxBatchSize added in v0.41.0

func LogEmitterWithMaxBatchSize(maxBatchSize uint) LogEmitterOption

LogEmitterWithMaxBatchSize returns an option that makes the LogEmitter use the specified max batch size

type LogReceiverType

type LogReceiverType interface {
	Type() config.Type
	CreateDefaultConfig() config.Receiver
	BaseConfig(config.Receiver) BaseConfig
	DecodeInputConfig(config.Receiver) (*operator.Config, error)
}

LogReceiverType is the interface used by stanza-based log receivers

type OperatorConfigs

type OperatorConfigs []map[string]interface{}

OperatorConfigs is an alias that allows for unmarshaling outside of mapstructure Stanza operators should will be migrated to mapstructure for greater compatibility but this allows a temporary solution

Jump to

Keyboard shortcuts

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