cobraotel

package
v2.0.0-...-f7fe739 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2024 License: Apache-2.0 Imports: 19 Imported by: 6

Documentation

Overview

Package cobraotel implements a builder for registering flags and producing a Cobra RunFunc that configures OpenTelemetry.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Builder

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

Builder is used to configure OpenTelemetry via Cobra.

func New

func New(serviceName string, opts ...Option) *Builder

New creates a Cobra RunFunc Builder for OpenTelemetry.

func (*Builder) RegisterFlagCompletion

func (b *Builder) RegisterFlagCompletion(cmd *cobra.Command) error

RegisterFlagCompletion adds completion functions supported flags.

The following flags are completed: - "$PREFIX-provider" - "$PREFIX-trace-propagator"

func (*Builder) RegisterFlags

func (b *Builder) RegisterFlags(flags *pflag.FlagSet)

RegisterFlags adds flags for configuring OpenTelemetry.

The following flags are added: - "$PREFIX-provider" - "$PREFIX-trace-propagator" - "$PREFIX-insecure" - "$PREFIX-endpoint" - "$PREFIX-service-name"

func (*Builder) RunE

func (b *Builder) RunE() cobrautil.CobraRunFunc

RunE returns a Cobra run func that configures the corresponding otel provider from a command.

The required flags can be added to a command by using RegisterOpenTelemetryFlags().

type Option

type Option func(*Builder)

Option is function used to configure OpenTelemetry within a Cobra RunFunc.

func WithFlagPrefix

func WithFlagPrefix(flagPrefix string) Option

WithFlagPrefix defines prefix used with the generated flags.

Defaults to "log".

func WithLogger

func WithLogger(logger logr.Logger) Option

WithLogger configures logging of the configured OpenTelemetry environment.

func WithPreRunLevel

func WithPreRunLevel(preRunLevel int) Option

WithPreRunLevel defines the logging level used for pre-run log messages.

Defaults to "debug".

Jump to

Keyboard shortcuts

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