telemetry

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Data

type Data struct {
	// ProjectName is the name of the project.
	ProjectName string
	// ProjectVersion is the version of the project.
	ProjectVersion string
	// ProjectArchitecture is the architecture of the project. For example, "amd64".
	ProjectArchitecture string
	// ClusterID is the unique id of the Kubernetes cluster where the project is installed.
	// It is the UID of the `kube-system` Namespace.
	ClusterID string
	// ClusterVersion is the Kubernetes version of the cluster.
	ClusterVersion string
	// ClusterPlatform is the Kubernetes platform of the cluster.
	ClusterPlatform string
	// InstallationID is the unique id of the project installation in the cluster.
	InstallationID string
	// ClusterNodeCount is the number of nodes in the cluster.
	ClusterNodeCount int64
}

Data defines common telemetry data points for NGINX Kubernetes-related projects.

func (*Data) Attributes

func (d *Data) Attributes() []attribute.KeyValue

type ErrorHandler

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

ErrorHandler capture errors generated by the OpenTelemetry SDK. If multiple errors occur, the last error is captured.

func NewErrorHandler

func NewErrorHandler() *ErrorHandler

NewErrorHandler creates a new ErrorHandler.

func (*ErrorHandler) Clear

func (e *ErrorHandler) Clear()

Clear clears the error.

func (*ErrorHandler) Error

func (e *ErrorHandler) Error() error

Error returns the last error captured.

func (*ErrorHandler) Handle

func (e *ErrorHandler) Handle(err error)

Handle captures the error.

type Exportable

type Exportable interface {
	// Attributes returns a list of key-value pairs that represent the telemetry data.
	Attributes() []attribute.KeyValue
}

Exportable allows exporting telemetry data using the Exporter.

type Exporter

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

Exporter exports telemetry data.

func NewExporter

func NewExporter(cfg ExporterConfig, options ...Option) (*Exporter, error)

NewExporter creates a new Exporter.

func (*Exporter) Export

func (e *Exporter) Export(ctx context.Context, exportable Exportable) error

Export exports telemetry data.

func (*Exporter) Shutdown

func (e *Exporter) Shutdown(ctx context.Context) error

Shutdown shuts down the Exporter.

type ExporterConfig

type ExporterConfig struct {
	// SpanProvider contains SpanProvider for exporting spans.
	SpanProvider SpanProvider
}

ExporterConfig contains the configuration for the Exporter.

type Option

type Option func(*optionsCfg)

Option is a configuration option for the Exporter.

func WithGlobalOTelErrorHandler

func WithGlobalOTelErrorHandler(errorHandler *ErrorHandler) Option

WithGlobalOTelErrorHandler sets the global OpenTelemetry error handler.

Note that the error handler captures all errors generated by the OpenTelemetry SDK. The Exporter uses it to catch errors that occur during exporting. If this option is not used, the Exporter will not be able to catch errors that occur during the export process.

Warning: This option changes the global OpenTelemetry state. If OpenTelemetry is used in other parts of your application, the error handler will catch errors from those parts as well. As a result, the Exporter might return errors when exporting telemetry data, even if no error occurred.

func WithGlobalOTelLogger

func WithGlobalOTelLogger(logger logr.Logger) Option

WithGlobalOTelLogger sets the global OpenTelemetry logger. The logger is used by the OpenTelemetry SDK to log messages.

Warning: This option changes the global OpenTelemetry state. If OpenTelemetry is used in other parts of your application, the logger will be used for those parts as well.

type SpanExporter

type SpanExporter interface {
	sdktrace.SpanExporter
}

SpanExporter is used to generate a fake for the unit test.

type SpanProvider

type SpanProvider func(ctx context.Context) (sdktrace.SpanExporter, error)

SpanProvider provides a span exporter.

func CreateOTLPSpanProvider

func CreateOTLPSpanProvider(options ...otlptracegrpc.Option) SpanProvider

CreateOTLPSpanProvider creates a new gRPC OTLP span provider. The options allow you to configure the remote endpoint and tune the behavior of the exporter. See https://pkg.go.dev/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc#Option for details.

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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