telemetry

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2024 License: MIT Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MODULE    = "github.com/wwmoraes/anilistarr"
	NAME      = "anilistarr"
	NAMESPACE = "api"
	VERSION   = "0.1.0-rc.1"
)

Variables

View Source
var (
	ErrNoEndpoint = errors.New("OTLP endpoint not provided")
)
View Source
var WithDescription = metric.WithDescription
View Source
var WithUnit = metric.WithUnit

Functions

func ContextWithLogger

func ContextWithLogger(ctx context.Context) context.Context

func DefaultLogger

func DefaultLogger() logr.Logger

func Float64Histogram added in v0.2.0

func Float64Histogram(name string, options ...metric.Float64HistogramOption) metric.Float64Histogram

func HandlerFunc

func HandlerFunc(fn http.HandlerFunc, startOptions []trace.SpanStartOption, endOptions []trace.SpanEndOption) http.HandlerFunc

func InstrumentAll

func InstrumentAll(ctx context.Context, otlpEndpoint string) (func(context.Context), error)

func InstrumentLogging

func InstrumentLogging(ctx context.Context, otlpEndpoint string) error

func InstrumentMetrics

func InstrumentMetrics(ctx context.Context, otlpEndpoint string) (func(context.Context), error)

func InstrumentTracing

func InstrumentTracing(ctx context.Context, otlpEndpoint string) (func(context.Context), error)

func Int

func Int(element Attributable, k string, v int)

func Int64Counter added in v0.2.0

func Int64Counter(name string, options ...metric.Int64CounterOption) metric.Int64Counter

func LoggerFromContext

func LoggerFromContext(ctx context.Context) logr.Logger

func Must added in v0.2.0

func Must[M any](metric M, err error) M

func NewHandleFunc

func NewHandleFunc(fn http.HandlerFunc, operation string) http.Handler

func NewHandler

func NewHandler(handler http.Handler, operation string) http.Handler

func NewHandlerMiddleware

func NewHandlerMiddleware(next http.Handler) http.Handler

func NewStdLogSink

func NewStdLogSink() *stdLogSink

func OpenSQL

func OpenSQL(driverName, dataSourceName string) (*sql.DB, error)

func SpanFromContext

func SpanFromContext(ctx context.Context) trace.Span

func TeeSink

func TeeSink(sinks ...logr.LogSink) logr.LogSink

func WantedRequestHeaders

func WantedRequestHeaders(h http.Header, keys ...string) http.Header

func WithInt

func WithInt(k string, v int) trace.SpanStartEventOption

func WithSpanKindClient

func WithSpanKindClient() trace.SpanStartOption

Types

type Attributable

type Attributable interface {
	SetAttributes(kv ...attribute.KeyValue)
}

type HTTPSpan

type HTTPSpan interface {
	Span

	HTTPStatus(status int)
	EndWithStatus(status int, options ...trace.SpanEndOption)
}

type Logger

type Logger = logr.Logger

type Meter

type Meter = metric.Meter

func DefaultMeter

func DefaultMeter() Meter

type MeterOption

type MeterOption = metric.MeterOption

type Span

type Span interface {
	trace.Span

	EndWith(err error, options ...trace.SpanEndOption)
	Assert(error) error
	Int(k string, v int)
}

func Start

func Start(ctx context.Context, spanName string, opts ...SpanStartOption) (context.Context, Span)

func StartFunction

func StartFunction(ctx context.Context, opts ...trace.SpanStartOption) (context.Context, Span)

type SpanStartOption

type SpanStartOption = trace.SpanStartOption

type Tracer

type Tracer interface {
	StartFunction(ctx context.Context, opts ...SpanStartOption) (context.Context, Span)
	StartHTTPResponse(req *http.Request, opts ...SpanStartOption) (context.Context, HTTPSpan)

	// custom span
	// from trace.Tracer
	Start(ctx context.Context, spanName string, opts ...SpanStartOption) (context.Context, Span)
}

func DefaultTracer

func DefaultTracer() Tracer

type TracerOption

type TracerOption = trace.TracerOption

Jump to

Keyboard shortcuts

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