juju: github.com/juju/juju/apiserver/logsink Index | Files | Directories

package logsink

import "github.com/juju/juju/apiserver/logsink"

Index

Package Files

filewriter.go logsink.go

func JujuClientVersionFromRequest Uses

func JujuClientVersionFromRequest(req *http.Request) (version.Number, error)

JujuClientVersionFromRequest returns the Juju client version number from the HTTP request.

func NewFileWriter Uses

func NewFileWriter(logPath string) (io.WriteCloser, error)

NewFileWriter returns an io.WriteCloser that will write log messages to disk.

func NewHTTPHandler Uses

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.

type CounterVec Uses

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 Uses

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 Uses

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 Uses

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. go:generate mockgen -package mocks -destination mocks/metrics_collector_mock.go github.com/juju/juju/apiserver/logsink MetricsCollector go:generate mockgen -package mocks -destination mocks/metrics_mock.go github.com/prometheus/client_golang/prometheus Counter,Gauge

type NewLogWriteCloserFunc Uses

type NewLogWriteCloserFunc func(*http.Request) (LogWriteCloser, error)

NewLogWriteCloserFunc returns a new LogWriteCloser for the given http.Request.

type RateLimitConfig Uses

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.

Directories

PathSynopsis
mocksPackage mocks is a generated GoMock package.

Package logsink imports 18 packages (graph) and is imported by 3 packages. Updated 2019-10-22. Refresh now. Tools for package owners.