opentelemetry

package
v1.17.0-beta.24 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2025 License: Apache-2.0 Imports: 23 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractGRPCContext added in v1.17.0

func ExtractGRPCContext(ctx context.Context) context.Context

ExtractGRPCContext extracts OpenTelemetry trace context from incoming gRPC metadata and injects it into the context. It handles case normalization for W3C trace headers.

func ExtractHTTPContext added in v1.17.0

func ExtractHTTPContext(c *fiber.Ctx) context.Context

ExtractHTTPContext extracts OpenTelemetry trace context from incoming HTTP headers and injects it into the context. It works with Fiber's HTTP 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 InjectGRPCContext added in v1.17.0

func InjectGRPCContext(ctx context.Context) context.Context

InjectGRPCContext injects OpenTelemetry trace context into outgoing gRPC metadata. It normalizes W3C trace headers to lowercase for gRPC compatibility.

func InjectHTTPContext added in v1.17.0

func InjectHTTPContext(headers *http.Header, ctx context.Context)

InjectHTTPContext modifies HTTP headers for trace propagation in outgoing client requests

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

	EnableTelemetry bool
	// contains filtered or unexported fields
}

func (*Telemetry) InitializeTelemetry

func (tl *Telemetry) InitializeTelemetry(logger log.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