mopentelemetry

package
v1.38.1-beta.1 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractContext

func ExtractContext(ctx context.Context) context.Context

ExtractContext extracts the OpenTelemetry headers (in lowercase) from the context and returns the new context.

func HandleSpanError

func HandleSpanError(span *trace.Span, message string, err error)

HandleSpanError sets the status of the span to error and records the error.

func InjectContext

func InjectContext(ctx context.Context) context.Context

InjectContext injects the context with the OpenTelemetry headers (in lowercase) and returns the new context.

func SetSpanAttributesFromStruct

func SetSpanAttributesFromStruct(span *trace.Span, key string, valueStruct any) error

SetSpanAttributesFromStruct converts a struct to a JSON string and sets it as an attribute on the span.

Types

type Telemetry

type Telemetry struct {
	LibraryName               string
	ServiceName               string
	ServiceVersion            string
	DeploymentEnv             string
	CollectorExporterEndpoint string
	TracerProvider            *sdktrace.TracerProvider
	MetricProvider            *sdkmetric.MeterProvider
	LoggerProvider            *sdklog.LoggerProvider
	// contains filtered or unexported fields
}

func (*Telemetry) InitializeTelemetry

func (tl *Telemetry) InitializeTelemetry(logger mlog.Logger) *Telemetry

InitializeTelemetry initializes the telemetry providers and sets them globally. (Logger is being passed as a parameter because it not exists in the global context at this point to be injected)

func (*Telemetry) ShutdownTelemetry

func (tl *Telemetry) ShutdownTelemetry()

ShutdownTelemetry shuts down the telemetry providers and exporters.

Jump to

Keyboard shortcuts

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