telemetry

package
v1.27.0 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package telemetry는 OpenTelemetry tracing 설정과 context 전파 helper를 제공합니다.

패키지 개요

이 패키지는 OpenTelemetry 기반 분산 추적을 서비스 공통 방식으로 구성합니다. Config로 service metadata, OTLP gRPC endpoint, TLS 사용 여부, sampler 비율을 지정하고 config.Enabled=true일 때 NewProvider가 exporter, resource, sampler, global provider를 설치합니다. Enabled=false이면 no-op Provider를 반환합니다.

주요 사용 패턴

config := telemetry.Config{}
config.Enabled = true
config.ServiceName = "llm-sched"
config.OTLPEndpoint = "otel-collector:4317"
config.OTLPInsecure = true
config.SampleRate = 1.0
provider, err := telemetry.NewProvider(ctx, config)
if err != nil {
    return err
}
defer provider.Shutdown(ctx)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Enabled: true면 트레이싱을 활성화합니다.
	Enabled bool

	// ServiceName: 서비스 식별자입니다 (예: "mcp-llm-server").
	ServiceName string

	// ServiceVersion: 서비스 버전입니다 (예: "1.0.0").
	ServiceVersion string

	// Environment: 배포 환경입니다 (예: "production", "development").
	Environment string

	// OTLPEndpoint: OTLP collector/exporter 주소입니다.
	// 예: "otel-collector:4317" (gRPC) 또는 "otel-collector:4318" (HTTP)
	OTLPEndpoint string

	// OTLPInsecure: true면 TLS 없이 연결합니다. 내부망에서만 사용하세요.
	OTLPInsecure bool

	// SampleRate: 샘플링 비율입니다 (0.0 ~ 1.0). 1.0이면 전체 트레이싱.
	// 프로덕션에서는 0.1 ~ 0.5 권장.
	SampleRate float64
}

type Provider

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

func NewProvider

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

config.Enabled가 false면 no-op Provider를 반환합니다.

func (*Provider) IsEnabled

func (p *Provider) IsEnabled() bool

func (*Provider) Shutdown

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

버퍼에 남은 span들을 flush하여 데이터 유실을 방지합니다.

Jump to

Keyboard shortcuts

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