obsreport

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2023 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package obsreport provides unified and consistent observability signals ( metrics, tracing, etc) for components of the OpenTelemetry collector.

The function Configure is used to control which signals are going to be generated. It provides functions for the typical operations of receivers, processors, and exporters.

Receivers should use the respective start and end according to the data type being received, ie.:

  • Traces receive operations should use the pair: StartTracesOp/EndTracesOp

  • Metrics receive operations should use the pair: StartMetricsOp/EndMetricsOp

  • Logs receive operations should use the pair: StartLogsOp/EndLogsOp

Similar for exporters:

  • Traces export operations should use the pair: StartTracesOp/EndTracesOp

  • Metrics export operations should use the pair: StartMetricsOp/EndMetricsOp

  • Metrics export operations should use the pair: StartLogsOp/EndLogsOp

The package is capable of generating legacy metrics by using the observability package allowing a controlled transition from legacy to the new metrics. The goal is to eventually remove the legacy metrics and use only the new metrics.

The main differences regarding the legacy metrics are:

1. "Amount of metric data" is measured as metric points (ie.: a single value in time), contrast it with number of time series used legacy. Number of metric data points is a more general concept regarding various metric formats.

2. Exporters measure the number of items, ie.: number of spans or metric points, that were sent and the ones for which the attempt to send failed. For more information about this see Notes below about reporting data loss.

3. All measurements of "amount of data" used in the new metrics for receivers and exporters should reflect their native formats, not the internal format used in the Collector. This is to facilitate reconciliation between Collector, client and backend. For instance: certain metric formats do not provide direct support for histograms and have predefined conventions to represent those, this conversion may end with a different number of time series and data points than the internal Collector format.

Notes:

* Data loss should be recorded only when the component itself remove the data from the pipeline. Legacy metrics for receivers used "dropped" in their names but these could be non-zero under normal operations and reflected no actual data loss when exporters with "sending_queue" are used. New metrics were renamed to avoid this misunderstanding. Here are the general recommendations to report data loss:

  • Receivers reporting errors to clients typically result in the client re-sending the same data so it is more correct to report "receive errors", not actual data loss.

  • Exporters need to report individual failures to send data, but on typical production pipelines processors usually take care of retries, so these should be reported as "send errors".

  • Data "filtered out" should have its own metrics and not be confused with dropped data.

Naming Convention for New Metrics

Common Metrics: Metrics shared by different components should follow the convention below:

`<component>/<metric_name>`

As a label the metric should have at least `{<component>="<name>"}` where `<name>` is the name used in the configuration for the instance of the component, eg.:

`receiver/accepted_spans{receiver="otlp",...}` `exporter/sent_spans{exporter="otlp/prod",...}`

Component Specific Metrics: These metrics are implemented by specific components, eg.: batch processor. The general pattern is the same as the common metrics but with the addition of the component type (as it appears in the configuration) before the actual metric:

`<component>/<type>/<metric_name>`

Even metrics exclusive to a single type should follow the conventions above and also include the type (as written in the configuration) as part of the metric name since there could be multiple instances of the same type in different pipelines, eg.:

`processor/batch/batch_size_trigger_send{processor="batch/dev",...}`

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildProcessorCustomMetricName

func BuildProcessorCustomMetricName(configType, metric string) string

BuildProcessorCustomMetricName is used to be build a metric name following the standards used in the Collector. The configType should be the same value used to identify the type on the config.

Types

type Exporter

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

Exporter is a helper to add observability to an exporter.

func NewExporter

func NewExporter(cfg ExporterSettings) (*Exporter, error)

NewExporter creates a new Exporter.

func (*Exporter) EndLogsOp

func (exp *Exporter) EndLogsOp(ctx context.Context, numLogRecords int, err error)

EndLogsOp completes the export operation that was started with StartLogsOp.

func (*Exporter) EndMetricsOp

func (exp *Exporter) EndMetricsOp(ctx context.Context, numMetricPoints int, err error)

EndMetricsOp completes the export operation that was started with StartMetricsOp.

func (*Exporter) EndTracesOp

func (exp *Exporter) EndTracesOp(ctx context.Context, numSpans int, err error)

EndTracesOp completes the export operation that was started with StartTracesOp.

func (*Exporter) StartLogsOp

func (exp *Exporter) StartLogsOp(ctx context.Context) context.Context

StartLogsOp is called at the start of an Export operation. The returned context should be used in other calls to the Exporter functions dealing with the same export operation.

func (*Exporter) StartMetricsOp

func (exp *Exporter) StartMetricsOp(ctx context.Context) context.Context

StartMetricsOp is called at the start of an Export operation. The returned context should be used in other calls to the Exporter functions dealing with the same export operation.

func (*Exporter) StartTracesOp

func (exp *Exporter) StartTracesOp(ctx context.Context) context.Context

StartTracesOp is called at the start of an Export operation. The returned context should be used in other calls to the Exporter functions dealing with the same export operation.

type ExporterSettings

type ExporterSettings struct {
	ExporterID             component.ID
	ExporterCreateSettings exporter.CreateSettings
}

ExporterSettings are settings for creating an Exporter.

type Processor

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

Processor is a helper to add observability to a processor.

func NewProcessor

func NewProcessor(cfg ProcessorSettings) (*Processor, error)

NewProcessor creates a new Processor.

func (*Processor) LogsAccepted

func (por *Processor) LogsAccepted(ctx context.Context, numRecords int)

LogsAccepted reports that the logs were accepted.

func (*Processor) LogsDropped

func (por *Processor) LogsDropped(ctx context.Context, numRecords int)

LogsDropped reports that the logs were dropped.

func (*Processor) LogsRefused

func (por *Processor) LogsRefused(ctx context.Context, numRecords int)

LogsRefused reports that the logs were refused.

func (*Processor) MetricsAccepted

func (por *Processor) MetricsAccepted(ctx context.Context, numPoints int)

MetricsAccepted reports that the metrics were accepted.

func (*Processor) MetricsDropped

func (por *Processor) MetricsDropped(ctx context.Context, numPoints int)

MetricsDropped reports that the metrics were dropped.

func (*Processor) MetricsRefused

func (por *Processor) MetricsRefused(ctx context.Context, numPoints int)

MetricsRefused reports that the metrics were refused.

func (*Processor) TracesAccepted

func (por *Processor) TracesAccepted(ctx context.Context, numSpans int)

TracesAccepted reports that the trace data was accepted.

func (*Processor) TracesDropped

func (por *Processor) TracesDropped(ctx context.Context, numSpans int)

TracesDropped reports that the trace data was dropped.

func (*Processor) TracesRefused

func (por *Processor) TracesRefused(ctx context.Context, numSpans int)

TracesRefused reports that the trace data was refused.

type ProcessorSettings

type ProcessorSettings struct {
	ProcessorID             component.ID
	ProcessorCreateSettings processor.CreateSettings
}

ProcessorSettings are settings for creating a Processor.

type Receiver

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

Receiver is a helper to add observability to a receiver.

func NewReceiver

func NewReceiver(cfg ReceiverSettings) (*Receiver, error)

NewReceiver creates a new Receiver.

func (*Receiver) EndLogsOp

func (rec *Receiver) EndLogsOp(
	receiverCtx context.Context,
	format string,
	numReceivedLogRecords int,
	err error,
)

EndLogsOp completes the receive operation that was started with StartLogsOp.

func (*Receiver) EndMetricsOp

func (rec *Receiver) EndMetricsOp(
	receiverCtx context.Context,
	format string,
	numReceivedPoints int,
	err error,
)

EndMetricsOp completes the receive operation that was started with StartMetricsOp.

func (*Receiver) EndTracesOp

func (rec *Receiver) EndTracesOp(
	receiverCtx context.Context,
	format string,
	numReceivedSpans int,
	err error,
)

EndTracesOp completes the receive operation that was started with StartTracesOp.

func (*Receiver) StartLogsOp

func (rec *Receiver) StartLogsOp(operationCtx context.Context) context.Context

StartLogsOp is called when a request is received from a client. The returned context should be used in other calls to the obsreport functions dealing with the same receive operation.

func (*Receiver) StartMetricsOp

func (rec *Receiver) StartMetricsOp(operationCtx context.Context) context.Context

StartMetricsOp is called when a request is received from a client. The returned context should be used in other calls to the obsreport functions dealing with the same receive operation.

func (*Receiver) StartTracesOp

func (rec *Receiver) StartTracesOp(operationCtx context.Context) context.Context

StartTracesOp is called when a request is received from a client. The returned context should be used in other calls to the obsreport functions dealing with the same receive operation.

type ReceiverSettings

type ReceiverSettings struct {
	ReceiverID component.ID
	Transport  string
	// LongLivedCtx when true indicates that the context passed in the call
	// outlives the individual receive operation.
	// Typically the long lived context is associated to a connection,
	// eg.: a gRPC stream, for which many batches of data are received in individual
	// operations without a corresponding new context per operation.
	LongLivedCtx           bool
	ReceiverCreateSettings receiver.CreateSettings
}

ReceiverSettings are settings for creating an Receiver.

type Scraper

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

Scraper is a helper to add observability to a scraper.

func NewScraper

func NewScraper(cfg ScraperSettings) (*Scraper, error)

NewScraper creates a new Scraper.

func (*Scraper) EndMetricsOp

func (s *Scraper) EndMetricsOp(
	scraperCtx context.Context,
	numScrapedMetrics int,
	err error,
)

EndMetricsOp completes the scrape operation that was started with StartMetricsOp.

func (*Scraper) StartMetricsOp

func (s *Scraper) StartMetricsOp(ctx context.Context) context.Context

StartMetricsOp is called when a scrape operation is started. The returned context should be used in other calls to the obsreport functions dealing with the same scrape operation.

type ScraperSettings

type ScraperSettings struct {
	ReceiverID             component.ID
	Scraper                component.ID
	ReceiverCreateSettings receiver.CreateSettings
}

ScraperSettings are settings for creating a Scraper.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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