cobraotel

package
v4.0.0-...-7740553 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2023 License: Apache-2.0 Imports: 21 Imported by: 0

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) RegisterFlags

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

RegisterFlags adds flags for configuring OpenTelemetry.

The following flags are added: - "$PREFIX-provider" - "$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