config

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: 8 Imported by: 0

Documentation

Overview

Package config defines the configuration to be used to setup the metrics and traces for each stage of a KrakenD instances as well as the level of detail we want for each stage.

Index

Constants

View Source
const (
	// Namespace is the key under the Lura's "extra_config" root
	// section, for a valid config. See [config] documentation for
	// details.
	Namespace = "telemetry/opentelemetry"
)

Variables

View Source
var (
	TimeBucketsOpt = metric.WithExplicitBucketBoundaries(
		0.010, 0.020, 0.050, 0.075,
		0.100, 0.125, 0.150, 0.175,
		0.200, 0.250, 0.300, 0.350,
		0.500, 0.750, 1.000, 1.500,
		2.000, 3.500, 5.000, 10.000)

	SizeBucketsOpt = metric.WithExplicitBucketBoundaries(
		128, 256, 512, 1024,
		4*1024, 8*1024, 16*1024, 32*1024,
		64*1024, 4*64*1024, 8*64*1024, 16*64*1024,
		4*1024*1024, 16*1024*1024, 64*1024*1024,
	)
)
View Source
var ErrNoConfig = errors.New("no config found for opentelemetry")

ErrNoConfig is used to signal no config was found

Functions

func NormalizeURLPattern

func NormalizeURLPattern(u string) string

Types

type Attributes

type Attributes []KeyValue

func (Attributes) ToMap

func (a Attributes) ToMap() (map[string]string, error)

type BackendMetricOpts

type BackendMetricOpts struct {
	DisableStage       bool       `json:"disable_stage"`
	RoundTrip          bool       `json:"round_trip"`
	ReadPayload        bool       `json:"read_payload"`
	DetailedConnection bool       `json:"detailed_connection"`
	StaticAttributes   Attributes `json:"static_attributes"`
}

BackendMetricOpts provides the options for the metrics to be reported at the backend level.

DisableStage option means it will perevent to report metrics for ALLL the full backend part (request + manipulations at the backend level), so other fields will have no effect.

RoundTrip options will report metrics on the actual request made for this backend: latency, body size, response code...

ReadPayload will report the metrics about the reading the body content of the request (from first time to read, until all the body has been read). This last options gives extra fined grained times, that might not be always useful.

func (*BackendMetricOpts) Enabled

func (o *BackendMetricOpts) Enabled() bool

Enabled tells if there are any metrics to be reported.

type BackendOpts

type BackendOpts struct {
	Metrics *BackendMetricOpts `json:"metrics"`
	Traces  *BackendTraceOpts  `json:"traces"`
}

BackendOpts defines the instrumentation detail level for backend requests. SkipInstrumentationPaths allows us to provide a list of path that we do not want to have instrumentation for: those could be the __debug , __health, or __echo endpoint, for example.

func (*BackendOpts) Enabled

func (o *BackendOpts) Enabled() bool

Enabled returns if either metrics or traces enabled for the backend stage.

type BackendTraceOpts

type BackendTraceOpts struct {
	DisableStage       bool       `json:"disable_stage"`
	RoundTrip          bool       `json:"round_trip"`
	ReadPayload        bool       `json:"read_payload"`
	DetailedConnection bool       `json:"detailed_connection"`
	StaticAttributes   Attributes `json:"static_attributes"`
	ReportHeaders      bool       `json:"report_headers"`
}

BackendTraceOpts provides the options for the tracing to be reported at the backend level.

DisableStage means it will avoid creating a Span for ALL the full backend part (request + manipulations at the backend level), so other fields will have no effect.

RoundTrip options will create an span for the actual request made for this backend.

ReadPayload will create an additional span just for the reading the response body part.

func (*BackendTraceOpts) Enabled

func (o *BackendTraceOpts) Enabled() bool

Enabled tells if there are any traces to be reported.

type ConfigData

type ConfigData struct {
	ServiceName           string      `json:"service_name"`
	ServiceVersion        string      `json:"service_version"`
	Layers                *LayersOpts `json:"layers"`
	Exporters             Exporters   `json:"exporters"`
	SkipPaths             []string    `json:"skip_paths"`
	MetricReportingPeriod *int        `json:"metric_reporting_period"`
	TraceSampleRate       *float64    `json:"trace_sample_rate"`
}

ConfigData is the root configuration for the OTEL observability stack

func FromLura

func FromLura(srvCfg luraconfig.ServiceConfig) (*ConfigData, error)

FromLura extracts the configuration from the Lura's ServiceConfig "extra_config" field.

In case no "Layers" config is provided, a set of defaults with everything enabled will be used.

func (*ConfigData) UnsetFieldsToDefaults

func (c *ConfigData) UnsetFieldsToDefaults()

func (*ConfigData) Validate

func (c *ConfigData) Validate() error

type Exporters

type Exporters struct {
	OTLP       []OTLPExporter       `json:"otlp"`
	Prometheus []PrometheusExporter `json:"prometheus"`
}

func (*Exporters) Validate

func (e *Exporters) Validate() error

type GlobalOpts

type GlobalOpts struct {
	DisableMetrics     bool `json:"disable_metrics"`
	DisableTraces      bool `json:"disable_traces"`
	DisablePropagation bool `json:"disable_propagation"`
	ReportHeaders      bool `json:"report_headers"`
}

GlobalOpts has the options for the KrakenD http handler stage. We can select if we want to disable the metrics, the traces, and / or the trace propagation.

type KeyValue

type KeyValue struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

type LayersOpts

type LayersOpts struct {
	Global  *GlobalOpts  `json:"global"`
	Pipe    *PipeOpts    `json:"proxy"`
	Backend *BackendOpts `json:"backend"`
}

LayersOpts contains the level of telemetry detail that we want for each KrakenD stage

type OTLPExporter

type OTLPExporter struct {
	Name           string `json:"name"`
	Host           string `json:"host"`
	Port           int    `json:"port"`
	UseHTTP        bool   `json:"use_http"`
	DisableMetrics bool   `json:"disable_metrics"`
	DisableTraces  bool   `json:"disable_traces"`
}

type PipeOpts

type PipeOpts struct {
	DisableMetrics bool `json:"disable_metrics"`
	DisableTraces  bool `json:"disable_traces"`
	ReportHeaders  bool `json:"report_headers"`
}

PipeOpts has the options for the KrakenD pipe stage to disable metrics and traces.

func (*PipeOpts) Enabled

func (o *PipeOpts) Enabled() bool

Enabled returns if either metrics or traces are enabled for the pipe stage.

type PrometheusExporter

type PrometheusExporter struct {
	Name           string `json:"name"`
	NameSpace      string `json:"name_space"`
	Port           int    `json:"port"`
	Host           string `json:"host"`
	ProcessMetrics bool   `json:"process_metrics"`
	GoMetrics      bool   `json:"go_metrics"`
	DisableMetrics bool   `json:"disable_metrics"`
}

Jump to

Keyboard shortcuts

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