Documentation
¶
Index ¶
- Variables
- func CloseAndLog(log logging.StandardLogger, name string, closer io.Closer)
- func CtxWithSplitTimeout(ctx context.Context, splitFactor int, minTimeout time.Duration) (context.Context, context.CancelFunc)
- func Exists(path string) bool
- func NewMetricProvider(ctx context.Context, cfg MetricProviderConfig) (*sdk.MeterProvider, error)
- func NormalizeAddress(addr string) string
- func NormalizeGRPCAddress(addr string) string
- func ResetContextOnError(ctx context.Context) context.Context
- func SanitizeAddr(addr string) (string, error)
- func SetStatusAndEnd(span trace.Span, err error)
- func SquareSize(lenShares int) uint64
- func ValidateAddr(addr string) (string, error)
- type MetricProviderConfig
- type Sessions
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidIP = errors.New("invalid IP address or hostname given")
Functions ¶
func CloseAndLog ¶ added in v0.20.2
func CloseAndLog(log logging.StandardLogger, name string, closer io.Closer)
CloseAndLog closes the closer and logs any error that occurs. The function is handy wrapping to group closing and logging in one call for defer statements.
func CtxWithSplitTimeout ¶ added in v0.20.2
func CtxWithSplitTimeout( ctx context.Context, splitFactor int, minTimeout time.Duration, ) (context.Context, context.CancelFunc)
CtxWithSplitTimeout will split timeout stored in context by splitFactor and return the result if it is greater than minTimeout. minTimeout == 0 will be ignored, splitFactor <= 0 will be ignored
func NewMetricProvider ¶
func NewMetricProvider(ctx context.Context, cfg MetricProviderConfig) (*sdk.MeterProvider, error)
NewMetricProvider creates a new OTLP metric provider with the given configuration
func NormalizeAddress ¶ added in v0.22.1
NormalizeAddress extracts the host and port, removing unsupported schemes.
func NormalizeGRPCAddress ¶ added in v0.28.4
func ResetContextOnError ¶ added in v0.12.2
ResetContextOnError returns a fresh context if the given context has an error.
func SanitizeAddr ¶ added in v0.5.0
SanitizeAddr trims leading protocol scheme and port from the given IP address or hostname if present.
func SetStatusAndEnd ¶ added in v0.6.3
SetStatusAndEnd sets the status of the span depending on the contents of the passed error and ends it.
func SquareSize ¶ added in v0.7.0
SquareSize returns the size of the square based on the given amount of shares.
func ValidateAddr ¶ added in v0.5.0
ValidateAddr sanitizes the given address and verifies that it is a valid IP or hostname. The sanitized address is returned.
Types ¶
type MetricProviderConfig ¶
type MetricProviderConfig struct {
// ServiceNamespace is the service namespace (e.g., network name, "latency-monitor")
ServiceNamespace string
// ServiceName is the service name (e.g., node type, "cel-shed")
ServiceName string
// ServiceInstanceID is the unique instance identifier (e.g., peer ID)
ServiceInstanceID string
// Interval is the interval at which metrics are collected and exported (defaults to 10s)
Interval time.Duration
// OTLPOptions are OTLP HTTP options (e.g., endpoint, headers, TLS config)
OTLPOptions []otlpmetrichttp.Option
// Producers are optional metric producers (e.g., prometheus bridge) added to the periodic reader
Producers []sdk.Producer
}
MetricProviderConfig holds configuration for creating a metric provider
type Sessions ¶ added in v0.20.2
type Sessions struct {
// contains filtered or unexported fields
}
Sessions manages concurrent sessions for the specified key. It ensures only one session can proceed for each key, avoiding duplicate efforts. If a session is already active for the given key, it waits until the session completes or context error occurs.
func NewSessions ¶ added in v0.20.2
func NewSessions() *Sessions
func (*Sessions) StartSession ¶ added in v0.20.2
StartSession attempts to start a new session for the given key. It provides a release function to clean up the session lock for this key, once the session is complete.