Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewFileWriter ¶
func NewFileWriter(logPath string) (io.WriteCloser, error)
NewFileWriter returns an io.WriteCloser that will write log messages to disk.
func NewHTTPHandler ¶
func NewHTTPHandler( newLogWriteCloser NewLogWriteCloserFunc, abort <-chan struct{}, ratelimit *RateLimitConfig, metrics MetricsCollector, modelUUID string, ) http.Handler
NewHTTPHandler returns a new http.Handler for receiving log messages over a websocket, using the given NewLogWriteCloserFunc to obtain a writer to which the log messages will be written.
ratelimit defines an optional rate-limit configuration. If nil, no rate- limiting will be applied.
Types ¶
type CounterVec ¶
type CounterVec interface {
// With returns a Counter for a given labels slice
With(prometheus.Labels) prometheus.Counter
}
CounterVec is a Collector that bundles a set of Counters that all share the same description.
type GaugeVec ¶
type GaugeVec interface {
// With returns a Gauge for a given labels slice
With(prometheus.Labels) prometheus.Gauge
}
GaugeVec is a Collector that bundles a set of Gauges that all share the same description.
type LogWriteCloser ¶
type LogWriteCloser interface {
io.Closer
// WriteLog writes out the given log record.
WriteLog(params.LogRecord) error
}
LogWriteCloser provides an interface for persisting log records. The LogCloser's Close method should be called to release any resources once it is done with.
type MetricsCollector ¶
type MetricsCollector interface {
// TotalConnections returns a prometheus metric that can be incremented
// as a counter for the total number connections being served from the api
// handler.
TotalConnections() prometheus.Counter
// Connections returns a prometheus metric that can be incremented and
// decremented as a gauge, for the number connections being current served
// from the api handler.
Connections() prometheus.Gauge
// PingFailureCount returns a prometheus metric for the number of
// ping failures per model uuid, that can be incremented as
// a counter.
PingFailureCount(modelUUID string) prometheus.Counter
// LogWriteCount returns a prometheus metric for the number of writes to
// the log that happened. It's split on the success/failure, so the charts
// will have to take that into account.
LogWriteCount(modelUUID, state string) prometheus.Counter
// LogReadCount returns a prometheus metric for the number of reads to
// the log that happened. It's split on the success/error/disconnect, so
// the charts will have to take that into account.
LogReadCount(modelUUID, state string) prometheus.Counter
}
MetricsCollector represents a way to change the metrics for the logsink api handler.
type NewLogWriteCloserFunc ¶
type NewLogWriteCloserFunc func(*http.Request) (LogWriteCloser, error)
NewLogWriteCloserFunc returns a new LogWriteCloser for the given http.Request.
type RateLimitConfig ¶
type RateLimitConfig struct {
// Burst is the number of log messages that will be let through before
// we start rate limiting.
Burst int64
// Refill is the rate at which log messages will be let through once
// the initial burst amount has been depleted.
Refill time.Duration
// Clock is the clock used to wait when rate-limiting log receives.
Clock clock.Clock
}
RateLimitConfig contains the rate-limit configuration for the logsink handler.