logs

package
v0.70.0 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2024 License: Apache-2.0 Imports: 28 Imported by: 32

Documentation

Overview

Package logs implements decision log buffering and uploading.

Index

Constants

View Source
const Name = "decision_logs"

Name identifies the plugin on manager.

Variables

This section is empty.

Functions

This section is empty.

Types

type BundleInfoV1 added in v0.13.0

type BundleInfoV1 struct {
	Revision string `json:"revision,omitempty"`
}

BundleInfoV1 describes a bundle associated with a decision log event.

func (*BundleInfoV1) AST added in v0.22.0

func (b *BundleInfoV1) AST() ast.Value

AST returns the BundleInfoV1 as an AST value

type Config

type Config struct {
	Plugin         *string              `json:"plugin"`
	Service        string               `json:"service"`
	PartitionName  string               `json:"partition_name,omitempty"`
	Reporting      ReportingConfig      `json:"reporting"`
	RequestContext RequestContextConfig `json:"request_context"`
	MaskDecision   *string              `json:"mask_decision"`
	DropDecision   *string              `json:"drop_decision"`
	ConsoleLogs    bool                 `json:"console"`
	Resource       *string              `json:"resource"`
	NDBuiltinCache bool                 `json:"nd_builtin_cache,omitempty"`
	// contains filtered or unexported fields
}

Config represents the plugin configuration.

func ParseConfig added in v0.10.2

func ParseConfig(config []byte, services []string, pluginList []string) (*Config, error)

ParseConfig validates the config and injects default values.

type ConfigBuilder added in v0.32.0

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

ConfigBuilder assists in the construction of the plugin configuration.

func NewConfigBuilder added in v0.32.0

func NewConfigBuilder() *ConfigBuilder

NewConfigBuilder returns a new ConfigBuilder to build and parse the plugin config.

func (*ConfigBuilder) Parse added in v0.32.0

func (b *ConfigBuilder) Parse() (*Config, error)

Parse validates the config and injects default values.

func (*ConfigBuilder) WithBytes added in v0.32.0

func (b *ConfigBuilder) WithBytes(config []byte) *ConfigBuilder

WithBytes sets the raw plugin config.

func (*ConfigBuilder) WithPlugins added in v0.32.0

func (b *ConfigBuilder) WithPlugins(plugins []string) *ConfigBuilder

WithPlugins sets the list of named plugins for decision logging.

func (*ConfigBuilder) WithServices added in v0.32.0

func (b *ConfigBuilder) WithServices(services []string) *ConfigBuilder

WithServices sets the services that implement control plane APIs.

func (*ConfigBuilder) WithTriggerMode added in v0.32.0

func (b *ConfigBuilder) WithTriggerMode(trigger *plugins.TriggerMode) *ConfigBuilder

WithTriggerMode sets the plugin trigger mode.

type EventV1

type EventV1 struct {
	Labels         map[string]string       `json:"labels"`
	DecisionID     string                  `json:"decision_id"`
	TraceID        string                  `json:"trace_id,omitempty"`
	SpanID         string                  `json:"span_id,omitempty"`
	Revision       string                  `json:"revision,omitempty"` // Deprecated: Use Bundles instead
	Bundles        map[string]BundleInfoV1 `json:"bundles,omitempty"`
	Path           string                  `json:"path,omitempty"`
	Query          string                  `json:"query,omitempty"`
	Input          *interface{}            `json:"input,omitempty"`
	Result         *interface{}            `json:"result,omitempty"`
	MappedResult   *interface{}            `json:"mapped_result,omitempty"`
	NDBuiltinCache *interface{}            `json:"nd_builtin_cache,omitempty"`
	Erased         []string                `json:"erased,omitempty"`
	Masked         []string                `json:"masked,omitempty"`
	Error          error                   `json:"error,omitempty"`
	RequestedBy    string                  `json:"requested_by,omitempty"`
	Timestamp      time.Time               `json:"timestamp"`
	Metrics        map[string]interface{}  `json:"metrics,omitempty"`
	RequestID      uint64                  `json:"req_id,omitempty"`
	RequestContext *RequestContext         `json:"request_context,omitempty"`
	// contains filtered or unexported fields
}

EventV1 represents a decision log event. WARNING: The AST() function for EventV1 must be kept in sync with the struct. Any changes here MUST be reflected in the AST() implementation below.

func (*EventV1) AST added in v0.22.0

func (e *EventV1) AST() (ast.Value, error)

AST returns the Rego AST representation for a given EventV1 object. This avoids having to round trip through JSON while applying a decision log mask policy to the event.

type HTTPRequestContext added in v0.65.0

type HTTPRequestContext struct {
	Headers map[string][]string `json:"headers,omitempty"`
}

type HTTPRequestContextConfig added in v0.65.0

type HTTPRequestContextConfig struct {
	Headers []string `json:"headers,omitempty"`
}

type Logger added in v0.10.3

type Logger interface {
	plugins.Plugin

	Log(context.Context, EventV1) error
}

Logger defines the interface for decision logging plugins.

type Plugin

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

Plugin implements decision log buffering and uploading.

func Lookup added in v0.10.2

func Lookup(manager *plugins.Manager) *Plugin

Lookup returns the decision logs plugin registered with the manager.

func New

func New(parsedConfig *Config, manager *plugins.Manager) *Plugin

New returns a new Plugin with the given config.

func (*Plugin) Config added in v0.64.0

func (p *Plugin) Config() *Config

Config returns the plugin's current configuration

func (*Plugin) Log

func (p *Plugin) Log(ctx context.Context, decision *server.Info) error

Log appends a decision log event to the buffer for uploading.

func (*Plugin) Reconfigure added in v0.10.2

func (p *Plugin) Reconfigure(_ context.Context, config interface{})

Reconfigure notifies the plugin with a new configuration.

func (*Plugin) Start

func (p *Plugin) Start(_ context.Context) error

Start starts the plugin.

func (*Plugin) Stop

func (p *Plugin) Stop(ctx context.Context)

Stop stops the plugin.

func (*Plugin) Trigger added in v0.32.0

func (p *Plugin) Trigger(ctx context.Context) error

Trigger can be used to control when the plugin attempts to upload a new decision log in manual triggering mode.

func (*Plugin) WithMetrics added in v0.28.0

func (p *Plugin) WithMetrics(m metrics.Metrics) *Plugin

WithMetrics sets the global metrics provider to be used by the plugin.

type ReportingConfig

type ReportingConfig struct {
	BufferSizeLimitBytes  *int64               `json:"buffer_size_limit_bytes,omitempty"`  // max size of in-memory buffer
	UploadSizeLimitBytes  *int64               `json:"upload_size_limit_bytes,omitempty"`  // max size of upload payload
	MinDelaySeconds       *int64               `json:"min_delay_seconds,omitempty"`        // min amount of time to wait between successful poll attempts
	MaxDelaySeconds       *int64               `json:"max_delay_seconds,omitempty"`        // max amount of time to wait between poll attempts
	MaxDecisionsPerSecond *float64             `json:"max_decisions_per_second,omitempty"` // max number of decision logs to buffer per second
	Trigger               *plugins.TriggerMode `json:"trigger,omitempty"`                  // trigger mode
}

ReportingConfig represents configuration for the plugin's reporting behaviour.

type RequestContext added in v0.65.0

type RequestContext struct {
	HTTPRequest *HTTPRequestContext `json:"http,omitempty"`
}

type RequestContextConfig added in v0.65.0

type RequestContextConfig struct {
	HTTPRequest *HTTPRequestContextConfig `json:"http,omitempty"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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