otel

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2023 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HTTPServerDuration    = "http.server.duration"
	HTTPClientDuration    = "http.client.duration"
	RPCServerDuration     = "rpc.server.duration"
	RPCClientDuration     = "rpc.client.duration"
	SQLClientDuration     = "sql.client.duration"
	HTTPServerRequestSize = "http.server.request.size"
	HTTPClientRequestSize = "http.client.request.size"

	UsualPortGRPC = "4317"
	UsualPortHTTP = "4318"
)

Variables

View Source
var DefaultBuckets = Buckets{

	DurationHistogram: []float64{0, 0.005, 0.01, 0.025, 0.05, 0.075, 0.1, 0.25, 0.5, 0.75, 1, 2.5, 5, 7.5, 10},

	RequestSizeHistogram: []float64{0, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192},
}

Functions

func ReportMetrics

func ReportMetrics(
	ctx context.Context, cfg *MetricsConfig, ctxInfo *global.ContextInfo,
) (node.TerminalFunc[[]request.Span], error)

func ReportTraces

func ReportTraces(ctx context.Context, cfg *TracesConfig, ctxInfo *global.ContextInfo) (node.TerminalFunc[[]request.Span], error)

Types

type Buckets

type Buckets struct {
	DurationHistogram    []float64 `yaml:"duration_histogram"`
	RequestSizeHistogram []float64 `yaml:"request_size_histogram"`
}

Buckets defines the histograms bucket boundaries, and allows users to redefine them

type Metrics added in v0.1.0

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

Metrics is a set of metrics associated to a given OTEL MeterProvider. There is a Metrics instance for each service/process instrumented by Beyla.

type MetricsConfig

type MetricsConfig struct {
	Interval time.Duration `yaml:"interval" env:"METRICS_INTERVAL"`

	CommonEndpoint  string `yaml:"-" env:"OTEL_EXPORTER_OTLP_ENDPOINT"`
	MetricsEndpoint string `yaml:"endpoint" env:"OTEL_EXPORTER_OTLP_METRICS_ENDPOINT"`

	Protocol        Protocol `yaml:"protocol" env:"OTEL_EXPORTER_OTLP_PROTOCOL"`
	MetricsProtocol Protocol `yaml:"-" env:"OTEL_EXPORTER_OTLP_METRICS_PROTOCOL"`

	// InsecureSkipVerify is not standard, so we don't follow the same naming convention
	InsecureSkipVerify bool `yaml:"insecure_skip_verify" env:"OTEL_INSECURE_SKIP_VERIFY"`

	// ReportTarget specifies whether http.target should be submitted as a metric attribute. It is disabled by
	// default to avoid cardinality explosion in paths with IDs. In that case, it is recommended to group these
	// requests in the Routes node
	ReportTarget   bool `yaml:"report_target" env:"METRICS_REPORT_TARGET"`
	ReportPeerInfo bool `yaml:"report_peer" env:"METRICS_REPORT_PEER"`

	Buckets Buckets `yaml:"buckets"`

	ReportersCacheLen int `yaml:"reporters_cache_len" env:"METRICS_REPORT_CACHE_LEN"`
}

func (MetricsConfig) Enabled

func (m MetricsConfig) Enabled() bool

Enabled specifies that the OTEL metrics node is enabled if and only if either the OTEL endpoint and OTEL metrics endpoint is defined. If not enabled, this node won't be instantiated Reason to disable linting: it requires to be a value despite it is considered a "heavy struct". This method is invoked only once during startup time so it doesn't have a noticeable performance impact. nolint:gocritic

func (*MetricsConfig) GetProtocol

func (m *MetricsConfig) GetProtocol() Protocol

func (*MetricsConfig) GuessProtocol added in v0.2.0

func (m *MetricsConfig) GuessProtocol() Protocol

type MetricsReporter

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

MetricsReporter implements the graph node that receives request.Span instances and forwards them as OTEL metrics.

type Protocol

type Protocol string

Protocol values for the OTEL_EXPORTER_OTLP_PROTOCOL, OTEL_EXPORTER_OTLP_TRACES_PROTOCOL and OTEL_EXPORTER_OTLP_METRICS_PROTOCOL standard configuration values More info: https://opentelemetry.io/docs/concepts/sdk-configuration/otlp-exporter-configuration/

const (
	ProtocolUnset        Protocol = ""
	ProtocolGRPC         Protocol = "grpc"
	ProtocolHTTPProtobuf Protocol = "http/protobuf"
	ProtocolHTTPJSON     Protocol = "http/json"
)

type ReporterPool added in v0.1.0

type ReporterPool[T any] struct {
	// contains filtered or unexported fields
}

ReporterPool keeps an LRU cache of different OTEL reporters given a service name. TODO: evict reporters after a time without being accessed

func NewReporterPool added in v0.1.0

func NewReporterPool[T any](
	cacheLen int,
	callback simplelru.EvictCallback[svc.ID, T],
	itemConstructor func(id svc.ID) (T, error),
) ReporterPool[T]

NewReporterPool creates a ReporterPool instance given a cache length, an eviction callback to be invoked each time an element is removed from the cache, and a constructor function that will specify how to instantiate the generic OTEL metrics/traces reporter.

func (*ReporterPool[T]) For added in v0.1.0

func (rp *ReporterPool[T]) For(service svc.ID) (T, error)

For retrieves the associated item for the given service name, or creates a new one if it does not exist

type SessionSpan

type SessionSpan struct {
	ReqSpan request.Span
	RootCtx context.Context
}

type Tracers added in v0.1.0

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

Tracers handles the OTEL traces providers and exporters. There is a Tracers instance for each instrumented service/process.

type TracesConfig

type TracesConfig struct {
	CommonEndpoint string `yaml:"-" env:"OTEL_EXPORTER_OTLP_ENDPOINT"`
	TracesEndpoint string `yaml:"endpoint" env:"OTEL_EXPORTER_OTLP_TRACES_ENDPOINT"`

	Protocol       Protocol `yaml:"protocol" env:"OTEL_EXPORTER_OTLP_PROTOCOL"`
	TracesProtocol Protocol `yaml:"-" env:"OTEL_EXPORTER_OTLP_TRACES_PROTOCOL"`

	// InsecureSkipVerify is not standard, so we don't follow the same naming convention
	InsecureSkipVerify bool `yaml:"insecure_skip_verify" env:"OTEL_INSECURE_SKIP_VERIFY"`

	SamplingRatio float64 `yaml:"sampling_ratio" env:"OTEL_TRACE_SAMPLING_RATIO"`

	// Configuration options below this line will remain undocumented at the moment,
	// but can be useful for performance-tuning of some customers.
	MaxExportBatchSize int           `yaml:"max_export_batch_size" env:"OTLP_TRACES_MAX_EXPORT_BATCH_SIZE"`
	MaxQueueSize       int           `yaml:"max_queue_size" env:"OTLP_TRACES_MAX_QUEUE_SIZE"`
	BatchTimeout       time.Duration `yaml:"batch_timeout" env:"OTLP_TRACES_BATCH_TIMEOUT"`
	ExportTimeout      time.Duration `yaml:"export_timeout" env:"OTLP_TRACES_EXPORT_TIMEOUT"`

	ReportersCacheLen int `yaml:"reporters_cache_len" env:"METRICS_REPORT_CACHE_LEN"`
}

func (TracesConfig) Enabled

func (m TracesConfig) Enabled() bool

Enabled specifies that the OTEL traces node is enabled if and only if either the OTEL endpoint and OTEL traces endpoint is defined. If not enabled, this node won't be instantiated

func (*TracesConfig) GetProtocol

func (m *TracesConfig) GetProtocol() Protocol

func (*TracesConfig) GuessProtocol added in v0.2.0

func (m *TracesConfig) GuessProtocol() Protocol

type TracesReporter

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

TracesReporter implement the graph node that receives request.Span instances and forwards them as OTEL traces.

Jump to

Keyboard shortcuts

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