instrumentation

package
v0.0.0-...-b4e7bf2 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: Apache-2.0, MIT Imports: 30 Imported by: 2

Documentation

Index

Constants

View Source
const (
	ScopeName = "gitlab.com/gitlab-org/opstrace/opstrace/go/pkg/instrumentation"
)

Variables

This section is empty.

Functions

func ConfiguredCollectors

func ConfiguredCollectors() []prometheus.Collector

func ConstructOTELMeterProvider

func ConstructOTELMeterProvider(
	ctx context.Context,
	r *resource.Resource,
	reg prometheus.Registerer,
	otlpEndpoint, otlpCACertificate, otlpTokenSecretFile string,
) (*metricsdk.MeterProvider, func() error, error)

func ConstructOTELResource

func ConstructOTELResource(ctx context.Context, serviceName, version string) (*resource.Resource, error)

func ConstructOTELTracingTools

func ConstructOTELTracingTools(
	ctx context.Context,
	r *resource.Resource,
	otlpEndpoint, otlpCACertificateFile, otlpTokenSecretFile string,
) (
	trace.TracerProvider,
	propagation.TextMapPropagator,
	func() error,
	error,
)

func ConstructPromMeterTooling

func ConstructPromMeterTooling() (*prometheus.Registry, *http.ServeMux)

func InstrumentHandlerFuncWithOpts

func InstrumentHandlerFuncWithOpts(strip StripFunc, addMetrics AdditionalMetricsFunc) gin.HandlerFunc

InstrumentHandlerFuncWithOpts is similar to PrometheusMiddleware but returns a gin specific middleware. This is only to be used as a middleware and uses the same metrics in use by its http.Handler counterpart.

func NewDefaultMeter

func NewDefaultMeter(mp *metricsdk.MeterProvider) metric.Meter

func NewSubSpan

func NewSubSpan(ctx context.Context, spanName string, spanKind trace.SpanKind) (context.Context, trace.Span)

func NoOpAdditionalMetricsFunc

func NoOpAdditionalMetricsFunc(_ *http.Request, _, _, _ string)

func NoOpStripFunc

func NoOpStripFunc(str string) string

NoOpStripFunc is a placeholder for strip function if path is to be kept as is

func PrometheusMiddleware

func PrometheusMiddleware(next http.Handler, strip StripFunc, addMetrics AdditionalMetricsFunc) http.Handler

func SetupLogger

func SetupLogger(logLevel string) (*zap.SugaredLogger, func(), zap.Config)

Types

type AdditionalMetricsFunc

type AdditionalMetricsFunc func(r *http.Request, code, method, path string)

AdditionalMetricsFunc should be a helper method to add additional metrics derived from the request.

type StripFunc

type StripFunc func(str string) string

StripFunc is a helper method to strip path such that it can be used as a label (satisfy low cardinality constraints).

Jump to

Keyboard shortcuts

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