Documentation ¶
Index ¶
- Constants
- Variables
- func ClientAddr(val string) attribute.KeyValue
- func ClientPort(val int) attribute.KeyValue
- func ContextWithTrace(parent context.Context, traceID trace.TraceID) context.Context
- func ContextWithTraceParent(parent context.Context, traceID trace.TraceID, spanID trace.SpanID) context.Context
- func HTTPRequestBodySize(val int) attribute.KeyValue
- func HTTPRequestMethod(val string) attribute.KeyValue
- func HTTPResponseBodySize(val int) attribute.KeyValue
- func HTTPResponseStatusCode(val int) attribute.KeyValue
- func HTTPUrlFull(val string) attribute.KeyValue
- func HTTPUrlPath(val string) attribute.KeyValue
- func HandleTraceparent(parentCtx context.Context, span *request.Span) context.Context
- func InstantiateMetricsExporter(ctx context.Context, cfg *MetricsConfig, log *slog.Logger) (metric.Exporter, error)
- func ReportMetrics(ctx context.Context, cfg *MetricsConfig, ctxInfo *global.ContextInfo) (node.TerminalFunc[[]request.Span], error)
- func ReportTraces(ctx context.Context, cfg *TracesConfig, ctxInfo *global.ContextInfo) (node.TerminalFunc[[]request.Span], error)
- func ServerAddr(val string) attribute.KeyValue
- func ServerPort(val int) attribute.KeyValue
- func SetupInternalOTELSDKLogger(levelStr string)
- func SpanKind(span *request.Span) trace2.SpanKind
- func SpanStartTime(t request.Timings) time.Time
- func SpanStatusCode(span *request.Span) codes.Code
- func TraceAttributes(span *request.Span) []attribute.KeyValue
- func TraceName(span *request.Span) string
- type BeylaIDGenerator
- type Buckets
- 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
- type MetricsReporter
- type Protocol
- type ReporterPool
- type Sampler
- type Tracers
- type TracesConfig
- type TracesReporter
Constants ¶
const ( HTTPRequestMethodKey = attribute.Key("http.request.method") HTTPResponseStatusCodeKey = attribute.Key("http.response.status_code") HTTPUrlPathKey = attribute.Key("url.path") HTTPUrlFullKey = attribute.Key("url.full") ClientAddrKey = attribute.Key("client.address") ClientPortKey = attribute.Key("client.port") ServerAddrKey = attribute.Key("server.address") ServerPortKey = attribute.Key("server.port") HTTPRequestBodySizeKey = attribute.Key("http.request.body.size") HTTPResponseBodySizeKey = attribute.Key("http.response.body.size") )
OpenTelemetry 1.23 semantic convention
const ( HTTPServerDuration = "http.server.request.duration" HTTPClientDuration = "http.client.request.duration" RPCServerDuration = "rpc.server.duration" RPCClientDuration = "rpc.client.duration" SQLClientDuration = "sql.client.duration" HTTPServerRequestSize = "http.server.request.body.size" HTTPClientRequestSize = "http.client.request.body.size" UsualPortGRPC = "4317" UsualPortHTTP = "4318" AggregationExplicit = "explicit_bucket_histogram" AggregationExponential = "base2_exponential_bucket_histogram" )
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 ClientAddr ¶ added in v0.4.2
func ClientPort ¶ added in v0.4.2
func ContextWithTrace ¶ added in v1.1.0
func ContextWithTraceParent ¶ added in v1.1.0
func HTTPRequestBodySize ¶ added in v0.4.2
func HTTPRequestMethod ¶ added in v0.4.2
func HTTPResponseBodySize ¶ added in v0.4.2
func HTTPResponseStatusCode ¶ added in v0.4.2
func HTTPUrlFull ¶ added in v0.4.2
func HTTPUrlPath ¶ added in v0.4.2
func HandleTraceparent ¶ added in v1.4.0
func InstantiateMetricsExporter ¶ added in v1.3.0
func InstantiateMetricsExporter(ctx context.Context, cfg *MetricsConfig, log *slog.Logger) (metric.Exporter, error)
TODO: restore as private
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)
func ServerAddr ¶ added in v0.4.2
func ServerPort ¶ added in v0.4.2
func SetupInternalOTELSDKLogger ¶ added in v0.4.1
func SetupInternalOTELSDKLogger(levelStr string)
func TraceAttributes ¶ added in v1.4.0
Types ¶
type BeylaIDGenerator ¶ added in v1.1.0
type BeylaIDGenerator struct{}
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 GrafanaConfig ¶ added in v0.4.1
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 ¶ added in v0.4.1
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 ¶ added in v0.4.1
func (cfg *GrafanaOTLP) AuthHeader() string
func (*GrafanaOTLP) Endpoint ¶ added in v0.4.1
func (cfg *GrafanaOTLP) Endpoint() string
func (*GrafanaOTLP) MetricsEnabled ¶ added in v0.4.1
func (cfg *GrafanaOTLP) MetricsEnabled() bool
func (*GrafanaOTLP) TracesEnabled ¶ added in v0.4.1
func (cfg *GrafanaOTLP) TracesEnabled() bool
type LogrAdaptor ¶ added in v0.4.1
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 ¶ added in v0.4.1
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 ¶ added in v0.4.1
func (l *LogrAdaptor) Error(err error, msg string, keysAndValues ...interface{})
func (*LogrAdaptor) Info ¶ added in v0.4.1
func (l *LogrAdaptor) Info(level int, msg string, keysAndValues ...interface{})
func (*LogrAdaptor) Init ¶ added in v0.4.1
func (l *LogrAdaptor) Init(_ logr.RuntimeInfo)
func (*LogrAdaptor) WithName ¶ added in v0.4.1
func (l *LogrAdaptor) WithName(name string) logr.LogSink
func (*LogrAdaptor) WithValues ¶ added in v0.4.1
func (l *LogrAdaptor) WithValues(keysAndValues ...interface{}) logr.LogSink
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:"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 ReportTarget bool `yaml:"report_target" env:"BEYLA_METRICS_REPORT_TARGET"` 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"` // Grafana configuration needs to be explicitly set up before building the graph Grafana *GrafanaOTLP `yaml:"-"` }
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/
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.UID, 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.
type Sampler ¶ added in v0.4.1
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 ¶ added in v0.4.1
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:"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"` 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
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.