trace2hooks

package
v16.10.3 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JSONMessage added in v16.10.0

type JSONMessage string

JSONMessage is a wrapper type around json.RawMessage. It is a string so logrus.TextMarshaler prints it out as a string. It implements the MarshalJSON method

func (JSONMessage) MarshalJSON added in v16.10.0

func (m JSONMessage) MarshalJSON() ([]byte, error)

MarshalJSON is a method that overrides the default JSON marshaling behavior for the JSONMessage struct. It converts the JSONMessage struct into a byte slice by marshaling it as a RawMessage.This allows for preserving the original JSON structure without further modification.

type LogExporter added in v16.9.0

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

LogExporter is a trace2 hook that adds trace2 api event logs to Gitaly's logs.

func NewLogExporter added in v16.9.0

func NewLogExporter(rl *rate.Limiter, logger log.Logger) *LogExporter

NewLogExporter initializes LogExporter, which is a hook that uses the parsed trace2 events from the manager to export them to the Gitaly log. It's invocations are limited by the rateLimiter. The limiter allows maxBurstToken number of events to happen at once and then replenishes by maxEventPerSecond. It works on the token bucket algorithm where you have a number of tokens in the bucket to start and you can consume them in each call whilst the bucket gets refilled at the specified rate.

func (*LogExporter) Handle added in v16.9.0

func (t *LogExporter) Handle(rootCtx context.Context, trace *trace2.Trace) error

Handle will log the trace in a readable json format in Gitaly's logs. Metadata is also collected and additional information is added to the log. It is also rate limited to protect it from overload when there are a lot of trace2 events triggered from git operations.

func (*LogExporter) Name added in v16.9.0

func (t *LogExporter) Name() string

Name returns the name of tracing exporter

type PackObjectsMetrics

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

PackObjectsMetrics is a trace2 hook that export pack-objects Prometheus metrics and stats log fields. This information is extracted by traversing the trace2 event tree.

func NewPackObjectsMetrics

func NewPackObjectsMetrics() *PackObjectsMetrics

NewPackObjectsMetrics is the initializer for PackObjectsMetrics

func (*PackObjectsMetrics) Collect

func (p *PackObjectsMetrics) Collect(c chan<- prometheus.Metric)

Collect collects Prometheus metrics exposed by the PackObjectsMetrics structure.

func (*PackObjectsMetrics) Describe

func (p *PackObjectsMetrics) Describe(descs chan<- *prometheus.Desc)

Describe describes Prometheus metrics exposed by the PackObjectsMetrics structure.

func (*PackObjectsMetrics) Handle

func (p *PackObjectsMetrics) Handle(rootCtx context.Context, trace *trace2.Trace) error

Handle traverses input trace2 event tree for data nodes containing relevant pack-objects data. When it finds one, it updates Prometheus objects and log fields accordingly.

func (*PackObjectsMetrics) Name

func (p *PackObjectsMetrics) Name() string

Name returns the name of the hooks

type TracingExporter

type TracingExporter struct{}

TracingExporter is a trace2 hook that converts the trace2 tree to corresponding distributed tracing's spans. These spans are then collected if the process initializes labkit's tracing utility.

func NewTracingExporter

func NewTracingExporter() *TracingExporter

NewTracingExporter initializes TracingExporter, which is a hook to convert Trace2 events to corresponding distributed tracing

func (*TracingExporter) Handle

func (t *TracingExporter) Handle(rootCtx context.Context, trace *trace2.Trace) error

Handle is the main method that converts each trace not in the tree to the corresponding nested span. All the spans will have `git:` prefix, followed by the operation. Trace metadata fields are copied as span tags.

func (*TracingExporter) Name

func (t *TracingExporter) Name() string

Name returns the name of tracing exporter

Jump to

Keyboard shortcuts

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