otelutils

package
v2.0.23 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2026 License: Apache-2.0, Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BlobstoreClientTracer = "blobstore-client"
	K8sClientTracer       = "k8s-client"
)

Variables

View Source
var (
	ConfigSection = config.MustRegisterSection(configSectionKey, defaultConfig)
)

Functions

func GetMeterProvider added in v2.0.21

func GetMeterProvider(serviceName string) rawmetric.MeterProvider

GetMeterProvider returns the meter provider for the given service name.

func GetTracerProvider

func GetTracerProvider(serviceName string) rawtrace.TracerProvider

GetTracerProvider returns the tracer provider for the given service name.

func NewSpan

func NewSpan(ctx context.Context, serviceName string, spanName string) (context.Context, rawtrace.Span)

NewSpan creates a new span with the given service name and span name.

func RegisterProvidersWithContext added in v2.0.21

func RegisterProvidersWithContext(ctx context.Context, serviceName string, config *Config) error

RegisterProvidersWithContext registers a tracer & metric provider for the given service name.

func WrapK8sCache

func WrapK8sCache(c cache.Cache) cache.Cache

func WrapK8sClient

func WrapK8sClient(c client.Client) client.Client

Types

type Config

type Config struct {
	ExporterType   ExporterType   `json:"type" pflag:",Sets the type of exporter to configure [noop/file/jaeger/otlpgrpc/otlphttp]."`
	FileConfig     FileConfig     `json:"file" pflag:",Configuration for exporting telemetry traces to a file"`
	JaegerConfig   JaegerConfig   `json:"jaeger" pflag:",Configuration for exporting telemetry traces to a jaeger"`
	OtlpGrpcConfig OtlpGrpcConfig `json:"otlpgrpc" pflag:",Configuration for exporting telemetry traces to an OTLP gRPC collector"`
	OtlpHttpConfig OtlpHttpConfig `json:"otlphttp" pflag:",Configuration for exporting telemetry traces to an OTLP HTTP collector"` // nolint:golint
	SamplerConfig  SamplerConfig  `json:"sampler" pflag:",Configuration for the sampler to use for the tracer"`
}

func GetConfig

func GetConfig() *Config

func (Config) GetPFlagSet

func (cfg Config) GetPFlagSet(prefix string) *pflag.FlagSet

GetPFlagSet will return strongly types pflags for all fields in Config and its nested types. The format of the flags is json-name.json-sub-name... etc.

type ExporterType

type ExporterType = string
const (
	NoopExporter     ExporterType = "noop"
	FileExporter     ExporterType = "file"
	JaegerExporter   ExporterType = "jaeger"
	OtlpGrpcExporter ExporterType = "otlpgrpc"
	OtlpHttpExporter ExporterType = "otlphttp" // nolint:golint
)

type FileConfig

type FileConfig struct {
	Filename string `json:"filename" pflag:",Filename to store exported telemetry traces"`
}

type JaegerConfig

type JaegerConfig struct {
	Endpoint string `json:"endpoint" pflag:",Endpoint for the jaeger telemetry trace ingestor"`
}

type K8sCacheWrapper

type K8sCacheWrapper struct {
	cache.Cache
}

func (*K8sCacheWrapper) Get

func (*K8sCacheWrapper) List

func (c *K8sCacheWrapper) List(ctx context.Context, list client.ObjectList, opts ...client.ListOption) error

type K8sClientWrapper

type K8sClientWrapper struct {
	client.Client
	// contains filtered or unexported fields
}

func (*K8sClientWrapper) Create

func (c *K8sClientWrapper) Create(ctx context.Context, obj client.Object, opts ...client.CreateOption) error

func (*K8sClientWrapper) Delete

func (c *K8sClientWrapper) Delete(ctx context.Context, obj client.Object, opts ...client.DeleteOption) error

func (*K8sClientWrapper) DeleteAllOf

func (c *K8sClientWrapper) DeleteAllOf(ctx context.Context, obj client.Object, opts ...client.DeleteAllOfOption) error

func (*K8sClientWrapper) Get

func (*K8sClientWrapper) List

func (*K8sClientWrapper) Patch

func (c *K8sClientWrapper) Patch(ctx context.Context, obj client.Object, patch client.Patch, opts ...client.PatchOption) error

func (*K8sClientWrapper) Status

func (c *K8sClientWrapper) Status() client.StatusWriter

func (*K8sClientWrapper) Update

func (c *K8sClientWrapper) Update(ctx context.Context, obj client.Object, opts ...client.UpdateOption) error

type K8sStatusWriterWrapper

type K8sStatusWriterWrapper struct {
	client.StatusWriter
}

func (*K8sStatusWriterWrapper) Patch

func (*K8sStatusWriterWrapper) Update

type OtlpGrpcConfig

type OtlpGrpcConfig struct {
	Endpoint string `json:"endpoint" pflag:",Endpoint for the OTLP telemetry trace collector"`
}

type OtlpHttpConfig

type OtlpHttpConfig struct {
	Endpoint string `json:"endpoint" pflag:",Endpoint for the OTLP telemetry trace collector"`
}

type SamplerConfig

type SamplerConfig struct {
	ParentSampler SamplerType `json:"parentSampler" pflag:",Sets the parent sampler to use for the tracer"`
	TraceIDRatio  float64     `json:"traceIdRatio" pflag:"-,Sets the trace id ratio for the TraceIdRatioBased sampler"`
}

type SamplerType

type SamplerType = string
const (
	AlwaysSample      SamplerType = "always"
	TraceIDRatioBased SamplerType = "traceid"
)

Jump to

Keyboard shortcuts

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