Documentation ¶
Overview ¶
Purpose: slogotlp is a slog.Handler that sends logs to an OpenTelemetry collector. Currently, only grpc is supported.
Index ¶
- func EnvSet() bool
- type Handler
- func (h *Handler) Enabled(_ context.Context, level slog.Level) bool
- func (h *Handler) Handle(ctx context.Context, record slog.Record) error
- func (h *Handler) Shutdown(ctx context.Context) error
- func (h *Handler) WithAttrs(attrs []slog.Attr) slog.Handler
- func (h *Handler) WithGroup(name string) slog.Handler
- type HandlerOption
- func WithBundleCountThreshold(count int) HandlerOption
- func WithBundleDelayThreshold(delay time.Duration) HandlerOption
- func WithDialOptions(opts ...grpc.DialOption) HandlerOption
- func WithEndpoint(endpoint string) HandlerOption
- func WithErrorHandler(handler func(error)) HandlerOption
- func WithInsecure(insecure bool) HandlerOption
- func WithLevel(level slog.Level) HandlerOption
- func WithResource(resource *resource.Resource) HandlerOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler implements the slog.Handler interface.
func NewHandler ¶
func NewHandler(ctx context.Context, options ...HandlerOption) (*Handler, error)
NewHandler creates a new slog.Handler.
type HandlerOption ¶
type HandlerOption interface {
// contains filtered or unexported methods
}
HandlerOption applies an option when creating a Handler.
func WithBundleCountThreshold ¶
func WithBundleCountThreshold(count int) HandlerOption
WithBundleCountThreshold sets the bundle count threshold. The default is bundler.DefaultBundleCountThreshold.
func WithBundleDelayThreshold ¶
func WithBundleDelayThreshold(delay time.Duration) HandlerOption
WithBundleDelayThreshold sets the bundle delay threshold. The default is bundler.DefaultDelayThreshold.
func WithDialOptions ¶ added in v1.2.0
func WithDialOptions(opts ...grpc.DialOption) HandlerOption
WithDialOptions sets the grpc dial options.
func WithEndpoint ¶
func WithEndpoint(endpoint string) HandlerOption
WithEndpoint sets the endpoint. If not set, this will be read from the environment
func WithErrorHandler ¶
func WithErrorHandler(handler func(error)) HandlerOption
WithErrorHandler sets the error handler. If not set, errors are logged to stderr.
func WithInsecure ¶
func WithInsecure(insecure bool) HandlerOption
WithInsecure sets the insecure flag. If not set, this will be read from the environment
func WithLevel ¶
func WithLevel(level slog.Level) HandlerOption
WithLevel sets the minimum level to log. The default is slog.LevelInfo.
func WithResource ¶
func WithResource(resource *resource.Resource) HandlerOption
WithResource sets the resource. There is no default.