state

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package state provides the functionality to "pack" into a single structure a set of configured instances (exporters, meters, tracers...)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetGlobalConfig

func SetGlobalConfig(cfg Config)

func SetGlobalState

func SetGlobalState(s *OTELState)

SetGlobalState set the provided state as the global state.

Types

type Config

type Config interface {
	OTEL() OTEL
	GlobalOpts() *config.GlobalOpts

	// Gets the OTEL instance for a given endpoint
	EndpointOTEL(cfg *luraconfig.EndpointConfig) OTEL
	EndpointPipeOpts(cfg *luraconfig.EndpointConfig) *config.PipeOpts
	EndpointBackendOpts(cfg *luraconfig.Backend) *config.BackendOpts

	BackendOTEL(cfg *luraconfig.Backend) OTEL
	BackendOpts(cfg *luraconfig.Backend) *config.BackendOpts

	// SkipEndpoint tells if an endpoint should not be instrumented
	SkipEndpoint(endpoint string) bool
}

func GlobalConfig

func GlobalConfig() Config

type GetterFn

type GetterFn func() OTEL

GetterFn defines a function that will return an OTEL instance.

type OTEL

type OTEL interface {
	Tracer() trace.Tracer
	Meter() metric.Meter
	Propagator() propagation.TextMapPropagator
	Shutdown(ctx context.Context)
	MeterProvider() metric.MeterProvider
	TracerProvider() trace.TracerProvider
}

OTEL defines the interface to obtain observability instruments for a state.

func GlobalState

func GlobalState() OTEL

GlobalState retrieves a configured global state

type OTELState

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

OTELState is the basic implementation of an OTEL intstance.

func NewWithVersion

func NewWithVersion(serviceName string, cfg *OTELStateConfig, version string,
	me map[string]exporter.MetricReader, te map[string]exporter.SpanExporter,
) (*OTELState, error)

NewWithVersion create a new OTELState with a version for the KrakenD service, with the provided metrics and traces exporters

func (*OTELState) Meter

func (s *OTELState) Meter() metric.Meter

Meter returns a meter to create metric instruments.

func (*OTELState) MeterProvider

func (s *OTELState) MeterProvider() metric.MeterProvider

func (*OTELState) Propagator

func (s *OTELState) Propagator() propagation.TextMapPropagator

Propagator returns the configured propagator to use.

func (*OTELState) Shutdown

func (s *OTELState) Shutdown(ctx context.Context)

Shutdown performs the clean shutdown to be able to flush pending traces and / or metrics.

func (*OTELState) Tracer

func (s *OTELState) Tracer() trace.Tracer

Tracer returns a tracer to start a span.

func (*OTELState) TracerProvider

func (s *OTELState) TracerProvider() trace.TracerProvider

type OTELStateConfig

type OTELStateConfig struct {
	MetricProviders       []string `json:"metric_providers"`
	TraceProviders        []string `json:"trace_providers"`
	MetricReportingPeriod int      `json:"metric_reporting_period"`
	TraceSampleRate       float64  `json:"trace_sample_rate"`
}

type StateConfig

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

func NewConfig

func NewConfig(cfgData *config.ConfigData) *StateConfig

func (*StateConfig) BackendOTEL

func (*StateConfig) BackendOTEL(_ *luraconfig.Backend) OTEL

func (*StateConfig) BackendOpts

func (s *StateConfig) BackendOpts(_ *luraconfig.Backend) *config.BackendOpts

func (*StateConfig) EndpointBackendOpts

func (s *StateConfig) EndpointBackendOpts(_ *luraconfig.Backend) *config.BackendOpts

func (*StateConfig) EndpointOTEL

func (*StateConfig) EndpointOTEL(_ *luraconfig.EndpointConfig) OTEL

func (*StateConfig) EndpointPipeOpts

func (s *StateConfig) EndpointPipeOpts(_ *luraconfig.EndpointConfig) *config.PipeOpts

func (*StateConfig) GlobalOpts

func (s *StateConfig) GlobalOpts() *config.GlobalOpts

func (*StateConfig) OTEL

func (*StateConfig) OTEL() OTEL

func (*StateConfig) SkipEndpoint

func (s *StateConfig) SkipEndpoint(endpoint string) bool

Jump to

Keyboard shortcuts

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