randomfailureprocessor

package module
v1.94.2 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

README

Random Failure Processor

The random failure processor is used for testing error resiliency in the collector.

Supported pipelines

  • Logs
  • Metrics
  • Traces

How it works

  1. The user configures the processor in one or more pipelines.
  2. Whenever telemetry passes through the processor, there is a user-configured probability that an error will be returned.

Configuration

Field Type Default Required Description
failure_rate float64 0.5 false The probability, between 0 and 1, of any given piece of telemetry causing an error.
error_message string "random failure" false The error message that will be returned by the processor.

Examples

Usage in pipelines

The random failure processor may be used in a pipeline in order to test what occurs when a section of the pipeline errors:

receivers:
  filelog:
    include: [/var/log/logfile.txt]

processors:
  randomfailure:
    failure_rate: 0.1
    error_message: "10% failure occurred!"

exporters:
  nop:

service:
  pipelines:
    logs:
      receivers: [filelog]
      processors: [randomfailure]
      exporters: [nop]

In this instance, each log from /var/log/logfile.txt has a 10% chance of generating an error when it passes through the processor.

Documentation

Overview

Package randomfailureprocessor provides a processor that randomly fails with a user-configured probability.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFactory

func NewFactory() processor.Factory

NewFactory creates a new factory for the processor.

Types

type Config

type Config struct {
	// FailureRate is the rate at which failures will occur.
	// This is a float between 0 and 1.
	// 0.5 means 50% of the time, a failure will occur.
	// 1.0 means 100% of the time, a failure will occur.
	// 0.0 means 0% of the time, a failure will occur.
	// Default is 0.5.
	FailureRate float64 `mapstructure:"failure_rate"`

	// ErrorMessage is the message that will be returned when a failure occurs.
	// Default is "random failure".
	ErrorMessage string `mapstructure:"error_message"`
}

Config is the config of the processor.

func (Config) Validate

func (c Config) Validate() error

Validate validates the processor configuration

Jump to

Keyboard shortcuts

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