Documentation ¶
Index ¶
- Constants
- Variables
- func ContextWithTrace(parent context.Context, traceID trace.TraceID) context.Context
- func ContextWithTraceParent(parent context.Context, traceID trace.TraceID, spanID trace.SpanID) context.Context
- func GenerateTraces(span *request.Span, hostID string, userAttrs map[attr.Name]struct{}, ...) ptrace.Traces
- func GenerateTracesWithAttributes(span *request.Span, hostID string, attrs []attribute.KeyValue, ...) ptrace.Traces
- func GetUserSelectedAttributes(attrs attributes.Selection) (map[attr.Name]struct{}, error)
- func InstantiateMetricsExporter(ctx context.Context, cfg *MetricsConfig, log *slog.Logger) (metric.Exporter, error)
- func NetMetricsExporterProvider(ctx context.Context, ctxInfo *global.ContextInfo, cfg *NetMetricsConfig) (pipe.FinalFunc[[]*ebpf.Record], error)
- func ProcMetricsExporterProvider(ctx context.Context, ctxInfo *global.ContextInfo, cfg *ProcMetricsConfig) pipe.FinalProvider[[]*process.Status]
- func ReportMetrics(ctx context.Context, ctxInfo *global.ContextInfo, cfg *MetricsConfig, ...) pipe.FinalProvider[[]request.Span]
- func ResourceAttrsFromEnv(svc *svc.Attrs) []attribute.KeyValue
- func SetupInternalOTELSDKLogger(levelStr string)
- func TracesReceiver(ctx context.Context, cfg TracesConfig, ctxInfo *global.ContextInfo, ...) pipe.FinalProvider[[]request.Span]
- type BeylaIDGenerator
- type Buckets
- type Expirer
- type GrafanaConfig
- type GrafanaOTLP
- type LogrAdaptor
- func (l *LogrAdaptor) Enabled(level int) bool
- func (l *LogrAdaptor) Error(err error, msg string, keysAndValues ...interface{})
- func (l *LogrAdaptor) Info(level int, msg string, keysAndValues ...interface{})
- func (l *LogrAdaptor) Init(_ logr.RuntimeInfo)
- func (l *LogrAdaptor) WithName(name string) logr.LogSink
- func (l *LogrAdaptor) WithValues(keysAndValues ...interface{}) logr.LogSink
- type Metrics
- type MetricsConfig
- func (m *MetricsConfig) Enabled() bool
- func (m *MetricsConfig) EndpointEnabled() bool
- func (m *MetricsConfig) GetProtocol() Protocol
- func (m *MetricsConfig) GuessProtocol() Protocol
- func (m *MetricsConfig) NetworkMetricsEnabled() bool
- func (m *MetricsConfig) OTelMetricsEnabled() bool
- func (m *MetricsConfig) ServiceGraphMetricsEnabled() bool
- func (m *MetricsConfig) SpanMetricsEnabled() bool
- type MetricsReporter
- type NetMetricsConfig
- type ProcMetricsConfig
- type Protocol
- type ReporterPool
- type Sampler
- type TracesConfig
Constants ¶
const ( // SpanMetricsLatency and rest of metrics below haven't been yet moved to the // pkg/internal/export/metric package as we are disabling user-provided attribute // selection for them. They are very specific metrics with an opinionated format // for Span Metrics and Service Graph Metrics functionalities SpanMetricsLatency = "traces_spanmetrics_latency" SpanMetricsCalls = "traces_spanmetrics_calls_total" SpanMetricsSizes = "traces_spanmetrics_size_total" TracesTargetInfo = "traces_target_info" ServiceGraphClient = "traces_service_graph_request_client" ServiceGraphServer = "traces_service_graph_request_server" ServiceGraphFailed = "traces_service_graph_request_failed_total" ServiceGraphTotal = "traces_service_graph_request_total" UsualPortGRPC = "4317" UsualPortHTTP = "4318" AggregationExplicit = "explicit_bucket_histogram" AggregationExponential = "base2_exponential_bucket_histogram" FeatureNetwork = "network" FeatureApplication = "application" FeatureSpan = "application_span" FeatureGraph = "application_service_graph" FeatureProcess = "application_process" )
Variables ¶
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 ContextWithTrace ¶
func ContextWithTraceParent ¶
func GenerateTraces ¶
func GenerateTraces(span *request.Span, hostID string, userAttrs map[attr.Name]struct{}, envResourceAttrs []attribute.KeyValue) ptrace.Traces
GenerateTraces creates a ptrace.Traces from a request.Span
func GenerateTracesWithAttributes ¶ added in v1.8.5
func GetUserSelectedAttributes ¶
func GetUserSelectedAttributes(attrs attributes.Selection) (map[attr.Name]struct{}, error)
func InstantiateMetricsExporter ¶
func InstantiateMetricsExporter(ctx context.Context, cfg *MetricsConfig, log *slog.Logger) (metric.Exporter, error)
TODO: restore as private
func NetMetricsExporterProvider ¶
func NetMetricsExporterProvider(ctx context.Context, ctxInfo *global.ContextInfo, cfg *NetMetricsConfig) (pipe.FinalFunc[[]*ebpf.Record], error)
func ProcMetricsExporterProvider ¶
func ProcMetricsExporterProvider( ctx context.Context, ctxInfo *global.ContextInfo, cfg *ProcMetricsConfig, ) pipe.FinalProvider[[]*process.Status]
func ReportMetrics ¶
func ReportMetrics( ctx context.Context, ctxInfo *global.ContextInfo, cfg *MetricsConfig, userAttribSelection attributes.Selection, ) pipe.FinalProvider[[]request.Span]
func ResourceAttrsFromEnv ¶ added in v1.8.0
func SetupInternalOTELSDKLogger ¶
func SetupInternalOTELSDKLogger(levelStr string)
func TracesReceiver ¶
func TracesReceiver(ctx context.Context, cfg TracesConfig, ctxInfo *global.ContextInfo, userAttribSelection attributes.Selection) pipe.FinalProvider[[]request.Span]
TracesReceiver creates a terminal node that consumes request.Spans and sends OpenTelemetry metrics to the configured consumers.
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 Expirer ¶
type Expirer[Record any, Metric removableMetric[ValType], ValType any] struct { // contains filtered or unexported fields }
Expirer drops metrics from labels that haven't been updated during a given timeout. It has multiple generic types to allow it working with different dataPoints (FloatVal, IntCounter...) and different types of data (int, float...). Record: type of the record that holds the metric data request.Span, ebpf.Record, process.Status... Metric: type of the dataPoint kind: IntCounter, FloatVal... VT: type of the value inside the datapoint: int, float64...
func NewExpirer ¶
func NewExpirer[Record any, Metric removableMetric[ValType], ValType any]( ctx context.Context, metric Metric, attrs []attributes.Field[Record, attribute.KeyValue], clock expire.Clock, ttl time.Duration, ) *Expirer[Record, Metric, ValType]
NewExpirer creates an expirer that wraps data points of a given type. Its labeled instances are dropped if they haven't been updated during the last timeout period. Arguments: - instancer: the constructor of each datapoint object (e.g. NewIntCounter, NewFloatVal...) - attrs: attributes for that given data point - clock: function that provides the current time - ttl: time to live of the datapoints whose attribute sets haven't been updated
func (*Expirer[Record, Metric, ValType]) ForRecord ¶
func (ex *Expirer[Record, Metric, ValType]) ForRecord(r Record, extraAttrs ...attribute.KeyValue) (Metric, attribute.Set)
ForRecord returns the data point for the given eBPF record. If that record is accessed for the first time, a new data point is created. If not, a cached copy is returned and the "last access" cache time is updated. Extra attributes can be explicitly added (e.g. cpu_mode="wait")
func (*Expirer[Record, Metric, ValType]) RemoveAllMetrics ¶
RemoveAllMetrics is explicitly invoked when the metrics reporter of a given service instance needs to be shut down
type GrafanaConfig ¶
type GrafanaConfig struct { // OTLP endpoint from Grafana Cloud. OTLP GrafanaOTLP `yaml:"otlp"` }
GrafanaConfig simplifies the submission of information to Grafana Cloud, but it can be actually used for any OTEL endpoint, as it uses the standard OTEL authentication under the hood
type GrafanaOTLP ¶
type GrafanaOTLP struct { // Submit accepts a comma-separated list of the kind of data that will be submitted to the // OTLP endpoint. It accepts `metrics` and/or `traces` as values. Submit []string `yaml:"cloud_submit" env:"GRAFANA_CLOUD_SUBMIT"` // CloudZone of your Grafana Endpoint. For example: prod-eu-west-0. CloudZone string `yaml:"cloud_zone" env:"GRAFANA_CLOUD_ZONE"` // InstanceID is your Grafana user name. It is usually a number but it must be set as a // string inside the YAML file. InstanceID string `yaml:"cloud_instance_id" env:"GRAFANA_CLOUD_INSTANCE_ID"` // APIKey of your Grafana Cloud account. APIKey string `yaml:"cloud_api_key" env:"GRAFANA_CLOUD_API_KEY"` }
func (*GrafanaOTLP) AuthHeader ¶
func (cfg *GrafanaOTLP) AuthHeader() string
func (*GrafanaOTLP) Endpoint ¶
func (cfg *GrafanaOTLP) Endpoint() string
func (*GrafanaOTLP) MetricsEnabled ¶
func (cfg *GrafanaOTLP) MetricsEnabled() bool
func (*GrafanaOTLP) TracesEnabled ¶
func (cfg *GrafanaOTLP) TracesEnabled() bool
type LogrAdaptor ¶
type LogrAdaptor struct {
// contains filtered or unexported fields
}
LogrAdaptor allows using our on logger to peek any warning or error in the OTEL exporters
func (*LogrAdaptor) Enabled ¶
func (l *LogrAdaptor) Enabled(level int) bool
Enabled returns, according to OTEL internal description: To see Warn messages use a logger with `l.V(1).Enabled() == true` To see Info messages use a logger with `l.V(4).Enabled() == true` To see Debug messages use a logger with `l.V(8).Enabled() == true`. However, we will "degrade" their info messages to our log level, as they leak many internal information that is not interesting for the final user.
func (*LogrAdaptor) Error ¶
func (l *LogrAdaptor) Error(err error, msg string, keysAndValues ...interface{})
func (*LogrAdaptor) Info ¶
func (l *LogrAdaptor) Info(level int, msg string, keysAndValues ...interface{})
func (*LogrAdaptor) Init ¶
func (l *LogrAdaptor) Init(_ logr.RuntimeInfo)
func (*LogrAdaptor) WithValues ¶
func (l *LogrAdaptor) WithValues(keysAndValues ...interface{}) logr.LogSink
type Metrics ¶
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:"BEYLA_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:"BEYLA_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 // Deprecated. Going to be removed in Beyla 2.0. Use attributes.select instead ReportTarget bool `yaml:"report_target" env:"BEYLA_METRICS_REPORT_TARGET"` // Deprecated. Going to be removed in Beyla 2.0. Use attributes.select instead ReportPeerInfo bool `yaml:"report_peer" env:"BEYLA_METRICS_REPORT_PEER"` Buckets Buckets `yaml:"buckets"` HistogramAggregation string `yaml:"histogram_aggregation" env:"OTEL_EXPORTER_OTLP_METRICS_DEFAULT_HISTOGRAM_AGGREGATION"` ReportersCacheLen int `yaml:"reporters_cache_len" env:"BEYLA_METRICS_REPORT_CACHE_LEN"` // SDKLogLevel works independently from the global LogLevel because it prints GBs of logs in Debug mode // and the Info messages leak internal details that are not usually valuable for the final user. SDKLogLevel string `yaml:"otel_sdk_log_level" env:"BEYLA_OTEL_SDK_LOG_LEVEL"` // Features of metrics that are can be exported. Accepted values are "application" and "network". // envDefault is provided to avoid breaking changes Features []string `yaml:"features" env:"BEYLA_OTEL_METRICS_FEATURES,expand" envDefault:"${BEYLA_OTEL_METRIC_FEATURES}" envSeparator:","` // Allows configuration of which instrumentations should be enabled, e.g. http, grpc, sql... Instrumentations []string `yaml:"instrumentations" env:"BEYLA_OTEL_METRICS_INSTRUMENTATIONS" envSeparator:","` // TTL is the time since a metric was updated for the last time until it is // removed from the metrics set. TTL time.Duration `yaml:"ttl" env:"BEYLA_OTEL_METRICS_TTL"` AllowServiceGraphSelfReferences bool `yaml:"allow_service_graph_self_references" env:"BEYLA_OTEL_ALLOW_SERVICE_GRAPH_SELF_REFERENCES"` // Grafana configuration needs to be explicitly set up before building the graph Grafana *GrafanaOTLP `yaml:"-"` }
func (*MetricsConfig) Enabled ¶
func (m *MetricsConfig) Enabled() bool
func (*MetricsConfig) EndpointEnabled ¶
func (m *MetricsConfig) EndpointEnabled() bool
EndpointEnabled 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 ¶
func (m *MetricsConfig) GuessProtocol() Protocol
func (*MetricsConfig) NetworkMetricsEnabled ¶
func (m *MetricsConfig) NetworkMetricsEnabled() bool
func (*MetricsConfig) OTelMetricsEnabled ¶
func (m *MetricsConfig) OTelMetricsEnabled() bool
func (*MetricsConfig) ServiceGraphMetricsEnabled ¶
func (m *MetricsConfig) ServiceGraphMetricsEnabled() bool
func (*MetricsConfig) SpanMetricsEnabled ¶
func (m *MetricsConfig) SpanMetricsEnabled() bool
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 NetMetricsConfig ¶
type NetMetricsConfig struct { Metrics *MetricsConfig AttributeSelectors attributes.Selection GloballyEnabled bool }
NetMetricsConfig extends MetricsConfig for Network Metrics
func (NetMetricsConfig) Enabled ¶
func (mc NetMetricsConfig) Enabled() bool
type ProcMetricsConfig ¶
type ProcMetricsConfig struct { Metrics *MetricsConfig AttributeSelectors attributes.Selection }
ProcMetricsConfig extends MetricsConfig for process metrics
func (*ProcMetricsConfig) Enabled ¶
func (mc *ProcMetricsConfig) Enabled() bool
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/
type ReporterPool ¶
type ReporterPool[K uidGetter, T any] struct { // contains filtered or unexported fields }
ReporterPool keeps an LRU cache of different OTEL reporters given a service name.
func NewReporterPool ¶
func NewReporterPool[K uidGetter, T any]( cacheLen int, ttl time.Duration, clock expire.Clock, callback simplelru.EvictCallback[svc.UID, *expirable[T]], itemConstructor func(id K) (T, error), ) ReporterPool[K, 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[K, T]) For ¶
func (rp *ReporterPool[K, T]) For(service K) (T, error)
For retrieves the associated item for the given service name, or creates a new one if it does not exist
type Sampler ¶
type Sampler struct { Name string `yaml:"name" env:"OTEL_TRACES_SAMPLER"` Arg string `yaml:"arg" env:"OTEL_TRACES_SAMPLER_ARG"` }
Sampler standard configuration https://opentelemetry.io/docs/concepts/sdk-configuration/general-sdk-configuration/#otel_traces_sampler We don't support, yet, the jaeger and xray samplers.
func (*Sampler) Implementation ¶
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"` // Allows configuration of which instrumentations should be enabled, e.g. http, grpc, sql... Instrumentations []string `yaml:"instrumentations" env:"BEYLA_OTEL_TRACES_INSTRUMENTATIONS" envSeparator:","` // InsecureSkipVerify is not standard, so we don't follow the same naming convention InsecureSkipVerify bool `yaml:"insecure_skip_verify" env:"BEYLA_OTEL_INSECURE_SKIP_VERIFY"` Sampler Sampler `yaml:"sampler"` // 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:"BEYLA_OTLP_TRACES_MAX_EXPORT_BATCH_SIZE"` MaxQueueSize int `yaml:"max_queue_size" env:"BEYLA_OTLP_TRACES_MAX_QUEUE_SIZE"` BatchTimeout time.Duration `yaml:"batch_timeout" env:"BEYLA_OTLP_TRACES_BATCH_TIMEOUT"` ExportTimeout time.Duration `yaml:"export_timeout" env:"BEYLA_OTLP_TRACES_EXPORT_TIMEOUT"` // Configuration options for BackOffConfig of the traces exporter. // See https://github.com/open-telemetry/opentelemetry-collector/blob/main/config/configretry/backoff.go // BackOffInitialInterval the time to wait after the first failure before retrying. BackOffInitialInterval time.Duration `yaml:"backoff_initial_interval" env:"BEYLA_BACKOFF_INITIAL_INTERVAL"` // BackOffMaxInterval is the upper bound on backoff interval. BackOffMaxInterval time.Duration `yaml:"backoff_max_interval" env:"BEYLA_BACKOFF_MAX_INTERVAL"` // BackOffMaxElapsedTime is the maximum amount of time (including retries) spent trying to send a request/batch. BackOffMaxElapsedTime time.Duration `yaml:"backoff_max_elapsed_time" env:"BEYLA_BACKOFF_MAX_ELAPSED_TIME"` ReportersCacheLen int `yaml:"reporters_cache_len" env:"BEYLA_TRACES_REPORT_CACHE_LEN"` // SDKLogLevel works independently from the global LogLevel because it prints GBs of logs in Debug mode // and the Info messages leak internal details that are not usually valuable for the final user. SDKLogLevel string `yaml:"otel_sdk_log_level" env:"BEYLA_OTEL_SDK_LOG_LEVEL"` // Grafana configuration needs to be explicitly set up before building the graph Grafana *GrafanaOTLP `yaml:"-"` }
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