otel

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2023 License: Apache-2.0 Imports: 29 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"
	HTTPServerRequestSize = "http.server.request.size"
	HTTPClientRequestSize = "http.client.request.size"
)

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 MetricsConfig

type MetricsConfig struct {
	Interval        time.Duration `yaml:"interval" env:"METRICS_INTERVAL"`
	Endpoint        string        `yaml:"endpoint" env:"OTEL_EXPORTER_OTLP_ENDPOINT"`
	MetricsEndpoint string        `yaml:"-" 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"`
}

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

type MetricsReporter

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

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 (
	ProtocolGRPC         Protocol = "grpc"
	ProtocolHTTPProtobuf Protocol = "http/protobuf"
	ProtocolHTTPJSON     Protocol = "http/json"
)

type SessionSpan

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

type TracesConfig

type TracesConfig struct {
	Endpoint       string `yaml:"endpoint" env:"OTEL_EXPORTER_OTLP_ENDPOINT"`
	TracesEndpoint string `yaml:"-" 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"`
}

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

type TracesReporter

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

Jump to

Keyboard shortcuts

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