otelcollector

package
v0.1.3-rc.2 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2022 License: AGPL-3.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// MarshalledLabelsLabel describes labels relevant to this traffic.
	// This is JSON encoded field:
	// {
	//   "foo": "bar",
	//   "fizz": "buzz"
	// }.
	MarshalledLabelsLabel = "aperture.labels"
	// DurationLabel describes duration of the flow in milliseconds.
	// NOTE: not available on spans because the span timestamps are encoded natively.
	DurationLabel = "duration_millis"
	// MarshalledCheckResponseLabel contains JSON encoded check response struct.
	MarshalledCheckResponseLabel = "aperture.check_response"
	// ControlPointLabel describes control point which reported traffic.
	// May be 'ingress', 'egress' or 'feature'.
	ControlPointLabel = "control_point"
	// ControlPointIngress const for ingress control point.
	ControlPointIngress = "ingress"
	// ControlPointEgress const for egress control point.
	ControlPointEgress = "egress"
	// ControlPointFeature const for feature control point.
	ControlPointFeature = "feature"

	// LabeledLabel describes if there are any labels matched to traffic.
	LabeledLabel = "labeled"

	// MarshalledAuthzResponseLabel contains JSON encoded response from authz.
	MarshalledAuthzResponseLabel = "aperture.authz_response"

	// AuthzStatusLabel describes the status reported from authz processing.
	AuthzStatusLabel = "authz_status"

	// EnvoyMissingAttributeSourceValue is a special attribute value, which can
	// happen when (eg. Envoy's) logger tries to send attribute value, but its
	// source is missing. Eg. In case authz couldn't reach agent, so we know
	// nothing about flowcontrol policies.  Note that this is different case
	// from "just empty", eg. "", "[]" or "{}".
	EnvoyMissingAttributeSourceValue = "-"

	// HTTPStatusCodeLabel describes HTTP status code of the response.
	HTTPStatusCodeLabel = "http.status_code"
	// HTTPRequestContentLength describes length of the HTTP request content in bytes.
	HTTPRequestContentLength = "http.request_content_length"
	// HTTPResponseContentLength describes length of the HTTP response content in bytes.
	HTTPResponseContentLength = "http.response_content_length"
	// HTTPMethodLabel describes HTTP method of the request.
	HTTPMethodLabel = "http.method"
	// HTTPTargetLabel describes HTTP target of the request.
	HTTPTargetLabel = "http.target"
	// HTTPFlavorLabel describes HTTP flavor of the request.
	HTTPFlavorLabel = "http.flavor"
	// HTTPUserAgentLabel describes HTTP user agent of the request.
	HTTPUserAgentLabel = "http.user_agent"
	// HTTPHostLabel describes HTTP host of the request.
	HTTPHostLabel = "http.host"

	// EnvoyDurationLabel from envoy access logs.
	EnvoyDurationLabel = "DURATION"
	// EnvoyRequestDurationLabel from envoy access logs.
	EnvoyRequestDurationLabel = "REQUEST_DURATION"
	// EnvoyRequestTxDurationLabel from envoy access logs.
	EnvoyRequestTxDurationLabel = "REQUEST_TX_DURATION"
	// EnvoyResponseDurationLabel from envoy access logs.
	EnvoyResponseDurationLabel = "RESPONSE_DURATION"
	// EnvoyResponseTxDurationLabel from envoy access logs.
	EnvoyResponseTxDurationLabel = "RESPONSE_TX_DURATION"
	// EnvoyCallerLabel from envoy access logs.
	EnvoyCallerLabel = "caller"

	// DecisionTypeLabel describes the decision type taken by policy.
	DecisionTypeLabel = "decision_type"
	// DecisionErrorReasonLabel describes the error reason of the decision taken by policy.
	DecisionErrorReasonLabel = "decision_error_reason"
	// DecisionRejectReasonLabel describes the reject reason of the decision taken by policy.
	DecisionRejectReasonLabel = "decision_reject_reason"
	// RateLimitersLabel describes rate limiters matched to the traffic.
	RateLimitersLabel = "rate_limiters"
	// DroppingRateLimitersLabel describes rate limiters dropping the traffic.
	DroppingRateLimitersLabel = "dropping_rate_limiters"
	// ConcurrencyLimitersLabel describes rate limiters matched to the traffic.
	ConcurrencyLimitersLabel = "concurrency_limiters"
	// DroppingConcurrencyLimitersLabel describes rate limiters dropping the traffic.
	DroppingConcurrencyLimitersLabel = "dropping_concurrency_limiters"
	// WorkloadsLabel describes workloads matched to the traffic.
	WorkloadsLabel = "workloads"
	// DroppingWorkloadsLabel describes workloads dropping the traffic.
	DroppingWorkloadsLabel = "dropping_workloads"
	// FluxMetersLabel describes flux meters matched to the traffic.
	FluxMetersLabel = "flux_meters"
	// FlowLabelKeysLabel describes keys of flow labels matched to the traffic.
	FlowLabelKeysLabel = "flow_label_keys"
	// ClassifiersLabel describes classifiers matched to the traffic.
	ClassifiersLabel = "classifiers"

	// HostAddressLabel describes host address of the request.
	HostAddressLabel = "net.host.address"
	// PeerAddressLabel describes peer address of the request.
	PeerAddressLabel = "net.peer.address"
	// HostIPLabel describes host IP address of the request.
	HostIPLabel = "net.host.ip"
	// PeerIPLabel describes peer IP address of the request.
	PeerIPLabel = "net.peer.ip"

	// FeatureAddressLabel describes feature address of the request.
	FeatureAddressLabel = "feature.ip"
	// FeatureIDLabel describes the ID of the feature.
	FeatureIDLabel = "feature.id"
	// FeatureStatusLabel describes the status of the feature.
	FeatureStatusLabel = "feature.status"

	// EntityNameLabel describes entity name e.g. pod name.
	EntityNameLabel = "entity_name"

	// AgentGroupLabel describes cluster to which metrics refer.
	AgentGroupLabel = "agent_group"
	// ServicesLabel describes services to which metrics refer.
	ServicesLabel = "services"
)

Variables

View Source
var LogSampled log.Logger = log.Sample(&zerolog.BasicSampler{N: 1000})

LogSampled provides log sampling for OTEL collector.

RollupTypes contains all available rollup types.

Functions

func EnforceExcludeList added in v0.1.3

func EnforceExcludeList(attributes pcommon.Map, excludeList map[string]bool)

EnforceExcludeList enforces the given exclude list on the given attributes.

func EnforceIncludeList added in v0.1.3

func EnforceIncludeList(attributes pcommon.Map, includeList map[string]bool)

EnforceIncludeList enforces the given include list on the given attributes.

func FormExcludeList added in v0.1.3

func FormExcludeList(attributes []string) map[string]bool

FormExcludeList returns a map of all the keys in the given list with a value of false.

func FormIncludeList added in v0.1.3

func FormIncludeList(attributes []string) map[string]bool

FormIncludeList returns a map of all the keys in the given list with a value of true.

func GetFloat64 added in v0.1.3

func GetFloat64(attributes pcommon.Map, key string, treatAsZero []string) (float64, bool)

GetFloat64 returns float64 value from given attribute map at given key.

func GetStruct added in v0.1.3

func GetStruct(attributes pcommon.Map, label string, output interface{}, treatAsMissing []string) bool

GetStruct is a helper for decoding complex structs encoded into an attribute as a json-encoded string. Takes: attributes to read from label key to read in attributes output interface that is filled via json unmarshal treatAsMissing is a list of values that are treated as attribute missing from source

Returns true is label was decoded successfully, false otherwise.

func IterateDataPoints

func IterateDataPoints(metric pmetric.Metric, fn func(pcommon.Map) error) error

IterateDataPoints calls given function for each metric data point. If the function returns error further data point will not be processed and the error will be returned.

func IterateLogRecords

func IterateLogRecords(ld plog.Logs, fn func(plog.LogRecord) error) error

IterateLogRecords calls given function for each logRecord. If the function returns error further logRecords will not be processed and the error will be returned.

func IterateMetrics

func IterateMetrics(md pmetric.Metrics, fn func(pmetric.Metric) error) error

IterateMetrics calls given function for each metric. If the function returns error further metric will not be processed and the error will be returned.

func IterateSpans

func IterateSpans(td ptrace.Traces, fn func(ptrace.Span) error) error

IterateSpans calls given function for each span. If the function returns error further span will not be processed and the error will be returned.

func Max added in v0.1.3

func Max(a, b float64) float64

Max returns the maximum value of the given values.

func Min added in v0.1.3

func Min(a, b float64) float64

Min returns the minimum value of the given values.

func Module

func Module() fx.Option

Module is a fx module that invokes OTEL Collector.

Types

type ConstructorIn

type ConstructorIn struct {
	fx.In
	Lifecycle     fx.Lifecycle
	Shutdowner    fx.Shutdowner
	Factories     component.Factories
	Unmarshaller  config.Unmarshaller
	BaseConfig    *OTELConfig   `name:"base"`
	PluginConfigs []*OTELConfig `group:"plugin-config"`
}

ConstructorIn describes parameters passed to create OTEL Collector, server providing the OpenTelemetry Collector service.

type OTELConfig

type OTELConfig struct {
	Extensions map[string]interface{} `json:"extensions,omitempty"`
	Receivers  map[string]interface{} `json:"receivers,omitempty"`
	Processors map[string]interface{} `json:"processors,omitempty"`
	Exporters  map[string]interface{} `json:"exporters,omitempty"`
	Service    *OTELService           `json:"service"`
}

OTELConfig represents OTEL Collector configuration.

func NewOTELConfig

func NewOTELConfig() *OTELConfig

NewOTELConfig creates new empty OTELConfig.

func (*OTELConfig) AddBatchProcessor

func (o *OTELConfig) AddBatchProcessor(name string, timeout time.Duration, sendBatchSize uint32)

AddBatchProcessor is a helper function for adding batch processor.

func (*OTELConfig) AddDebugExtensions

func (o *OTELConfig) AddDebugExtensions()

AddDebugExtensions adds common debug extextions and enables them.

func (*OTELConfig) AddExporter

func (o *OTELConfig) AddExporter(name string, value interface{})

AddExporter adds receiver to OTEL config.

func (*OTELConfig) AddExtension

func (o *OTELConfig) AddExtension(name string, value interface{})

AddExtension adds given extension and enables it in service.

func (*OTELConfig) AddProcessor

func (o *OTELConfig) AddProcessor(name string, value interface{})

AddProcessor adds receiver to OTEL config.

func (*OTELConfig) AddReceiver

func (o *OTELConfig) AddReceiver(name string, value interface{})

AddReceiver adds receiver to OTEL config.

func (*OTELConfig) AsMap

func (o *OTELConfig) AsMap() map[string]interface{}

AsMap returns map representation of OTELConfig.

type OTELConfigUnmarshaller

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

OTELConfigUnmarshaller can be used as an OTEL config map provider.

func NewOTELConfigUnmarshaler

func NewOTELConfigUnmarshaler(config map[string]interface{}) *OTELConfigUnmarshaller

NewOTELConfigUnmarshaler creates a new OTELConfigUnmarshaler instance.

func (*OTELConfigUnmarshaller) Retrieve

Retrieve returns the value to be injected in the configuration and the corresponding watcher.

func (*OTELConfigUnmarshaller) Scheme

func (u *OTELConfigUnmarshaller) Scheme() string

Scheme returns the scheme name, location scheme used by Retrieve.

func (*OTELConfigUnmarshaller) Shutdown

func (u *OTELConfigUnmarshaller) Shutdown(ctx context.Context) error

Shutdown indicates the provider should close.

type OTELService

type OTELService struct {
	Telemetry  map[string]interface{}
	Pipelines  map[string]Pipeline
	Extensions []string
}

OTELService represents service in OTEL Config.

func NewOTELService

func NewOTELService() *OTELService

NewOTELService returns new empty OTEL Service.

func (*OTELService) AddPipeline

func (o *OTELService) AddPipeline(name string, pipeline Pipeline)

AddPipeline adds pipeline to OTEL Service.

func (*OTELService) AsMap

func (o *OTELService) AsMap() map[string]interface{}

AsMap returns map representation of OTELService.

func (*OTELService) Pipeline

func (o *OTELService) Pipeline(name string) (Pipeline, bool)

Pipeline gets pipeline with given name from OTEL Service together with `exists` bool.

type Pipeline

type Pipeline struct {
	Receivers  []string
	Processors []string
	Exporters  []string
}

Pipeline represents OTEL Config pipeline.

func (*Pipeline) AsMap

func (p *Pipeline) AsMap() map[string]interface{}

AsMap returns map representation of Pipeline.

type Rollup added in v0.1.3

type Rollup struct {
	FromField   string     `mapstructure:"from"`
	ToField     string     `mapstructure:"to"`
	Type        RollupType `mapstructure:"type"`
	TreatAsZero []string   `mapstructure:"treat_as_zero"`
}

Rollup represents singe rollup operation. It describes Type of operation to be done on all `FromField`s from logs/traces. Result of operation is stored in `ToField`.

func (*Rollup) GetFromFieldValue added in v0.1.3

func (rollup *Rollup) GetFromFieldValue(attributes pcommon.Map) (float64, bool)

GetFromFieldValue returns value of `FromField` from attributes as float64.

func (*Rollup) GetToFieldValue added in v0.1.3

func (rollup *Rollup) GetToFieldValue(attributes pcommon.Map) (float64, bool)

GetToFieldValue returns value of `ToField` from attributes as float64.

type RollupType added in v0.1.3

type RollupType string

RollupType represents rollup type available in the processor.

const (
	// RollupSum rolls up fields by adding them.
	RollupSum RollupType = "sum"
	// RollupMax rolls up fields by getting max value of them.
	RollupMax RollupType = "max"
	// RollupMin rolls up fields by getting min value of them.
	RollupMin RollupType = "min"
	// RollupSumOfSquares rolls up fields by summing squares of them.
	RollupSumOfSquares RollupType = "sumOfSquares"
	// RollupDatasketch rolls up fields by creating datasketch from them.
	RollupDatasketch RollupType = "datasketch"
)

Directories

Path Synopsis
Package loggingexporter exports data to console as logs.
Package loggingexporter exports data to console as logs.

Jump to

Keyboard shortcuts

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