resultlog

package
v0.0.0-...-84339fa Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ResultLogKeys = struct {
	Experiment string
	Enricher   string
	Router     string
	Ensembler  string
}{
	Experiment: "experiment",
	Enricher:   "enricher",
	Router:     "router",
	Ensembler:  "ensembler",
}

ResultLogKeys defines the individual components for which the result log must be created

Functions

func AddResponse

func AddResponse(rl *turing.TuringResultLogMessage, key string, body string, header map[string]string, err string)

AddResponse adds the per-component response/error info to the TuringResultLogEntry

func FormatHeader

func FormatHeader[h http.Header | metadata.MD](header h) map[string]string

FormatHeader formats the header which by concatenating the string values corresponding to each header into a single comma-delimited string

func NewTuringResultLog

func NewTuringResultLog[h http.Header | metadata.MD](
	predictionID string,
	timestamp time.Time,
	header h,
	body string,
) *turing.TuringResultLogMessage

NewTuringResultLog returns a new TuringResultLogMessage object with the given context and request

Types

type BigQueryLogger

type BigQueryLogger interface {
	TuringResultLogger
	// contains filtered or unexported methods
}

BigQueryLogger extends the TuringResultLogger interface and defines additional methods on the logger

func NewBigQueryLogger

func NewBigQueryLogger(cfg *config.BQConfig) (BigQueryLogger, error)

NewBigQueryLogger creates a new BigQueryLogger

type ConsoleLogger

type ConsoleLogger struct{}

ConsoleLogger generates instance of ConsoleLog for logging results

func NewConsoleLogger

func NewConsoleLogger() *ConsoleLogger

NewConsoleLogger generates an instance of ConsoleLogger

type FluentdLogger

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

FluentdLogger generates instances of FluentdLog for posting results to a fluentd backend.

func NewFluentdLogger

func NewFluentdLogger(
	cfg *config.FluentdConfig,
	bqLogger BigQueryLogger,
) (*FluentdLogger, error)

NewFluentdLogger creates a new FluentdLogger

type GrpcRouterResponse

type GrpcRouterResponse struct {
	// Key field is not used for now as there is only router,
	// it can be used to differentiate enricher/ensembler/experiment engine response
	Key     string
	Header  metadata.MD
	Body    *upiv1.PredictValuesResponse
	Err     string
	ErrCode int
}

GrpcRouterResponse is sent to the result logger to construct RouterLog or TuringResultLog

type KafkaLogger

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

KafkaLogger logs the result log data to the configured Kafka topic

func NewKafkaLogger

func NewKafkaLogger(cfg *config.KafkaConfig) (*KafkaLogger, error)

NewKafkaLogger creates a new KafkaLogger

type NopLogger

type NopLogger struct{}

NopLogger generates instance of NopLog for logging results

func NewNopLogger

func NewNopLogger() *NopLogger

NewNopLogger generates an instance of NewNopLogger

type ResultLogger

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

ResultLogger holds the logic how the TuringResultLogMessage is being constructed, and writes to the destination using the logger middleware

func InitTuringResultLogger

func InitTuringResultLogger(appName string, logger TuringResultLogger) *ResultLogger

InitTuringResultLogger initializes the result with supplied logger for logging TuringResultLogMessage. appName stores the configured app name, Format: {router_name}-{router_version}.{project_name}

func (*ResultLogger) LogTuringRouterRequestError

func (rl *ResultLogger) LogTuringRouterRequestError(ctx context.Context, err *errors.TuringError)

LogTuringRouterRequestError logs the given turing request id and the error data

func (*ResultLogger) LogTuringRouterRequestSummary

func (rl *ResultLogger) LogTuringRouterRequestSummary(
	predictionID string,
	logger log.Logger,
	timestamp time.Time,
	reqHeader http.Header,
	reqBody []byte,
	mcRespCh <-chan RouterResponse)

LogTuringRouterRequestSummary logs the summary of the request made to the turing router, through the configured result logger. It takes as its input the turing request id, the request header and body for the original request to the turing router, a response channel with responses from each stage of the turing workflow.

func (*ResultLogger) SendResponseToLogChannel

func (rl *ResultLogger) SendResponseToLogChannel(
	ctx context.Context,
	ch chan<- RouterResponse,
	key string,
	r mchttp.Response,
	httpErr *errors.TuringError,
)

SendResponseToLogChannel copies the response from the turing router to the given channel as a RouterResponse object

type RouterResponse

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

RouterResponse is the struct of expected to pass into response channel to be logged as TuringResultLogMessage later

type TuringResultLogger

type TuringResultLogger interface {
	// contains filtered or unexported methods
}

TuringResultLogger is an abstraction for the underlying result logger for TuringResultLogMessage

type UPIKafkaLogger

type UPIKafkaLogger struct {
	*KafkaLogger
}

func NewUPIKafkaLogger

func NewUPIKafkaLogger(cfg *config.KafkaConfig) (*UPIKafkaLogger, error)

type UPILogger

type UPILogger interface {
	// contains filtered or unexported methods
}

type UPIResultLogger

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

UPIResultLogger holds the logic how the RouterLog is being constructed, the server will always provide GrpcRouterResponse and UPIResultLogger will be responsible to construct it into TuringResultLogMessage or RouterLog and writes to the destination with the underlying logger middleware

func InitUPIResultLogger

func InitUPIResultLogger(
	appName string,
	loggerType config.ResultLogger,
	upiLogger UPILogger,
	resultLogger *ResultLogger) (*UPIResultLogger, error)

func (*UPIResultLogger) LogTuringRouterRequestError

func (ul *UPIResultLogger) LogTuringRouterRequestError(ctx context.Context, err *errors.TuringError)

LogTuringRouterRequestError logs the given turing request id and the error data

func (*UPIResultLogger) LogTuringRouterRequestSummary

func (ul *UPIResultLogger) LogTuringRouterRequestSummary(
	header metadata.MD,
	upiReq *upiv1.PredictValuesRequest,
	mcRespCh <-chan GrpcRouterResponse,
)

func (*UPIResultLogger) SendResponseToLogChannel

func (ul *UPIResultLogger) SendResponseToLogChannel(
	ch chan<- GrpcRouterResponse,
	key string,
	md metadata.MD,
	r *upiv1.PredictValuesResponse,
	err *errors.TuringError)

SendResponseToLogChannel send the response from the turing router to the given channel as a RouterResponse object

Directories

Path Synopsis
proto

Jump to

Keyboard shortcuts

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