otel

package
v0.0.0-...-2cc43cd Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContextWithEnvTraceparent

func ContextWithEnvTraceparent(ctx context.Context) context.Context

ContextWithEnvTraceparent is a helper that looks for the the TRACEPARENT environment variable and if it's set, it grabs the traceparent and adds it to the context it returns. When there is no envvar or it's empty, the original context is returned unmodified. Depends on global OTel TextMapPropagator.

func ContextWithTraceparentString

func ContextWithTraceparentString(ctx context.Context, traceparent string) context.Context

ContextWithTraceparentString takes a W3C traceparent string, uses the otel carrier code to get it into a context it returns ready to go. Depends on global OTel TextMapPropagator.

func Init

Init sets up the OpenTelemetry plumbing so it's ready to use. It requires a context.Context and returns context and a func() that encapuslates clean shutdown.

func TraceparentStringFromContext

func TraceparentStringFromContext(ctx context.Context) string

TraceparentStringFromContext gets the current trace from the context and returns a W3C traceparent string. Depends on global OTel TextMapPropagator.

Types

type Config

type Config struct {
	Servicename string `json:"service_name"`
	Endpoint    string `json:"endpoint"`
	Insecure    bool   `json:"insecure"`
	Logger      logr.Logger
}

Config holds the typed values of configuration read from the environment. It is public mainly to make testing easier and most users should never use it directly.

func (Config) Handle

func (c Config) Handle(err error)

type SimpleCarrier

type SimpleCarrier map[string]string

SimpleCarrier is an abstraction for handling traceparent propagation that needs a type that implements the propagation.TextMapCarrier(). This is the simplest possible implementation that is a little fragile but since we're not doing anything else with it, it's fine for this.

func (SimpleCarrier) Clear

func (otp SimpleCarrier) Clear()

Clear implements the otel interface for propagation.

func (SimpleCarrier) Get

func (otp SimpleCarrier) Get(key string) string

Get implements the otel interface for propagation.

func (SimpleCarrier) Keys

func (otp SimpleCarrier) Keys() []string

Keys implements the otel interface for propagation.

func (SimpleCarrier) Set

func (otp SimpleCarrier) Set(key, value string)

Set implements the otel interface for propagation.

Jump to

Keyboard shortcuts

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