sampler

package
v1.67.3 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Copyright 2020 New Relic Corporation. All rights reserved. SPDX-License-Identifier: Apache-2.0

Copyright 2020 New Relic Corporation. All rights reserved. SPDX-License-Identifier: Apache-2.0

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ExcludeProcessSampleMatchFn added in v1.67.3

type ExcludeProcessSampleMatchFn MatcherFn

ExcludeProcessSampleMatchFn func that returns whether an event/sample should be excluded, it satisfies the metrics matcher (processor.MatcherChain) interface.

type ExpressionMatcher

type ExpressionMatcher interface {
	// Evaluate compare property value with evaluator criteria and
	// return if it found a match
	Evaluate(event interface{}) bool
}

ExpressionMatcher is an interface every evaluator must implement

type IncludeProcessSampleMatchFn added in v1.67.3

type IncludeProcessSampleMatchFn MatcherFn

IncludeProcessSampleMatchFn func that returns whether an event/sample should be included, it satisfies the metrics matcher (processor.MatcherChain) interface.

type MatcherChain

type MatcherChain struct {
	Matchers map[string][]ExpressionMatcher
	Enabled  bool
}

MatcherChain is a chain of evaluators An evaluator chain stores for each attribute an array of evaluators Each evaluator represent a single rule that evaluates against the attribute Usually each attribute will have a single evaluator. For example: - process.name

  • "test"

- process.executable

  • "/bin/test"
  • regex "^/opt/newrelic/"

will create an evaluator chain with 2 entries. The first one will have 1 evaluator. The second 2 evaluators

func NewMatcherChain

func NewMatcherChain(expressions config.MetricsMap) MatcherChain

NewMatcherChain creates a new chain of matchers. Each expression will generate an matcher that gets added to the chain While the chain will be matched for each "sample", it terminates as soon as 1 match is matched (result = true)

func (MatcherChain) Evaluate

func (ec MatcherChain) Evaluate(event interface{}) bool

Evaluate returns the result of compare an event with a chain of matching rules return:

  • true, if event match with evaluator criteria chain
  • false, if event do not match with evaluator criteria chain

If there is no matchers will return true.

type MatcherFn added in v1.67.3

type MatcherFn func(event any) bool

MatcherFn func that returns whether an event/sample is matched. It satisfies the metrics matcher (processor.MatcherChain) interface.

func NewExcludeProcessSampleMatchFn added in v1.67.3

func NewExcludeProcessSampleMatchFn(metricsMatchers config.ExcludeMetricsMap) MatcherFn

NewExcludeProcessSampleMatchFn returns a function `func(sample) bool` that determinesif the sample should be excluded (true) as an event or not (false). Note that this is NOT the negation of `NewIncludeProcessSampleMatchFn`. In particular, we don't check here for the `enableProcessMetrics` being unset or disabled because it is checked before calling this function at `agent.NewAgent`. The exclude decision logic only applies to ProcessSamples. Other kinds of samples are never excluded.

func NewIncludeProcessSampleMatchFn added in v1.67.3

func NewIncludeProcessSampleMatchFn(enableProcessMetrics *bool, metricsMatchers config.IncludeMetricsMap, ffRetriever feature_flags.Retriever) MatcherFn

NewIncludeProcessSampleMatchFn returns a function `func(sample) bool` that determinesif the sample should be included (true) as an event or not (false). Note that this is NOT the negation of `NewExcludeProcessSampleMatchFn`. The include decision logic only applies to ProcessSamples. Other kinds of samples are always included.

type Sampler

type Sampler interface {
	Sample() (sample.EventBatch, error)
	OnStartup()
	Name() string
	Interval() time.Duration
	Disabled() bool
}

type SamplerRoutine

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

func StartSamplerRoutine

func StartSamplerRoutine(sampler Sampler, sampleQueue chan sample.EventBatch) *SamplerRoutine

func (*SamplerRoutine) Stop

func (sr *SamplerRoutine) Stop()

Jump to

Keyboard shortcuts

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