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 ¶
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 ¶
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, ) )
var ErrNoConfig = errors.New("no config found for opentelemetry")
ErrNoConfig is used to signal no config was found
Functions ¶
func NormalizeURLPattern ¶
Types ¶
type Attributes ¶
type Attributes []KeyValue
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 ¶ added in v0.2.0
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 ¶ added in v0.2.0
func (c *ConfigData) UnsetFieldsToDefaults()
func (*ConfigData) Validate ¶ added in v0.2.0
func (c *ConfigData) Validate() error
type Exporters ¶
type Exporters struct { OTLP []OTLPExporter `json:"otlp"` Prometheus []PrometheusExporter `json:"prometheus"` }
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 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