telemetry

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package telemetry provides OpenTelemetry tracing utilities for the xg2g application.

Package telemetry provides OpenTelemetry tracing utilities for the xg2g application.

Index

Constants

View Source
const (
	// HTTP attributes
	HTTPMethodKey     = "http.method"
	HTTPStatusCodeKey = "http.status_code"
	HTTPRouteKey      = "http.route"
	HTTPURLKey        = "http.url"
	HTTPUserAgentKey  = "http.user_agent"

	// Streaming attributes
	StreamChannelKey   = "stream.channel"
	StreamServiceIDKey = "stream.service_id"
	StreamBouquetKey   = "stream.bouquet"

	// Transcoding attributes
	TranscodeCodecKey       = "transcode.codec"
	TranscodeInputCodecKey  = "transcode.input_codec"
	TranscodeOutputCodecKey = "transcode.output_codec"
	TranscodeBitrateKey     = "transcode.bitrate"
	TranscodeResolutionKey  = "transcode.resolution"
	TranscodeDeviceKey      = "transcode.device"
	TranscodeGPUEnabledKey  = "transcode.gpu_enabled"

	// EPG attributes
	EPGDaysKey        = "epg.days"
	EPGChannelsKey    = "epg.channels"
	EPGEventsKey      = "epg.events"
	EPGConcurrencyKey = "epg.concurrency"
	EPGRetriesKey     = "epg.retries"

	// Job attributes
	JobTypeKey     = "job.type"
	JobStatusKey   = "job.status"
	JobDurationKey = "job.duration_ms"

	// Error attributes
	ErrorKey     = "error"
	ErrorTypeKey = "error.type"
)

Common attribute keys for consistent tracing across the application.

Variables

This section is empty.

Functions

func EPGAttributes

func EPGAttributes(days, channels, events, concurrency, retries int) []attribute.KeyValue

EPGAttributes creates EPG-related span attributes.

func ErrorAttributes

func ErrorAttributes(_ error, errorType string) []attribute.KeyValue

ErrorAttributes creates error-related span attributes.

func HTTPAttributes

func HTTPAttributes(method, route, url string, statusCode int) []attribute.KeyValue

HTTPAttributes creates common HTTP span attributes.

func JobAttributes

func JobAttributes(jobType, status string, durationMS int64) []attribute.KeyValue

JobAttributes creates job-related span attributes.

func StreamAttributes

func StreamAttributes(channel, serviceID, bouquet string) []attribute.KeyValue

StreamAttributes creates streaming-related span attributes.

func Tracer

func Tracer(name string) trace.Tracer

Tracer returns a tracer for the given name.

func TranscodeAttributes

func TranscodeAttributes(inputCodec, outputCodec, device string, bitrate int, gpuEnabled bool) []attribute.KeyValue

TranscodeAttributes creates transcoding-related span attributes.

Types

type Config

type Config struct {
	// Enabled determines if telemetry is active
	Enabled bool

	// ServiceName is the name of the service (e.g., "xg2g")
	ServiceName string

	// ServiceVersion is the version of the service
	ServiceVersion string

	// Environment is the deployment environment (e.g., "production", "development")
	Environment string

	// ExporterType defines the exporter to use: "grpc", "http", or "noop"
	ExporterType string

	// Endpoint is the OTLP collector endpoint (e.g., "localhost:4317" for gRPC, "localhost:4318" for HTTP)
	Endpoint string

	// SamplingRate is the trace sampling rate (0.0 to 1.0, where 1.0 = 100%)
	SamplingRate float64
}

Config holds telemetry configuration.

type Provider

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

Provider manages the OpenTelemetry tracer provider.

func NewProvider

func NewProvider(ctx context.Context, cfg Config) (*Provider, error)

NewProvider creates and initializes a new OpenTelemetry tracer provider.

func (*Provider) Shutdown

func (p *Provider) Shutdown(ctx context.Context) error

Shutdown gracefully shuts down the tracer provider.

Jump to

Keyboard shortcuts

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